Skip to content

Commit b801088

Browse files
committed
test(state): add test for restoring state witn null date values
1 parent f5530c7 commit b801088

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

projects/igniteui-angular/src/lib/grids/state.directive.spec.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,27 @@ describe('IgxGridState - input properties #grid', () => {
178178
expect(gridState).toBe(filteringState);
179179
});
180180

181+
it('setState should correctly restore grid filtering state from with null date values', () => {
182+
const fix = TestBed.createComponent(IgxGridStateComponent);
183+
fix.detectChanges();
184+
const grid = fix.componentInstance.grid;
185+
grid.getCellByColumn(0, "OrderDate").value = null;
186+
fix.detectChanges();
187+
const state = fix.componentInstance.state;
188+
189+
const filteringState = '{"filtering":{"filteringOperands":[{"filteringOperands":[{"condition":{"name":"empty","isUnary":true,"iconName":"is-empty"},"fieldName":"OrderDate","ignoreCase":true,"searchVal":null}],"operator":1,"fieldName":"OrderDate"}],"operator":0,"type":0}}';
190+
const initialState = '{"filtering":{"filteringOperands":[],"operator":0}}';
191+
192+
let gridState = state.getState(true, 'filtering');
193+
expect(gridState).toBe(initialState);
194+
195+
state.setState(filteringState);
196+
gridState = state.getState(false, 'filtering') as IGridState;
197+
HelperFunctions.verifyFilteringExpressions(grid.filteringExpressionsTree, gridState);
198+
gridState = state.getState(true, 'filtering');
199+
expect(gridState).toBe(filteringState);
200+
});
201+
181202
it('setState should correctly restore grid filtering state from object', () => {
182203
const fix = TestBed.createComponent(IgxGridStateComponent);
183204
fix.detectChanges();

0 commit comments

Comments
 (0)