Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const zs = of(7, 8, 9);
const res = combineLatest(xs, ys, zs);
const it = res[Symbol.asyncIterator]();
let next = await it.next();
expect(next.done).toBeFalsy();
expect(sequenceEqual(next.value, [3, 6, 7])).toBeTruthy();
next = await it.next();
expect(next.done).toBeFalsy();
expect(sequenceEqual(next.value, [3, 6, 8])).toBeTruthy();
next = await it.next();
expect(next.done).toBeFalsy();
expect(sequenceEqual(next.value, [3, 6, 9])).toBeTruthy();
next = await it.next();
expect(next.done).toBeTruthy();
});
test('Iterable#concat concatAll order of effects', () => {
let i = 0;
const xss = range(0, 3).pipe(
map(x => range(0, x + 1)),
tap({ next: async () => ++i })
);
const res = xss.pipe(
concatAll(),
map(x => i + ' - ' + x)
);
expect(sequenceEqual(res, of('1 - 0', '2 - 0', '2 - 1', '3 - 0', '3 - 1', '3 - 2'))).toBeTruthy();
});
test('Iterable#concat behavior', () => {
const res = concat([1, 2, 3], [4, 5]);
expect(sequenceEqual(res, of(1, 2, 3, 4, 5))).toBeTruthy();
});
test('AsyncIterable#forkJoin no selector last smaller', async () => {
const xs = of(42, 25, 39);
const ys = of(25, 39, 42);
const zs = of(39, 42);
const res = await forkJoin(xs, ys, zs);
expect(sequenceEqual(res as number[], [39, 42, 42])).toBeTruthy();
});
test('AsyncIterable#asyncify multiple arguments', async () => {
const callbackFn = (a: number, b: number, cb: Function) => {
cb(a, b);
};
const asyncFn = asyncify(callbackFn);
const xs = asyncFn(1, 2);
const it = xs[Symbol.asyncIterator]();
const { value, done } = await it.next();
expect(sequenceEqual(value as number[], [1, 2])).toBeTruthy();
expect(done).toBeFalsy();
await noNext(it);
});
test('Iterable#catchError source and handler types are composed', () => {
const xs = range(0, 10);
const res = xs.pipe(catchError((_: Error) => of('foo')));
expect(sequenceEqual(res, xs)).toBeTruthy();
});
test('Iterable#catchWith no error misses', () => {
const xs = range(0, 10);
const res = xs.pipe(catchError(_ => of(42)));
expect(sequenceEqual(res, xs)).toBeTruthy();
});