Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (31 sloc) 1.08 KB
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();
});
});
});
You can’t perform that action at this time.