@@ -43,6 +43,41 @@ describe('IgxGrid - CRUD operations #grid', () => {
4343 expect ( grid . rowList . length ) . toEqual ( expectedLength ) ;
4444 } ) ;
4545
46+ it ( 'should keep the external data array reference in sync after repeated addRow() calls' , ( ) => {
47+ const originalRef = fix . componentInstance . data ;
48+
49+ for ( let i = 2 ; i <= 6 ; i ++ ) {
50+ grid . addRow ( { index : i , value : i * 10 } ) ;
51+ }
52+ fix . detectChanges ( ) ;
53+
54+ expect ( grid . data ) . toBe ( originalRef ) ;
55+ expect ( data . length ) . toEqual ( 6 ) ;
56+ expect ( data . find ( r => r . index === 6 ) ) . toBeDefined ( ) ;
57+ expect ( data ) . toBe ( grid . data ) ;
58+ } ) ;
59+
60+ it ( 'should keep the external data array reference in sync after repeated deleteRow() calls' , ( ) => {
61+ const originalRef = fix . componentInstance . data ;
62+
63+ for ( let i = 2 ; i <= 5 ; i ++ ) {
64+ grid . addRow ( { index : i , value : i * 10 } ) ;
65+ }
66+ fix . detectChanges ( ) ;
67+
68+ expect ( data . length ) . toEqual ( 5 ) ;
69+
70+ grid . deleteRow ( 1 ) ;
71+ grid . deleteRow ( 3 ) ;
72+ fix . detectChanges ( ) ;
73+
74+ expect ( grid . data ) . toBe ( originalRef ) ;
75+ expect ( data . length ) . toEqual ( 3 ) ;
76+ expect ( data . find ( r => r . index === 1 ) ) . toBeUndefined ( ) ;
77+ expect ( data . find ( r => r . index === 3 ) ) . toBeUndefined ( ) ;
78+ expect ( data ) . toBe ( grid . data ) ;
79+ } ) ;
80+
4681 // No longer supported - array mutations are not detected automatically, need ref change.
4782 xit ( 'should support adding rows by manipulating the `data` @Input of the grid' , ( ) => {
4883 // Add to the data array without changing the reference
0 commit comments