How to use the rxjs-marbles/mocha.fakeSchedulers function in rxjs-marbles

To help you get started, we’ve selected a few rxjs-marbles examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cartant / rxjs-marbles / examples / mocha / fake-spec.ts View on Github external
it(
    "should support a timer",
    fakeSchedulers(() => {
      let received: number | undefined;
      timer(100).subscribe(value => (received = value));
      clock.tick(50);
      expect(received).to.be.undefined;
      clock.tick(50);
      expect(received).to.equal(0);
    })
  );

  it(
    "should support delay",
    fakeSchedulers(() => {
      let received: number | undefined;
      of(1)
        .pipe(delay(100))
        .subscribe(value => (received = value));
      clock.tick(50);
      expect(received).to.be.undefined;
      clock.tick(50);
      expect(received).to.equal(1);
    })
  );

  afterEach(() => {
    clock.restore();
  });
});