import { of } from 'rxjs'; import { distinct, tap, toArray } from 'rxjs/operators'; describe('rx.distinct', () => { interface TestObject { key1: string; key2: string; } it('should allow chaining', () => { const t1: TestObject = { key1: 'a1', key2: 'b1' }; const t2: TestObject = { key1: 'a2', key2: 'b1' }; const t3: TestObject = { key1: 'a3', key2: 'b2' }; const t4: TestObject = { key1: 'a2', key2: 'b3' }; return of(t1, t2, t3, t4).pipe( distinct(o => o.key1), distinct(o => o.key2), toArray(), tap(a => { expect(a.length).toEqual(2); })).toPromise(); }); });