forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-helper.ts
48 lines (41 loc) · 1.17 KB
/
test-helper.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
declare const global: any;
declare const Symbol: any;
import * as Rx from '../../dist/cjs/Rx';
import {ObservableInput} from '../../dist/cjs/Observable';
import {root} from '../../dist/cjs/util/root';
import {$$iterator} from '../../dist/cjs/symbol/iterator';
import $$symbolObservable from 'symbol-observable';
export function lowerCaseO<T>(...args): Rx.Observable<T> {
const values = [].slice.apply(arguments);
const o = {
subscribe: function (observer) {
values.forEach(function (v) {
observer.next(v);
});
observer.complete();
}
};
o[Symbol.observable] = function () {
return this;
};
return <any>o;
};
export const createObservableInputs = <T>(value: T) => Rx.Observable.of<ObservableInput<T>>(
Rx.Observable.of<T>(value),
Rx.Observable.of<T>(value, Rx.Scheduler.async),
[value],
Promise.resolve(value),
<any>({ [$$iterator]: () => {
const iteratorResults = [
{value, done: false},
{done: true}
];
return {
next: () => {
return iteratorResults.shift();
}
};
}}),
<any>({ [$$symbolObservable]: () => Rx.Observable.of(value) })
);
global.__root__ = root;