Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Last active February 24, 2020 10:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliverJAsh/b7a478d4f4179537711c05e0541c4086 to your computer and use it in GitHub Desktop.
Save OliverJAsh/b7a478d4f4179537711c05e0541c4086 to your computer and use it in GitHub Desktop.
import { marbles } from 'rxjs-marbles/jest';
import { delayUntil } from '../operators';
describe('delayUntil', () => {
it(
'if notifier emits nothing and then completes after source emits, emits when notifier completes',
marbles(m => {
const source$ = m.cold(' --a--(b|)');
const notifier$ = m.cold('----------|');
const expected = ' ----------(ab|)';
const actual$ = source$.pipe(delayUntil(notifier$));
m.expect(actual$).toBeObservable(expected);
}),
);
it(
'if notifier emits after source emits, emits when notifier emits',
marbles(m => {
const source$ = m.cold(' --a--(b|)');
const notifier$ = m.cold('----------a');
const expected = ' ----------(ab|)';
const actual$ = source$.pipe(delayUntil(notifier$));
m.expect(actual$).toBeObservable(expected);
}),
);
it(
'if notifier completes before source emits, emits when source emits',
marbles(m => {
const source$ = m.cold(' -------a--(b|)');
const notifier$ = m.cold('--|');
const expected = ' -------a--(b|)';
const actual$ = source$.pipe(delayUntil(notifier$));
m.expect(actual$).toBeObservable(expected);
}),
);
it(
'if notifier emits before source emits, emits when source emits',
marbles(m => {
const source$ = m.cold(' -------a--(b|)');
const notifier$ = m.cold('--a');
const expected = ' -------a--(b|)';
const actual$ = source$.pipe(delayUntil(notifier$));
m.expect(actual$).toBeObservable(expected);
}),
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment