-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
48 lines (41 loc) · 916 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var {expect} = require('chai').use(require('dirty-chai'));
var MetaStream = require('./');
exports['MetaStream'] = {
'should stream' (done) {
var s = MetaStream(['hello']);
s.apply(x => {
expect(x).to.equal('hello');
done();
});
},
'should set meta' () {
var s = MetaStream();
s.meta({foo: 'bar'});
expect(s.meta().foo).to.equal('bar');
},
'should pass on meta' () {
var s = MetaStream([1]);
s.meta({foo: 'bar'});
var r = s.map(x => x);
expect(r.meta().foo).to.equal('bar');
},
'should get initial meta from getInitialMeta' () {
var S = MetaStream.use({
getInitialMeta() {
return {foo: 'bar'};
}
});
expect(S().meta().foo).to.equal('bar');
},
'should merge meta deeply' () {
var s = MetaStream();
s.meta({foo: {bar: 'baz'}});
s.meta({foo: {quux: 'frob'}});
expect(s.meta()).to.deep.equal({
foo: {
bar: 'baz',
quux: 'frob'
}
});
}
};