forked from ReactiveX/IxJS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuffercountortime-spec.ts
More file actions
30 lines (21 loc) · 925 Bytes
/
buffercountortime-spec.ts
File metadata and controls
30 lines (21 loc) · 925 Bytes
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
import '../asynciterablehelpers.js';
import { of, concat, toArray, interval } from 'ix/asynciterable/index.js';
import { bufferCountOrTime, delay, take } from 'ix/asynciterable/operators/index.js';
test('buffer count behaviour', async () => {
const source = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
const res = source.pipe(bufferCountOrTime(5, 10));
expect(await toArray(res)).toEqual([
[1, 2, 3, 4, 5],
[6, 7, 8, 9, 0],
]);
});
test('buffer time behaviour', async () => {
const source = concat(of(1, 2, 3, 4, 5), of(6, 7, 8, 9), of(0).pipe(delay(11)));
const res = source.pipe(bufferCountOrTime(5, 10));
expect(await toArray(res)).toEqual([[1, 2, 3, 4, 5], [6, 7, 8, 9], [0]]);
});
test('continues the timer in the background', async () => {
const source = interval(10);
const res = source.pipe(bufferCountOrTime(3, 45));
expect(await toArray(res.pipe(take(2)))).toEqual([[0, 1, 2], [3]]);
});