-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
64 lines (56 loc) · 1.61 KB
/
test.js
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
const { marbles } = require("rxjs-marbles/jest");
const RxJSOperators = require("rxjs/operators");
const { bufferDebounce } = require("./bufferDebounce");
describe("bufferDebounce", () => {
it(
"works with > 0 timeout",
marbles((m) => {
const source$ = m.cold("--a--b----c-----d");
const ms = m.time(" ---|");
const expected = " --------1----2-----3";
const actual$ = source$.pipe(bufferDebounce(ms));
m.expect(actual$).toBeObservable(expected, {
1: ["a", "b"],
2: ["c"],
3: ["d"],
});
})
);
it(
"works with 0 timeout",
marbles((m) => {
const source$ = m.cold("--(ab)--c--d");
const ms = m.time(" |");
const expected = " --1-----2--3";
const actual$ = source$.pipe(bufferDebounce(ms));
m.expect(actual$).toBeObservable(expected, {
1: ["a", "b"],
2: ["c"],
3: ["d"],
});
})
);
it(
"works with `startWith`",
marbles((m) => {
const source$ = m.cold("-");
const ms = m.time(" |");
const expected = " 1";
const actual$ = source$.pipe(
RxJSOperators.startWith("a"),
bufferDebounce(ms)
);
m.expect(actual$).toBeObservable(expected, { 1: ["a"] });
})
);
it(
"works with observable that emits and completes immediately",
marbles((m) => {
const source$ = m.cold("(a|)");
const ms = m.time(" |");
const expected = " (1|)";
const actual$ = source$.pipe(bufferDebounce(ms));
m.expect(actual$).toBeObservable(expected, { 1: ["a"] });
})
);
});