Skip to content

Commit

Permalink
test(IgxTreeGrid): Adding empty ChildDataKey test. #2921
Browse files Browse the repository at this point in the history
  • Loading branch information
IvayloG authored and wnvko committed Dec 5, 2018
1 parent 2beff83 commit 0bd0eed
Showing 1 changed file with 52 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -804,12 +804,10 @@ fdescribe('IgxTreeGrid - Integration', () => {
const childRow = { ID: 12, ParentID: 11, Name: 'Tervel Pulev', JobTitle: 'wrestler', Age: 30 };
const grandChildRow = { ID: 13, ParentID: 12, Name: 'Asparuh Pulev', JobTitle: 'wrestler', Age: 14 };
const trans = treeGrid.transactions;
spyOn(trans, 'add').and.callThrough();

treeGrid.addRow(rootRow, 0);
fix.detectChanges();

const parentRow = treeGrid.getRowByIndex(10) as IgxTreeGridRowComponent;
treeGrid.addRow(childRow, 11);
fix.detectChanges();

Expand All @@ -829,16 +827,58 @@ fdescribe('IgxTreeGrid - Integration', () => {
expect(treeGrid.getRowByKey(13).nativeElement.classList).toContain('igx-grid__tr--edited');
});

it('Add a child node to a previously added parent node - Hierarchical DS', () => {
// TODO:
// 1. Add a row at level 0 to the grid
// 2. Add a child row to that parent
// 3. Verify the new rows are pending with the correct styles
// 4. Commit
// 5. verify the rows are committed, the styles are OK
// 6. Add another child row at level 2 (grand-child of the first row)
// 7. verify the pending styles is applied only to the newly added row
// and not to the previously added rows
it('Add a child node to a previously added parent node - Hierarchical DS - empty ChildDataKey -commit', () => {
fix = TestBed.createComponent(IgxTreeGridRowEditingHierarchicalDSTransactionComponent);
fix.detectChanges();
treeGrid = fix.componentInstance.treeGrid as IgxTreeGridComponent;
const trans = treeGrid.transactions;
const rootRow = {
ID: 11,
Name: 'Kubrat Pulev',
HireDate: new Date(2018, 10, 20),
Age: 32,
OnPTO: false,
Employees: []
};

const childRow = {
ID: 12,
Name: 'Tervel Pulev',
HireDate: new Date(2018, 10, 10),
Age: 30,
OnPTO: true,
Employees: []
};

const grandChildRow = {
ID: 13,
Name: 'Asparuh Pulev',
HireDate: new Date(2017, 10, 10),
Age: 14,
OnPTO: true,
Employees: []
};

treeGrid.addRow(rootRow);
treeGrid.addRow(childRow, 11);

expect(treeGrid.getRowByKey(11).nativeElement.classList).toContain('igx-grid__tr--edited');
expect(treeGrid.getRowByKey(12).nativeElement.classList).toContain('igx-grid__tr--edited');

trans.commit(treeGrid.data);

expect(treeGrid.getRowByKey(11).nativeElement.classList).not.toContain('igx-grid__tr--edited');
expect(treeGrid.getRowByKey(12).nativeElement.classList).not.toContain('igx-grid__tr--edited');

treeGrid.addRow(grandChildRow, 12);

expect(treeGrid.getRowByKey(11).nativeElement.classList).not.toContain('igx-grid__tr--edited');
expect(treeGrid.getRowByKey(12).nativeElement.classList).not.toContain('igx-grid__tr--edited');
expect(treeGrid.getRowByKey(13).nativeElement.classList).toContain('igx-grid__tr--edited');
expect(treeGrid.records.get(11).level).toBe(0);
expect(treeGrid.records.get(12).level).toBe(1);
expect(treeGrid.records.get(13).level).toBe(2);

});

it('Delete a pending parent node - Flat DS', () => {
Expand Down

0 comments on commit 0bd0eed

Please sign in to comment.