How to use the rxjs-marbles/mocha.observe 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 / ts-action / packages / ts-action-operators / source / toPayload-spec.ts View on Github external
describe("toPayload", () => {
  const { foo } = usingPayload;

  it(
    "should obtain the payload",
    observe(() => {
      return of(foo({ foo: 42 })).pipe(
        ofType(foo),
        toPayload(),
        toArray(),
        tap(array => expect(array).to.deep.equal([{ foo: 42 }]))
      );
    })
  );
});
github cartant / ts-action / packages / ts-action-operators / source / ofType-spec.ts View on Github external
it(
      "should filter actions matching a single type",
      observe(() => {
        return of(foo({ foo: 42 }), bar({ bar: 54 })).pipe(
          ofType(foo),
          tap(action => expect(isType(action, foo)).to.be.true),
          map(action => action.payload.foo),
          toArray(),
          tap(array => expect(array).to.deep.equal([42]))
        );
      })
    );

    it(
      "should filter actions matching multiple types",
      observe(() => {
        return of(foo({ foo: 42 }), bar({ bar: 54 })).pipe(
          ofType(foo, bar),
          tap(action => expect(isType(action, foo, bar)).to.be.true),
          map(action =>
            action.type === foo.type ? action.payload.foo : action.payload.bar
          ),
          toArray(),
          tap(array => expect(array).to.deep.equal([42, 54]))
        );
      })
    );

    it(
      "should filter actions not matching a type",
      observe(() => {
        return of(foo({ foo: 42 })).pipe(
github cartant / rxjs-marbles / examples / mocha / observe-spec.ts View on Github external
describe("observe", () => {
  it(
    "should support tests that return an observable",
    observe(() => {
      return of(1).pipe(
        map(value => value.toString()),
        tap(value => expect(value).to.be.a("string"))
      );
    })
  );

  it(
    "should handle assertions in finalize operator",
    observe(() => {
      let haveBeenCalled = false;
      const mock = () => (haveBeenCalled = true);
      return of(1).pipe(
        tap(() => mock()),
        finalize(() => assert.isOk(haveBeenCalled))
      );