Skip to content

Commit

Permalink
Add tests related to internal state
Browse files Browse the repository at this point in the history
  • Loading branch information
vially committed May 9, 2020
1 parent e468e16 commit 296637b
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions spec/retryBackoff-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -350,4 +350,53 @@ describe('retryBackoff operator', () => {
expectSubscriptions(source.subscriptions).toBe(subs);
});
});

it('should be referentially transparent', () => {
testScheduler.run(({ expectObservable, cold, expectSubscriptions }) => {
const source1 = cold('--#');
const source2 = cold('--#');
const unsub = ' ---------!';
const subs = [
' ^-! ',
' ---^-! ',
' -------^-!',
];
const expected = ' ----------';

const op = retryBackoff({
initialInterval: 1,
});

expectObservable(source1.pipe(op), unsub).toBe(expected);
expectSubscriptions(source1.subscriptions).toBe(subs);

expectObservable(source2.pipe(op), unsub).toBe(expected);
expectSubscriptions(source2.subscriptions).toBe(subs);
});
});

it('should ensure interval state is per-subscription', () => {
testScheduler.run(({ expectObservable, cold, expectSubscriptions }) => {
const source = cold('--#');
const sub1 = ' ^--------!';
const sub2 = ' ----------^--------!';
const subs = [
' ^-! ',
' ---^-! ',
' -------^-!',
' ----------^-! ',
' -------------^-! ',
' -----------------^-!',
];
const expected = ' ----------';

const result = source.pipe(retryBackoff({
initialInterval: 1,
}));

expectObservable(result, sub1).toBe(expected);
expectObservable(result, sub2).toBe(expected);
expectSubscriptions(source.subscriptions).toBe(subs);
});
});
});

0 comments on commit 296637b

Please sign in to comment.