-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathvalue.test.ts
More file actions
40 lines (31 loc) · 1.08 KB
/
value.test.ts
File metadata and controls
40 lines (31 loc) · 1.08 KB
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
import { should, expect } from 'chai'; should();
import group from '../group';
import { Source } from '../source';
import { Pin } from '../pin';
import value from '../value';
describe('value()', () => {
it('should be a `Pin`.', () => {
value(42).should.be.instanceof(Pin);
});
it('should only send given value when all of its inbound pins have sent data.', () => {
let c = undefined;
let a = new Source(); let b = new Source();
group(a, b).to(value('hellow')).subscribe(val => c = val);
a.send(); expect(c).to.be.undefined;
b.send(); expect(c).to.equal('hellow');
});
it('should again wait for all of its inbound pins for subsequently resending its value.', () => {
let c = 0;
let a = new Source(); let b = new Source();
group(a, b).to(value(3)).subscribe(v => c += v);
a.send(); b.send(); c.should.equal(3);
a.send(); c.should.equal(3);
b.send(); c.should.equal(6);
});
it('should send its value when not connected to any pin.', done => {
value(42).subscribe(val => {
val.should.equal(42);
done();
});
});
});