@@ -207,8 +207,22 @@ describe('Slash Commands', () => {
207
207
208
208
expect ( ( ) => {
209
209
const option = getStringOption ( ) ;
210
- option . autocomplete = true ;
211
- option . choices = [ { name : 'Fancy Pants' , value : 'fp_1' } ] ;
210
+ Reflect . set ( option , 'autocomplete' , true ) ;
211
+ Reflect . set ( option , 'choices' , [ { name : 'Fancy Pants' , value : 'fp_1' } ] ) ;
212
+ return option . toJSON ( ) ;
213
+ } ) . toThrowError ( ) ;
214
+
215
+ expect ( ( ) => {
216
+ const option = getNumberOption ( ) ;
217
+ Reflect . set ( option , 'autocomplete' , true ) ;
218
+ Reflect . set ( option , 'choices' , [ { name : 'Fancy Pants' , value : 'fp_1' } ] ) ;
219
+ return option . toJSON ( ) ;
220
+ } ) . toThrowError ( ) ;
221
+
222
+ expect ( ( ) => {
223
+ const option = getIntegerOption ( ) ;
224
+ Reflect . set ( option , 'autocomplete' , true ) ;
225
+ Reflect . set ( option , 'choices' , [ { name : 'Fancy Pants' , value : 'fp_1' } ] ) ;
212
226
return option . toJSON ( ) ;
213
227
} ) . toThrowError ( ) ;
214
228
} ) ;
@@ -229,14 +243,6 @@ describe('Slash Commands', () => {
229
243
expect ( ( ) => getBuilder ( ) . addChannelOption ( getChannelOption ( ) . addChannelType ( 100 ) ) ) . toThrowError ( ) ;
230
244
231
245
expect ( ( ) => getBuilder ( ) . addChannelOption ( getChannelOption ( ) . addChannelTypes ( [ 100 , 200 ] ) ) ) . toThrowError ( ) ;
232
-
233
- expect ( ( ) => getBuilder ( ) . addChannelOption ( getChannelOption ( ) . addChannelType ( 100 ) ) ) . toThrowError ( ) ;
234
-
235
- expect ( ( ) => getBuilder ( ) . addChannelOption ( getChannelOption ( ) . addChannelType ( 1 ) ) ) . toThrowError ( ) ;
236
-
237
- expect ( ( ) => getBuilder ( ) . addChannelOption ( getChannelOption ( ) . addChannelType ( 1 ) ) ) . toThrowError ( ) ;
238
-
239
- expect ( ( ) => getBuilder ( ) . addChannelOption ( getChannelOption ( ) . addChannelTypes ( [ 1 , 2 , 3 ] ) ) ) . toThrowError ( ) ;
240
246
} ) ;
241
247
242
248
test ( 'GIVEN a builder with invalid number min/max options THEN does throw an error' , ( ) => {
@@ -324,6 +330,22 @@ describe('Slash Commands', () => {
324
330
test ( 'GIVEN valid builder with defaultPermission false THEN does not throw error' , ( ) => {
325
331
expect ( ( ) => getBuilder ( ) . setName ( 'foo' ) . setDescription ( 'foo' ) . setDefaultPermission ( false ) ) . not . toThrowError ( ) ;
326
332
} ) ;
333
+
334
+ test ( 'GIVEN an option that is autocompletable and has choices, THEN setting choices to an empty array should not throw an error' , ( ) => {
335
+ expect ( ( ) =>
336
+ getBuilder ( ) . addStringOption ( getStringOption ( ) . setAutocomplete ( true ) . setChoices ( [ ] ) ) ,
337
+ ) . not . toThrowError ( ) ;
338
+ } ) ;
339
+
340
+ test ( 'GIVEN an option that is autocompletable and has choices, THEN setting choices should throw an error' , ( ) => {
341
+ expect ( ( ) =>
342
+ getBuilder ( ) . addStringOption (
343
+ getStringOption ( )
344
+ . setAutocomplete ( true )
345
+ . setChoices ( [ [ 'owo' , 'uwu' ] ] ) ,
346
+ ) ,
347
+ ) . toThrowError ( ) ;
348
+ } ) ;
327
349
} ) ;
328
350
329
351
describe ( 'Builder with subcommand (group) options' , ( ) => {
0 commit comments