@@ -123,8 +123,10 @@ describe('ui.grid.selection uiGridSelectionService', function() {
123
123
it ( 'should utilize public apis' , function ( ) {
124
124
grid . api . selection . toggleRowSelection ( grid . rows [ 0 ] . entity ) ;
125
125
expect ( uiGridSelectionService . getSelectedRows ( grid ) . length ) . toBe ( 1 ) ;
126
+ expect ( uiGridSelectionService . getUnSelectedRows ( grid ) . length ) . toBe ( 9 ) ;
126
127
grid . api . selection . clearSelectedRows ( ) ;
127
128
expect ( uiGridSelectionService . getSelectedRows ( grid ) . length ) . toBe ( 0 ) ;
129
+ expect ( uiGridSelectionService . getUnSelectedRows ( grid ) . length ) . toBe ( 10 ) ;
128
130
} ) ;
129
131
} ) ;
130
132
@@ -368,6 +370,11 @@ describe('ui.grid.selection uiGridSelectionService', function() {
368
370
} ) ;
369
371
370
372
describe ( 'getSelectedRows function' , function ( ) {
373
+ it ( 'should retrieve empty array if nothing selected' , function ( ) {
374
+ expect ( grid . api . selection . getSelectedRows ( ) . length ) . toBe ( 0 ) ;
375
+ expect ( grid . api . selection . getSelectedGridRows ( ) . length ) . toBe ( 0 ) ;
376
+ } ) ;
377
+
371
378
it ( 'should retrieve the selected rows that have a $$hashKey property' , function ( ) {
372
379
grid . rows . forEach ( function ( row ) {
373
380
row . isSelected = false ;
@@ -387,6 +394,56 @@ describe('ui.grid.selection uiGridSelectionService', function() {
387
394
} ;
388
395
389
396
expect ( grid . api . selection . getSelectedRows ( ) . length ) . toEqual ( 2 ) ;
397
+ expect ( grid . api . selection . getSelectedGridRows ( ) . length ) . toEqual ( 2 ) ;
398
+ } ) ;
399
+
400
+ it ( 'should retrieve correct data' , function ( ) {
401
+ grid . rows [ 0 ] . isSelected = true ;
402
+ grid . rows [ 0 ] . entity = {
403
+ $$hashKey : '1234'
404
+ } ;
405
+
406
+ expect ( grid . api . selection . getSelectedRows ( ) [ 0 ] . $$hashKey ) . toEqual ( '1234' ) ;
407
+ expect ( grid . api . selection . getSelectedGridRows ( ) [ 0 ] . entity ) . toEqual ( {
408
+ $$hashKey : '1234'
409
+ } ) ;
410
+ } ) ;
411
+ } ) ;
412
+
413
+ describe ( 'getUnSelectedRows function' , function ( ) {
414
+ it ( 'should retrieve every row if nothing selected' , function ( ) {
415
+ expect ( grid . api . selection . getUnSelectedRows ( ) . length ) . toEqual ( 10 ) ;
416
+ expect ( grid . api . selection . getUnSelectedGridRows ( ) . length ) . toEqual ( 10 ) ;
417
+ } ) ;
418
+
419
+ it ( 'should retrieve the unselected rows that have a $$hashKey property' , function ( ) {
420
+ grid . rows . forEach ( function ( row ) {
421
+ row . isSelected = false ;
422
+ row . entity = {
423
+ $$hashKey : '1234'
424
+ } ;
425
+ } ) ;
426
+
427
+ grid . rows [ 0 ] . isSelected = true ;
428
+ grid . rows [ 1 ] . isSelected = true ;
429
+ grid . rows [ 2 ] . isSelected = true ;
430
+ grid . rows [ 2 ] . entity = { } ;
431
+ grid . rows [ 3 ] . entity = { } ;
432
+
433
+ expect ( grid . api . selection . getUnSelectedRows ( ) . length ) . toEqual ( 8 ) ;
434
+ expect ( grid . api . selection . getUnSelectedGridRows ( ) . length ) . toEqual ( 7 ) ;
435
+ } ) ;
436
+
437
+ it ( 'should retrieve correct data' , function ( ) {
438
+ grid . rows [ 0 ] . isSelected = false ;
439
+ grid . rows [ 0 ] . entity = {
440
+ $$hashKey : '1234'
441
+ } ;
442
+
443
+ expect ( grid . api . selection . getUnSelectedRows ( ) [ 0 ] . $$hashKey ) . toEqual ( '1234' ) ;
444
+ expect ( grid . api . selection . getUnSelectedGridRows ( ) [ 0 ] . entity ) . toEqual ( {
445
+ $$hashKey : '1234'
446
+ } ) ;
390
447
} ) ;
391
448
} ) ;
392
449
0 commit comments