Skip to content

Commit

Permalink
add a test for combining 4 selectors
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-okrushko committed May 28, 2020
1 parent a888a9d commit e980ab5
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions modules/component-store/spec/component-store.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,37 @@ describe('Component Store', () => {
})
);

it(
'would emit a single value even when all 4 selectors produce values',
marbles(m => {
const s1$ = componentStore.select(s => `fromS1(${s.value})`);
const s2$ = componentStore.select(s => `fromS2(${s.value})`);
const s3$ = componentStore.select(s => `fromS3(${s.value})`);
const s4$ = componentStore.select(s => `fromS4(${s.value})`);

const selector$ = componentStore.select(
s1$,
s2$,
s3$,
s4$,
(s1, s2, s3, s4) => `${s1} & ${s2} & ${s3} & ${s4}`
);

const updater$ = m.cold(' -----e-|');
const expectedSelector$ = m.hot('i----c--', {
// initial👆 👆 combined single value
i: 'fromS1(init) & fromS2(init) & fromS3(init) & fromS4(init)',
c: 'fromS1(e) & fromS2(e) & fromS3(e) & fromS4(e)',
});

componentStore.updater((_, newValue: string) => ({
value: newValue,
}))(updater$);

m.expect(selector$).toBeObservable(expectedSelector$);
})
);

it(
'can combine with Observables that complete',
marbles(m => {
Expand Down

0 comments on commit e980ab5

Please sign in to comment.