@@ -1640,6 +1640,7 @@ describe('IgxGrid Component Tests', () => {
16401640 beforeEach ( async ( ( ) => {
16411641 TestBed . configureTestingModule ( {
16421642 declarations : [
1643+ IgxGridTestComponent ,
16431644 IgxBasicGridRowEditingComponent ,
16441645 IgxGridRowEditingComponent ,
16451646 IgxGridRowEditingWithoutEditableColumnsComponent ,
@@ -3496,19 +3497,61 @@ describe('IgxGrid Component Tests', () => {
34963497 } ) ;
34973498
34983499 describe ( 'Row Editing - Column editable property' , ( ) => {
3499- it ( 'Default column editable value is true , when row editing is enabled' , fakeAsync ( ( ) => {
3500+ it ( 'Default column editable value is correct , when row editing is enabled' , fakeAsync ( ( ) => {
35003501 const fixture = TestBed . createComponent ( IgxGridRowEditingWithoutEditableColumnsComponent ) ;
35013502 fixture . detectChanges ( ) ;
3502- tick ( 16 ) ;
3503+ tick ( ) ;
35033504
35043505 const grid = fixture . componentInstance . grid ;
35053506
3506- const columns : IgxColumnComponent [ ] = grid . columnList . toArray ( ) ;
3507- expect ( columns [ 0 ] . editable ) . toBeFalsy ( ) ;
3508- expect ( columns [ 1 ] . editable ) . toBeFalsy ( ) ;
3509- expect ( columns [ 2 ] . editable ) . toBeTruthy ( ) ;
3510- expect ( columns [ 3 ] . editable ) . toBeTruthy ( ) ;
3511- expect ( columns [ 4 ] . editable ) . toBeFalsy ( ) ;
3507+ let columns : IgxColumnComponent [ ] = grid . columnList . toArray ( ) ;
3508+ expect ( columns [ 0 ] . editable ) . toBeTruthy ( ) ; // column.editable not set
3509+ expect ( columns [ 1 ] . editable ) . toBeFalsy ( ) ; // column.editable not set. Primary column
3510+ expect ( columns [ 2 ] . editable ) . toBeTruthy ( ) ; // column.editable set to true
3511+ expect ( columns [ 3 ] . editable ) . toBeTruthy ( ) ; // column.editable not set
3512+ expect ( columns [ 4 ] . editable ) . toBeFalsy ( ) ; // column.editable set to false
3513+
3514+ grid . rowEditable = false ;
3515+ columns = grid . columnList . toArray ( ) ;
3516+ expect ( columns [ 0 ] . editable ) . toBeFalsy ( ) ; // column.editable not set
3517+ expect ( columns [ 1 ] . editable ) . toBeFalsy ( ) ; // column.editable not set. Primary column
3518+ expect ( columns [ 2 ] . editable ) . toBeTruthy ( ) ; // column.editable set to true
3519+ expect ( columns [ 3 ] . editable ) . toBeFalsy ( ) ; // column.editable not set
3520+ expect ( columns [ 4 ] . editable ) . toBeFalsy ( ) ; // column.editable set to false
3521+
3522+ grid . rowEditable = true ;
3523+ columns = grid . columnList . toArray ( ) ;
3524+ expect ( columns [ 0 ] . editable ) . toBeTruthy ( ) ; // column.editable not set
3525+ expect ( columns [ 1 ] . editable ) . toBeFalsy ( ) ; // column.editable not set. Primary column
3526+ expect ( columns [ 2 ] . editable ) . toBeTruthy ( ) ; // column.editable set to true
3527+ expect ( columns [ 3 ] . editable ) . toBeTruthy ( ) ; // column.editable not set
3528+ expect ( columns [ 4 ] . editable ) . toBeFalsy ( ) ; // column.editable set to false
3529+ } ) ) ;
3530+
3531+ it ( `Default column editable value is correct, when row edititng is disabled` , fakeAsync ( ( ) => {
3532+ const fixture = TestBed . createComponent ( IgxGridTestComponent ) ;
3533+ fixture . componentInstance . columns . push ( { field : 'ID' , header : 'ID' , dataType : 'number' , width : null , hasSummary : false } ) ;
3534+ fixture . componentInstance . data = [
3535+ { ID : 0 , index : 0 , value : 0 } ,
3536+ { ID : 1 , index : 1 , value : 1 } ,
3537+ { ID : 2 , index : 2 , value : 2 } ,
3538+ ] ;
3539+ const grid = fixture . componentInstance . grid ;
3540+ grid . primaryKey = 'ID' ;
3541+
3542+ fixture . detectChanges ( ) ;
3543+ tick ( ) ;
3544+
3545+ let columns : IgxColumnComponent [ ] = grid . columnList . toArray ( ) ;
3546+ expect ( columns [ 0 ] . editable ) . toBeFalsy ( ) ; // column.editable not set
3547+ expect ( columns [ 1 ] . editable ) . toBeFalsy ( ) ; // column.editable not set
3548+ expect ( columns [ 2 ] . editable ) . toBeFalsy ( ) ; // column.editable not set. Primary column
3549+
3550+ grid . rowEditable = true ;
3551+ columns = grid . columnList . toArray ( ) ;
3552+ expect ( columns [ 0 ] . editable ) . toBeTruthy ( ) ; // column.editable not set
3553+ expect ( columns [ 1 ] . editable ) . toBeTruthy ( ) ; // column.editable not set
3554+ expect ( columns [ 2 ] . editable ) . toBeFalsy ( ) ; // column.editable not set. Primary column
35123555 } ) ) ;
35133556 } ) ;
35143557
0 commit comments