File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed
Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -1180,7 +1180,7 @@ angular.module('ui.grid')
11801180 }
11811181 } ) ;
11821182
1183- if ( self . selection ) {
1183+ if ( self . selection && self . rows . length ) {
11841184 self . selection . selectAll = allRowsSelected ;
11851185 }
11861186
Original file line number Diff line number Diff line change @@ -530,6 +530,39 @@ describe('Grid factory', function () {
530530 } ) ;
531531 } ) ;
532532
533+ describe ( 'selection' , function ( ) {
534+ var grid ;
535+
536+ beforeEach ( function ( ) {
537+ grid = new Grid ( { id : 1 , enableRowHashing : false } ) ;
538+ spyOn ( grid , 'getRow' ) . and . callFake ( function ( newEntity ) {
539+ return newEntity ;
540+ } ) ;
541+
542+ grid . rows = [ ] ;
543+ grid . selection = { selectAll : false } ;
544+ } ) ;
545+ afterEach ( function ( ) {
546+ grid . getRow . calls . reset ( ) ;
547+ } ) ;
548+
549+ it ( 'should enable selectAll if a new row is added that is already selected' , function ( ) {
550+ grid . modifyRows ( [ { isSelected : true } ] ) ;
551+
552+ expect ( grid . selection . selectAll ) . toBe ( true ) ;
553+ } ) ;
554+ it ( 'should disable selectAll if a new row is added that is not selected' , function ( ) {
555+ grid . modifyRows ( [ { isSelected : false } ] ) ;
556+
557+ expect ( grid . selection . selectAll ) . toBe ( false ) ;
558+ } ) ;
559+ it ( 'should not update selectAll if there are no rows' , function ( ) {
560+ grid . modifyRows ( [ ] ) ;
561+
562+ expect ( grid . selection . selectAll ) . toBe ( false ) ;
563+ } ) ;
564+ } ) ;
565+
533566 describe ( 'follow source array' , function ( ) {
534567 var dataRows , grid ;
535568
You can’t perform that action at this time.
0 commit comments