feat(ivy): observable QueryList (#21859)

PR Close #21859
This commit is contained in:
Pawel Kozlowski
2018-01-29 16:06:31 +01:00
committed by Jason Aden
parent b10540a0b5
commit 285dd6be34
2 changed files with 38 additions and 3 deletions

View File

@ -826,4 +826,34 @@ describe('query', () => {
});
});
describe('observable interface', () => {
it('should allow observing changes to query list', () => {
const queryList = new QueryList();
let changes = 0;
queryList.changes.subscribe({
next: (arg) => {
changes += 1;
expect(arg).toBe(queryList);
}
});
// initial refresh, the query should be dirty
qR(queryList);
expect(changes).toBe(1);
// refresh without setting dirty - no emit
qR(queryList);
expect(changes).toBe(1);
// refresh with setting dirty - emit
queryList.setDirty();
qR(queryList);
expect(changes).toBe(2);
});
});
});