forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
34 lines (29 loc) · 899 Bytes
/
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
var rxjs = require('rxjs');
var rxjs1 = require('rxjs1');
var mergeMap = require('rxjs/operators').mergeMap;
var mergeMap1 = require('rxjs1/operators').mergeMap;
var of = rxjs.of;
var of1 = rxjs1.of;
var from1 = rxjs1.from;
var actual = [];
var expected = [1];
var id = setTimeout(function () {
throw new Error('TIMEOUT: Observable did not complete');
}, 200);
of1(0).pipe(
mergeMap1(function (x) { return of(x); }),
mergeMap(function () { return from1(Promise.resolve(1)); })
).subscribe({
next: function (value) { actual.push(value); },
error: function () {
throw new Error('should not error');
},
complete: function () {
if (actual.length !== expected.length || actual[0] !== expected[0] || actual[1] !== expected[1]) {
throw new Error(actual + ' does not equal ' + expected);
} else {
clearTimeout(id);
console.log('TEST PASSED');
}
},
});