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