22import { TestBed , fakeAsync , waitForAsync } 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' ;
@@ -24,7 +24,8 @@ describe('IgxTreeGrid - Add Row UI #tGrid', () => {
2424 beforeAll ( waitForAsync ( ( ) => {
2525 TestBed . configureTestingModule ( {
2626 declarations : [
27- IgxTreeGridEditActionsComponent
27+ IgxTreeGridEditActionsComponent ,
28+ IgxTreeGridEditActionsPinningComponent
2829 ] ,
2930 imports : [ IgxTreeGridModule , NoopAnimationsModule , IgxActionStripModule ]
3031 } )
@@ -128,5 +129,70 @@ describe('IgxTreeGrid - Add Row UI #tGrid', () => {
128129
129130 expect ( treeGrid . rowList . length ) . toBe ( 1 ) ;
130131 } ) ;
132+
133+ it ( 'should add row on correct position and enter edit mode from pinned row - pinning position: Top' , ( ) => {
134+ fix = TestBed . createComponent ( IgxTreeGridEditActionsPinningComponent ) ;
135+ fix . detectChanges ( ) ;
136+ treeGrid = fix . componentInstance . treeGrid ;
137+ actionStrip = fix . componentInstance . actionStrip ;
138+
139+ treeGrid . pinRow ( 1 ) ;
140+ treeGrid . pinRow ( 6 ) ;
141+
142+ expect ( treeGrid . getRowByKey ( 1 ) . pinned ) . toBeTrue ( ) ;
143+ expect ( treeGrid . getRowByKey ( 6 ) . pinned ) . toBeTrue ( ) ;
144+
145+ actionStrip . show ( treeGrid . rowList . toArray ( ) [ 1 ] ) ;
146+ fix . detectChanges ( ) ;
147+
148+ const editActions = fix . debugElement . queryAll ( By . css ( `igx-grid-action-button` ) ) ;
149+
150+ expect ( editActions [ 3 ] . componentInstance . iconName ) . toBe ( 'add-row' ) ;
151+ const addRowBtn = editActions [ 3 ] . componentInstance ;
152+ addRowBtn . actionClick . emit ( ) ;
153+ fix . detectChanges ( ) ;
154+ endTransition ( ) ;
155+
156+ let addRow = treeGrid . gridAPI . get_row_by_index ( 2 ) ;
157+ expect ( addRow . addRowUI ) . toBeTrue ( ) ;
158+ expect ( addRow . inEditMode ) . toBeTrue ( ) ;
159+
160+ treeGrid . gridAPI . crudService . endEdit ( true ) ;
161+ fix . detectChanges ( ) ;
162+ } ) ;
163+
164+ it ( 'should add row on correct position and enter edit mode from pinned row - pinning position: Bottom' , ( ) => {
165+ fix = TestBed . createComponent ( IgxTreeGridEditActionsPinningComponent ) ;
166+ fix . detectChanges ( ) ;
167+ treeGrid = fix . componentInstance . treeGrid ;
168+ actionStrip = fix . componentInstance . actionStrip ;
169+
170+ treeGrid . pinning = fix . componentInstance . pinningConfig ;
171+ fix . detectChanges ( ) ;
172+
173+ treeGrid . pinRow ( 1 ) ;
174+ treeGrid . pinRow ( 6 ) ;
175+
176+ expect ( treeGrid . getRowByKey ( 1 ) . pinned ) . toBeTrue ( ) ;
177+ expect ( treeGrid . getRowByKey ( 6 ) . pinned ) . toBeTrue ( ) ;
178+
179+ actionStrip . show ( treeGrid . rowList . last ) ;
180+ fix . detectChanges ( ) ;
181+
182+ const editActions = fix . debugElement . queryAll ( By . css ( `igx-grid-action-button` ) ) ;
183+
184+ expect ( editActions [ 3 ] . componentInstance . iconName ) . toBe ( 'add-row' ) ;
185+ const addRowBtn = editActions [ 3 ] . componentInstance ;
186+ addRowBtn . actionClick . emit ( ) ;
187+ fix . detectChanges ( ) ;
188+ endTransition ( ) ;
189+
190+ let addRow = treeGrid . gridAPI . get_row_by_index ( 10 ) ;
191+ expect ( addRow . addRowUI ) . toBeTrue ( ) ;
192+ expect ( addRow . inEditMode ) . toBeTrue ( ) ;
193+
194+ treeGrid . gridAPI . crudService . endEdit ( true ) ;
195+ fix . detectChanges ( ) ;
196+ } ) ;
131197 } ) ;
132198} ) ;
0 commit comments