@@ -43,7 +43,7 @@ describe("Test mention each function", () => {
43
43
( res ) => res . json ( )
44
44
) ;
45
45
expect ( textMessage . data . content ) . toBe (
46
- `Sorry no user found under <@&${ roleId } > role.`
46
+ `Sorry no user found with <@&${ roleId } > role.`
47
47
) ;
48
48
} ) ;
49
49
@@ -60,7 +60,7 @@ describe("Test mention each function", () => {
60
60
( res ) => res . json ( )
61
61
) ;
62
62
expect ( textMessage . data . content ) . toBe (
63
- `Sorry no user found under <@&${ roleId } > role.`
63
+ `Sorry no user found with <@&${ roleId } > role.`
64
64
) ;
65
65
} ) ;
66
66
@@ -108,11 +108,16 @@ describe("Test mention each function", () => {
108
108
expect ( response ) . toBe ( expectedResponse ) ;
109
109
} ) ;
110
110
111
- it ( "should return default string " , ( ) => {
112
- const usersWithMatchingRole = [ ] as string [ ] ;
111
+ it ( "should return default string" , ( ) => {
112
+ const roleId = "1118201414078976192" ;
113
+ const usersWithMatchingRole : string [ ] = [ ] ;
113
114
const msgToBeSent = "hello" ;
114
- const response = checkDisplayType ( { usersWithMatchingRole, msgToBeSent } ) ;
115
- const expectedResponse = `Sorry no user found under this role.` ;
115
+ const response = checkDisplayType ( {
116
+ usersWithMatchingRole,
117
+ msgToBeSent,
118
+ roleId,
119
+ } ) ;
120
+ const expectedResponse = `Sorry no user found with <@&${ roleId } > role.` ;
116
121
expect ( response ) . toBe ( expectedResponse ) ;
117
122
} ) ;
118
123
@@ -128,37 +133,18 @@ describe("Test mention each function", () => {
128
133
expect ( response ) . toBe ( expectedResponse ) ;
129
134
} ) ;
130
135
131
- it ( "should handle custom message when provided" , async ( ) => {
132
- const env = {
133
- BOT_PUBLIC_KEY : "xyz" ,
134
- DISCORD_GUILD_ID : "123" ,
135
- DISCORD_TOKEN : "abc" ,
136
- } ;
137
- const customArg = {
138
- ...transformedArgument ,
139
- displayMessageObj : {
140
- name : "displayMessage" ,
141
- type : 3 ,
142
- value : "Custom message:" ,
143
- } ,
144
- } ;
145
- const response = mentionEachUser ( customArg , env , ctx ) ;
146
- expect ( response ) . toBeInstanceOf ( Promise ) ;
147
- const textMessage : { data : { content : string } } = await response . then (
148
- ( res ) => res . json ( )
149
- ) ;
150
- expect ( textMessage . data . content ) . toContain ( "Custom message:" ) ;
151
- } ) ;
152
-
153
- it ( "should handle message with no matching users" , ( ) => {
154
- const usersWithMatchingRole = [ ] as string [ ] ;
155
- const roleId = "1118201414078976192" ;
156
- const msgToBeSent = "No users found:" ;
157
- const response = checkDisplayType ( { usersWithMatchingRole, msgToBeSent } ) ;
158
- const modifiedResponse = response . replace ( "this" , `<@&${ roleId } >` ) ;
159
- expect ( modifiedResponse ) . toBe (
160
- `Sorry no user found under <@&${ roleId } > role.`
161
- ) ;
136
+ describe ( "checkDisplayType" , ( ) => {
137
+ it ( "should handle message with no matching users" , ( ) => {
138
+ const usersWithMatchingRole : string [ ] = [ ] ;
139
+ const roleId = "1118201414078976192" ;
140
+ const msgToBeSent = "No users found:" ;
141
+ const response = checkDisplayType ( {
142
+ usersWithMatchingRole,
143
+ msgToBeSent,
144
+ roleId,
145
+ } ) ;
146
+ expect ( response ) . toBe ( `Sorry no user found with <@&${ roleId } > role.` ) ;
147
+ } ) ;
162
148
} ) ;
163
149
it ( "should handle case when only one user found" , ( ) => {
164
150
const roleId = "860900892193456149" ;
@@ -175,9 +161,9 @@ describe("Test mention each function", () => {
175
161
} ,
176
162
] ;
177
163
const response = filterUserByRoles ( optionsArray , roleId ) ;
178
- const message = `The user with <@&${ roleId } > roles is: ${ response } ` ;
164
+ const message = `The user with <@&${ roleId } > role is: ${ response } ` ;
179
165
expect ( message ) . toBe (
180
- `The user with <@&${ roleId } > roles is: <@${ optionsArray [ 0 ] . user . id } >`
166
+ `The user with <@&${ roleId } > role is: <@${ optionsArray [ 0 ] . user . id } >`
181
167
) ;
182
168
} ) ;
183
169
} ) ;
0 commit comments