Skip to content

Commit a503659

Browse files
MKirovaMKirova
authored andcommitted
chore(*): Add test for date column.
1 parent a892a57 commit a503659

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

projects/igniteui-angular/src/lib/grids/grid/cell-merge.spec.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,28 @@ describe('IgxGrid - Cell merging #grid', () => {
138138
{ value: 'Ignite UI for JavaScript', span: 9 }
139139
]);
140140
});
141+
142+
it('should merge date column correctly.', () => {
143+
const col = grid.getColumnByName('ReleaseDate');
144+
145+
grid.sort({ fieldName: 'ReleaseDate', dir: SortingDirection.Desc, ignoreCase: false });
146+
fix.detectChanges();
147+
148+
// merge date column
149+
col.merge = true;
150+
fix.detectChanges();
151+
152+
const today: Date = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate(), 0, 0, 0);
153+
const nextDay = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() + 1, 0, 0, 0);
154+
const prevDay = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate() - 1, 0, 0, 0);
155+
156+
GridFunctions.verifyColumnMergedState(grid, col, [
157+
{ value: nextDay, span: 2 },
158+
{ value: today, span: 2 },
159+
{ value: prevDay, span: 3 },
160+
{ value: null, span: 2 }
161+
]);
162+
});
141163
});
142164

143165
describe('UI', () => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ export class GridFunctions {
112112
const cellValue = row.cells.toArray().find(x => x.column === col).value;
113113
const rowSpan = row.metaData?.cellMergeMeta.get(col.field)?.rowSpan || 1;
114114
const currState = state[index - totalSpan];
115-
expect(cellValue).toBe(currState.value);
116-
expect(rowSpan).toBe(currState.span);
115+
expect(cellValue).toEqual(currState.value);
116+
expect(rowSpan).toEqual(currState.span);
117117
totalSpan += (rowSpan - 1);
118118
index += (rowSpan - 1);
119119
}

0 commit comments

Comments
 (0)