Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 }]))
);
})
);
});
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(
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))
);