Skip to content

Commit 0a31d3f

Browse files
committed
chore(*): add test for empty row edit template and navigation
1 parent 9ac2511 commit 0a31d3f

File tree

2 files changed

+56
-3
lines changed

2 files changed

+56
-3
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid-row-editing.spec.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ import {
2323
IgxGridWithEditingAndFeaturesComponent,
2424
IgxGridRowEditingWithoutEditableColumnsComponent,
2525
IgxGridCustomOverlayComponent,
26-
IgxGridRowEditingWithFeaturesComponent
26+
IgxGridRowEditingWithFeaturesComponent,
27+
IgxGridEmptyRowEditTemplateComponent
2728
} from '../../test-utils/grid-samples.spec';
2829
import { IgxGridTestComponent } from './grid.component.spec';
2930

@@ -45,7 +46,8 @@ describe('IgxGrid - Row Editing #grid', () => {
4546
IgxGridRowEditingWithoutEditableColumnsComponent,
4647
IgxGridTestComponent,
4748
IgxGridCustomOverlayComponent,
48-
IgxGridRowEditingWithFeaturesComponent
49+
IgxGridRowEditingWithFeaturesComponent,
50+
IgxGridEmptyRowEditTemplateComponent
4951
],
5052
imports: [
5153
NoopAnimationsModule, IgxGridModule]
@@ -1912,7 +1914,7 @@ describe('IgxGrid - Row Editing #grid', () => {
19121914

19131915
expect(parseInt(GridFunctions.getRowEditingBannerText(fix), 10)).toEqual(0);
19141916
fix.componentInstance.cellInEditMode.editValue = 'Spiro';
1915-
fix.componentInstance.moveNext(true);
1917+
UIInteractions.triggerKeyDownWithBlur('tab', cell.nativeElement, true);
19161918
tick(16);
19171919
fix.detectChanges();
19181920

@@ -1923,6 +1925,41 @@ describe('IgxGrid - Row Editing #grid', () => {
19231925
expect(grid.endEdit).toHaveBeenCalled();
19241926
expect(grid.endEdit).toHaveBeenCalledTimes(1);
19251927
}));
1928+
1929+
it('Empty template', fakeAsync(() => {
1930+
const fix = TestBed.createComponent(IgxGridEmptyRowEditTemplateComponent);
1931+
fix.detectChanges();
1932+
tick(16);
1933+
1934+
const grid = fix.componentInstance.grid;
1935+
let cell = grid.getCellByColumn(0, 'ProductName');
1936+
UIInteractions.triggerKeyDownEvtUponElem('f2', cell.nativeElement, true);
1937+
1938+
fix.detectChanges();
1939+
tick(16);
1940+
1941+
cell.editValue = 'Spiro';
1942+
UIInteractions.triggerKeyDownEvtUponElem('tab', cell.nativeElement, true);
1943+
1944+
fix.detectChanges();
1945+
tick(16);
1946+
fix.detectChanges();
1947+
tick(16);
1948+
1949+
expect(cell.editMode).toBe(false);
1950+
cell = grid.getCellByColumn(0, 'ReorderLevel');
1951+
expect(cell.editMode).toBe(true);
1952+
1953+
UIInteractions.triggerKeyDownEvtUponElem('tab', cell.nativeElement, true, false, true);
1954+
fix.detectChanges();
1955+
tick(16);
1956+
fix.detectChanges();
1957+
tick(16);
1958+
1959+
expect(cell.editMode).toBe(false);
1960+
cell = grid.getCellByColumn(0, 'ProductName');
1961+
expect(cell.editMode).toBe(true);
1962+
}));
19261963
});
19271964

19281965
describe('Transaction', () => {

projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,22 @@ export class IgxGridCustomOverlayComponent extends BasicGridComponent {
14191419
}
14201420
}
14211421

1422+
@Component({
1423+
template: `
1424+
<igx-grid #grid [data]="data" [primaryKey]="'ProductID'" width="700px" height="400px" [rowEditable]="true">
1425+
<igx-column field="ProductID" header="Product ID"></igx-column>
1426+
<igx-column field="ReorderLevel" header="Reorder Lever" [dataType]="'number'" [editable]="true" width="100px"></igx-column>
1427+
<igx-column field="ProductName" header="Product Name" [dataType]="'string'" width="150px"></igx-column>
1428+
<igx-column field="OrderDate" header="Order Date" [dataType]="'date'" width="150px" [editable]="false"></igx-column>
1429+
<ng-template igxRowEdit >
1430+
</ng-template>
1431+
</igx-grid>
1432+
`
1433+
})
1434+
export class IgxGridEmptyRowEditTemplateComponent extends BasicGridComponent {
1435+
public data = SampleTestData.foodProductData();
1436+
}
1437+
14221438
@Component({
14231439
template: `
14241440
<igx-grid #grid [data]="data" [primaryKey]="'ProductID'" width="900px" height="900px" [rowEditable]="true"

0 commit comments

Comments
 (0)