22import { TestBed , waitForAsync , ComponentFixture } from '@angular/core/testing' ;
33import { By } from '@angular/platform-browser' ;
44import { IgxTreeGridModule , IgxTreeGridComponent } from './public_api' ;
5- import { IgxTreeGridEditActionsComponent } from '../../test-utils/tree-grid-components.spec' ;
5+ import { IgxTreeGridEditActionsComponent , IgxTreeGridEditActionsPinningComponent } from '../../test-utils/tree-grid-components.spec' ;
66import { configureTestSuite } from '../../test-utils/configure-suite' ;
77import { NoopAnimationsModule } from '@angular/platform-browser/animations' ;
88import { IgxActionStripModule , IgxActionStripComponent } from '../../action-strip/public_api' ;
@@ -23,7 +23,8 @@ describe('IgxTreeGrid - Add Row UI #tGrid', () => {
2323 beforeAll ( waitForAsync ( ( ) => {
2424 TestBed . configureTestingModule ( {
2525 declarations : [
26- IgxTreeGridEditActionsComponent
26+ IgxTreeGridEditActionsComponent ,
27+ IgxTreeGridEditActionsPinningComponent
2728 ] ,
2829 imports : [ IgxTreeGridModule , NoopAnimationsModule , IgxActionStripModule ]
2930 } ) . compileComponents ( ) ;
@@ -126,5 +127,70 @@ describe('IgxTreeGrid - Add Row UI #tGrid', () => {
126127
127128 expect ( treeGrid . rowList . length ) . toBe ( 1 ) ;
128129 } ) ;
130+
131+ it ( 'should add row on correct position and enter edit mode from pinned row - pinning position: Top' , ( ) => {
132+ fix = TestBed . createComponent ( IgxTreeGridEditActionsPinningComponent ) ;
133+ fix . detectChanges ( ) ;
134+ treeGrid = fix . componentInstance . treeGrid ;
135+ actionStrip = fix . componentInstance . actionStrip ;
136+
137+ treeGrid . pinRow ( 1 ) ;
138+ treeGrid . pinRow ( 6 ) ;
139+
140+ expect ( treeGrid . getRowByKey ( 1 ) . pinned ) . toBeTrue ( ) ;
141+ expect ( treeGrid . getRowByKey ( 6 ) . pinned ) . toBeTrue ( ) ;
142+
143+ actionStrip . show ( treeGrid . rowList . toArray ( ) [ 1 ] ) ;
144+ fix . detectChanges ( ) ;
145+
146+ const editActions = fix . debugElement . queryAll ( By . css ( `igx-grid-action-button` ) ) ;
147+
148+ expect ( editActions [ 3 ] . componentInstance . iconName ) . toBe ( 'add-row' ) ;
149+ const addRowBtn = editActions [ 3 ] . componentInstance ;
150+ addRowBtn . actionClick . emit ( ) ;
151+ fix . detectChanges ( ) ;
152+ endTransition ( ) ;
153+
154+ let addRow = treeGrid . gridAPI . get_row_by_index ( 2 ) ;
155+ expect ( addRow . addRowUI ) . toBeTrue ( ) ;
156+ expect ( addRow . inEditMode ) . toBeTrue ( ) ;
157+
158+ treeGrid . gridAPI . crudService . endEdit ( true ) ;
159+ fix . detectChanges ( ) ;
160+ } ) ;
161+
162+ it ( 'should add row on correct position and enter edit mode from pinned row - pinning position: Bottom' , ( ) => {
163+ fix = TestBed . createComponent ( IgxTreeGridEditActionsPinningComponent ) ;
164+ fix . detectChanges ( ) ;
165+ treeGrid = fix . componentInstance . treeGrid ;
166+ actionStrip = fix . componentInstance . actionStrip ;
167+
168+ treeGrid . pinning = fix . componentInstance . pinningConfig ;
169+ fix . detectChanges ( ) ;
170+
171+ treeGrid . pinRow ( 1 ) ;
172+ treeGrid . pinRow ( 6 ) ;
173+
174+ expect ( treeGrid . getRowByKey ( 1 ) . pinned ) . toBeTrue ( ) ;
175+ expect ( treeGrid . getRowByKey ( 6 ) . pinned ) . toBeTrue ( ) ;
176+
177+ actionStrip . show ( treeGrid . rowList . last ) ;
178+ fix . detectChanges ( ) ;
179+
180+ const editActions = fix . debugElement . queryAll ( By . css ( `igx-grid-action-button` ) ) ;
181+
182+ expect ( editActions [ 3 ] . componentInstance . iconName ) . toBe ( 'add-row' ) ;
183+ const addRowBtn = editActions [ 3 ] . componentInstance ;
184+ addRowBtn . actionClick . emit ( ) ;
185+ fix . detectChanges ( ) ;
186+ endTransition ( ) ;
187+
188+ let addRow = treeGrid . gridAPI . get_row_by_index ( 10 ) ;
189+ expect ( addRow . addRowUI ) . toBeTrue ( ) ;
190+ expect ( addRow . inEditMode ) . toBeTrue ( ) ;
191+
192+ treeGrid . gridAPI . crudService . endEdit ( true ) ;
193+ fix . detectChanges ( ) ;
194+ } ) ;
129195 } ) ;
130196} ) ;
0 commit comments