Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('AsyncIterable#zip equal length no selector', async () => {
const xs = of(1, 2, 3);
const ys = of(4, 5, 6);
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();
test('AsyncIterable#zip equal length with selector', async () => {
const xs = of(1, 2, 3);
const ys = of(4, 5, 6);
const zs = of(7, 8, 9);
const res = combineLatest(([x, y, z]) => x + y + z, xs, ys, zs);
const it = res[Symbol.asyncIterator]();
await hasNext(it, 16);
await hasNext(it, 17);
await hasNext(it, 18);
await noNext(it);
});
test('AsyncIterable#zip equal length with selector', async () => {
const xs = of(1, 2, 3);
const ys = of(4, 5, 6);
const zs = of(7, 8, 9);
const res = combineLatest(([x, y, z]) => x + y + z, xs, ys, zs);
const it = res[Symbol.asyncIterator]();
await hasNext(it, 16);
await hasNext(it, 17);
await hasNext(it, 18);
await noNext(it);
});
test('AsyncIterable#zip equal length no selector', async () => {
const xs = of(1, 2, 3);
const ys = of(4, 5, 6);
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();
test('AsyncIterable#merge mergeAll behavior', async () => {
const res = of(of(1, 2, 3), of(4, 5)).pipe(mergeAll());
expect(await sequenceEqual(res, of(1, 2, 3, 4, 5))).toBeTruthy();
});
test('AsyncIterable#forkJoin with selector first smaller', async () => {
const xs = of(42, 25);
const ys = of(25, 39, 42);
const zs = of(39, 42, 25);
const res = await forkJoin(([x, y, z]) => x + y + z, xs, ys, zs);
expect(res).toBe(92);
});
test('AsyncIterable#concat concatAll order of effects', async () => {
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(
await sequenceEqual(res, of('1 - 0', '2 - 0', '2 - 1', '3 - 0', '3 - 1', '3 - 2'))
).toBeTruthy();
});
test(`#pipe type inference is correct with two operators`, () => {
const source = of(0, 1, 2).pipe(
map(x => x + 1),
map(x => x + 1)
);
expect(source).toEqualStream([2, 3, 4]);
});
test('AsyncIterable#forkJoin with selector middle smaller', async () => {
const xs = of(42, 25, 39);
const ys = of(25, 39);
const zs = of(39, 42, 25);
const res = await forkJoin(([x, y, z]) => x + y + z, xs, ys, zs);
expect(res).toBe(103);
});