-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
36 lines (29 loc) · 1.11 KB
/
test.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
import {streamFromFutureForDriver, makeFutureHTTPDriver, HttpSource} from './index'
import ava from 'ava';
import {isFuture, Future} from 'fluture';
import {Stream} from 'xstream';
ava('streamFromFutureForDriver', t => {
const f = Future.of(null);
const stream = streamFromFutureForDriver({future: f, category: 'test'});
t.true(isFuture(f), 'f is a future');
t.true(stream instanceof Stream, 'we have a stream from a future');
t.pass();
});
ava.cb('makeHTTPDriver', t => {
t.plan(4);
const future = Future.of(null);
const category = 'nulls';
const null$ = Stream.of({future, category});
const driver = makeFutureHTTPDriver();
const source = driver(null$);
const null$from$$ = source.select(category).flatten();
t.true(typeof driver == 'function', 'driver is a function');
t.true(source instanceof HttpSource, 'driver is a function that produces HTTP sources, given a stream');
t.true(null$from$$ instanceof Stream, 'can get subbed stream from stream of streams in HTTP source');
null$from$$.subscribe({
next: v => {
t.is(v, null, 'got expected value; null');
t.end();
}
});
});