How to use the rxjs-marbles/jest.marbles 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 twlevelup / watch_edition / framework / src / rxjs / watchOperators.spec.js View on Github external
describe('watchOperators', () => {
  it('getRxjsTarget', marbles((m) => {
    const leftTarget = { dataset: { rxjsTarget: 'left' } };
    const rxjsTargetWithClosest = { ...leftTarget, closest: () => leftTarget };
    const nonRxjsTargetWithClosest = { closest: () => leftTarget };

    const inputs = {
      a: { target: rxjsTargetWithClosest },
      b: { target: nonRxjsTargetWithClosest },
    };

    const source = m.hot('a--b', inputs);

    const piped = source.pipe(watchOperators.getRxjsTarget());

    m.expect(piped).toBeObservable('x--x', { x: 'left' });
  }))
github cartant / rxjs-marbles / examples / jest / basic-spec.ts View on Github external
marbles(m => {
      const source = m.hot("  --^-a-b-c-|");
      const subs = "            ^-------!";
      const expected = m.cold(" --b-c-d-|");

      const destination = source.pipe(
        map(value => String.fromCharCode(value.charCodeAt(0) + 1))
      );
      m.expect(destination).toBeObservable(expected);
      m.expect(source).toHaveSubscriptions(subs);
    })
  );

  it(
    "should support marble tests with values",
    marbles(m => {
      const inputs = {
        a: 1,
        b: 2,
        c: 3
      };
      const outputs = {
        x: 2,
        y: 3,
        z: 4
      };

      const source = m.hot("  --^-a-b-c-|", inputs);
      const subs = "            ^-------!";
      const expected = m.cold(" --x-y-z-|", outputs);

      const destination = source.pipe(map(value => value + 1));
github twlevelup / watch_edition / framework / spec / App.spec.js View on Github external
beforeEach(() => {
          jest.spyOn(Date, 'now')
            .mockReturnValueOnce(42)
            .mockReturnValueOnce(142)
        })

        it('should merge mouseDown and keyDown', marbles((m) => {
          app.watchMouseDown$ = m.hot('a', { a: 'left' })
          app.watchKeyDown$ = m.hot('---a', { a: 'left' })
          app.mergeEvents();
          m.expect(app.watchDown$).toBeObservable('x--y', { x: { target: 'left', timestamp: 42 }, y: { target: 'left', timestamp: 142 } });
        }))


        it('should merge mouseUp and keyUp', marbles((m) => {
          app.watchMouseUp$ = m.hot('a', { a: 'left' })
          app.watchKeyUp$ = m.hot('---a', { a: 'left' })
          app.mergeEvents();
          m.expect(app.watchUp$).toBeObservable('x--y', { x: { target: 'left', timestamp: 42 }, y: { target: 'left', timestamp: 142 } });
        }))

      })