/
forkjoin-spec.ts
128 lines (100 loc) · 3.62 KB
/
forkjoin-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
import { empty, forkJoin, of } from 'ix/asynciterable';
import { sequenceEqual } from 'ix/iterable';
test('AsyncIterable#forkJoin no selector all equal', async () => {
const xs = of(42, 25, 39);
const ys = of(25, 39, 42);
const zs = of(39, 42, 25);
const res = await forkJoin(xs, ys, zs);
expect(sequenceEqual(res as number[], [39, 42, 25])).toBeTruthy();
});
test('AsyncIterable#forkJoin no 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(xs, ys, zs);
expect(sequenceEqual(res as number[], [25, 42, 25])).toBeTruthy();
});
test('AsyncIterable#forkJoin no 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(xs, ys, zs);
expect(sequenceEqual(res as number[], [39, 39, 25])).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#forkJoin no selector first empty', async () => {
const xs = empty<number>();
const ys = of(25, 39, 42);
const zs = of(39, 42, 25);
const res = await forkJoin(xs, ys, zs);
expect(res).toBe(undefined);
});
test('AsyncIterable#forkJoin no selector middle empty', async () => {
const xs = of(42, 25, 39);
const ys = empty<number>();
const zs = of(39, 42, 25);
const res = await forkJoin(xs, ys, zs);
expect(res).toBe(undefined);
});
test('AsyncIterable#forkJoin no selector last empty', async () => {
const xs = of(42, 25, 39);
const ys = of(25, 39, 42);
const zs = empty<number>();
const res = await forkJoin(xs, ys, zs);
expect(res).toBe(undefined);
});
test('AsyncIterable#forkJoin with selector all equal', async () => {
const xs = of(42, 25, 39);
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(106);
});
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#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);
});
test('AsyncIterable#forkJoin with 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(([x, y, z]) => x + y + z, xs, ys, zs);
expect(res).toBe(123);
});
test('AsyncIterable#forkJoin with selector first empty', async () => {
const xs = empty<number>();
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(undefined);
});
test('AsyncIterable#forkJoin with selector middle empty', async () => {
const xs = of(42, 25, 39);
const ys = empty<number>();
const zs = of(39, 42, 25);
const res = await forkJoin(([x, y, z]) => x + y + z, xs, ys, zs);
expect(res).toBe(undefined);
});
test('AsyncIterable#forkJoin with selector last empty', async () => {
const xs = of(42, 25, 39);
const ys = of(25, 39, 42);
const zs = empty<number>();
const res = await forkJoin(([x, y, z]) => x + y + z, xs, ys, zs);
expect(res).toBe(undefined);
});