@@ -271,49 +271,62 @@ describe('selectByIndexesCommand', () => {
271271 afterEach ( ( ) => afterTest ( ) ) ;
272272
273273 describe ( 'schema' , ( ) => {
274- it ( 'accepts an array of positive integers with deselect' , ( ) => {
274+ it ( 'accepts an array of positive integers with mode deselect' , ( ) => {
275275 expect ( selectByIndexesCommand . schema . safeParse ( {
276- indexes : [ 1 , 2 , 3 ] , deselect : true ,
276+ indexes : [ 1 , 2 , 3 ] , mode : 'deselect' ,
277+ } ) . success ) . toBe ( true ) ;
278+ } ) ;
279+
280+ it ( 'accepts mode select' , ( ) => {
281+ expect ( selectByIndexesCommand . schema . safeParse ( {
282+ indexes : [ 1 ] , mode : 'select' ,
277283 } ) . success ) . toBe ( true ) ;
278284 } ) ;
279285
280286 it ( 'rejects when indexes is missing' , ( ) => {
281- expect ( selectByIndexesCommand . schema . safeParse ( { } ) . success ) . toBe ( false ) ;
287+ expect ( selectByIndexesCommand . schema . safeParse ( { mode : 'select' } ) . success ) . toBe ( false ) ;
282288 } ) ;
283289
284- it ( 'accepts when deselect is omitted (optional) ' , ( ) => {
290+ it ( 'rejects when mode is missing ' , ( ) => {
285291 expect ( selectByIndexesCommand . schema . safeParse ( {
286292 indexes : [ 1 ] ,
287- } ) . success ) . toBe ( true ) ;
293+ } ) . success ) . toBe ( false ) ;
294+ } ) ;
295+
296+ it ( 'rejects an invalid mode value' , ( ) => {
297+ expect ( selectByIndexesCommand . schema . safeParse ( {
298+ indexes : [ 1 ] , mode : 'toggle' ,
299+ } ) . success ) . toBe ( false ) ;
288300 } ) ;
289301
290302 it ( 'rejects when indexes is an empty array' , ( ) => {
291303 expect ( selectByIndexesCommand . schema . safeParse ( {
292- indexes : [ ] ,
304+ indexes : [ ] , mode : 'select' ,
293305 } ) . success ) . toBe ( false ) ;
294306 } ) ;
295307
296308 it ( 'rejects zero (indexes are 1-based)' , ( ) => {
297309 expect ( selectByIndexesCommand . schema . safeParse ( {
298- indexes : [ 0 ] ,
310+ indexes : [ 0 ] , mode : 'select' ,
299311 } ) . success ) . toBe ( false ) ;
300312 } ) ;
301313
302314 it ( 'rejects negative indexes' , ( ) => {
303315 expect ( selectByIndexesCommand . schema . safeParse ( {
304- indexes : [ - 1 ] ,
316+ indexes : [ - 1 ] , mode : 'select' ,
305317 } ) . success ) . toBe ( false ) ;
306318 } ) ;
307319
308320 it ( 'rejects non-integer indexes' , ( ) => {
309321 expect ( selectByIndexesCommand . schema . safeParse ( {
310- indexes : [ 1.5 ] ,
322+ indexes : [ 1.5 ] , mode : 'select' ,
311323 } ) . success ) . toBe ( false ) ;
312324 } ) ;
313325
314326 it ( 'rejects unknown properties' , ( ) => {
315327 expect ( selectByIndexesCommand . schema . safeParse ( {
316328 indexes : [ 1 ] ,
329+ mode : 'select' ,
317330 extra : 1 ,
318331 } ) . success ) . toBe ( false ) ;
319332 } ) ;
@@ -326,7 +339,7 @@ describe('selectByIndexesCommand', () => {
326339 const callbacks = createCallbacks ( ) ;
327340
328341 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
329- indexes : [ 1 ] ,
342+ indexes : [ 1 ] , mode : 'select' ,
330343 } ) ;
331344
332345 expect ( result . status ) . toBe ( 'failure' ) ;
@@ -340,7 +353,7 @@ describe('selectByIndexesCommand', () => {
340353
341354 // Three rows in createGrid; 1-based index 100 has no row on the current page.
342355 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
343- indexes : [ 1 , 100 ] ,
356+ indexes : [ 1 , 100 ] , mode : 'select' ,
344357 } ) ;
345358
346359 expect ( result . status ) . toBe ( 'failure' ) ;
@@ -360,7 +373,7 @@ describe('selectByIndexesCommand', () => {
360373 const callbacks = createCallbacks ( ) ;
361374
362375 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
363- indexes : [ 1 ] ,
376+ indexes : [ 1 ] , mode : 'select' ,
364377 } ) ;
365378
366379 expect ( result . status ) . toBe ( 'failure' ) ;
@@ -373,21 +386,21 @@ describe('selectByIndexesCommand', () => {
373386 const callbacks = createCallbacks ( ) ;
374387
375388 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
376- indexes : [ 1 , 3 ] ,
389+ indexes : [ 1 , 3 ] , mode : 'select' ,
377390 } ) ;
378391
379392 expect ( selectSpy ) . toHaveBeenCalledWith ( [ 0 , 2 ] ) ;
380393 expect ( result . status ) . toBe ( 'success' ) ;
381394 } ) ;
382395
383- it ( 'selects when deselect is omitted (defaults to selecting) ' , async ( ) => {
396+ it ( 'selects when mode is select ' , async ( ) => {
384397 const instance = await createGrid ( ) ;
385398 const selectSpy = jest . spyOn ( instance , 'selectRowsByIndexes' ) . mockReturnValue ( Promise . resolve ( [ ] ) as never ) ;
386399 const deselectSpy = jest . spyOn ( instance , 'deselectRows' ) ;
387400 const callbacks = createCallbacks ( ) ;
388401
389402 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
390- indexes : [ 1 , 3 ] ,
403+ indexes : [ 1 , 3 ] , mode : 'select' ,
391404 } ) ;
392405
393406 expect ( selectSpy ) . toHaveBeenCalledWith ( [ 0 , 2 ] ) ;
@@ -402,7 +415,7 @@ describe('selectByIndexesCommand', () => {
402415 const callbacks = createCallbacks ( ) ;
403416
404417 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
405- indexes : [ 1 ] , deselect : true ,
418+ indexes : [ 1 ] , mode : 'deselect' ,
406419 } ) ;
407420
408421 expect ( deselectSpy ) . toHaveBeenCalledWith ( [ 1 ] ) ;
@@ -418,7 +431,7 @@ describe('selectByIndexesCommand', () => {
418431 const callbacks = createCallbacks ( ) ;
419432
420433 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
421- indexes : [ 1 ] ,
434+ indexes : [ 1 ] , mode : 'select' ,
422435 } ) ;
423436
424437 expect ( result . status ) . toBe ( 'failure' ) ;
@@ -431,7 +444,7 @@ describe('selectByIndexesCommand', () => {
431444 const callbacks = createCallbacks ( ) ;
432445
433446 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
434- indexes : [ 1 ] ,
447+ indexes : [ 1 ] , mode : 'select' ,
435448 } ) ;
436449
437450 expect ( result . status ) . toBe ( 'failure' ) ;
@@ -444,7 +457,7 @@ describe('selectByIndexesCommand', () => {
444457 const callbacks = createCallbacks ( ) ;
445458
446459 const result = await selectByIndexesCommand . execute ( instance , callbacks ) ( {
447- indexes : [ 1 ] , deselect : true ,
460+ indexes : [ 1 ] , mode : 'deselect' ,
448461 } ) ;
449462
450463 expect ( result . status ) . toBe ( 'failure' ) ;
@@ -458,7 +471,7 @@ describe('selectByIndexesCommand', () => {
458471 const callbacks = createCallbacks ( ) ;
459472
460473 await selectByIndexesCommand . execute ( instance , callbacks ) ( {
461- indexes : [ 1 , 3 ] ,
474+ indexes : [ 1 , 3 ] , mode : 'select' ,
462475 } ) ;
463476
464477 expect ( callbacks . success ) . toHaveBeenCalledWith ( 'Select row(s) number 1, 3 on the current page.' ) ;
@@ -470,7 +483,7 @@ describe('selectByIndexesCommand', () => {
470483 const callbacks = createCallbacks ( ) ;
471484
472485 await selectByIndexesCommand . execute ( instance , callbacks ) ( {
473- indexes : [ 1 ] , deselect : true ,
486+ indexes : [ 1 ] , mode : 'deselect' ,
474487 } ) ;
475488
476489 expect ( callbacks . success ) . toHaveBeenCalledWith ( 'Deselect row(s) number 1 on the current page.' ) ;
@@ -481,7 +494,7 @@ describe('selectByIndexesCommand', () => {
481494 const callbacks = createCallbacks ( ) ;
482495
483496 await selectByIndexesCommand . execute ( instance , callbacks ) ( {
484- indexes : [ 1 ] ,
497+ indexes : [ 1 ] , mode : 'select' ,
485498 } ) ;
486499
487500 expect ( callbacks . failure ) . toHaveBeenCalledWith ( 'Select row(s) number 1 on the current page.' ) ;
0 commit comments