-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.spec.js
43 lines (31 loc) · 934 Bytes
/
index.spec.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
const test = require( 'tape' );
const makeBehaviorSubject = require( '.' );
test( "Should broadcast initial value on connection, if not updated.", assert => {
assert.plan( 2 );
const subject = makeBehaviorSubject( 'A' );
const sink = ( t, d ) => {
if ( t === 0 ) {
assert.ok( d, 'The sink should receive a talkback.' );
}
if ( t === 1 ) {
assert.equal( d, 'A', 'The sink should receive the initial subject value.' );
}
};
subject( 0, sink );
assert.end();
});
test( "Should broadcast last data on connection.", assert => {
assert.plan( 2 );
const subject = makeBehaviorSubject( 'A' );
subject( 1, 'B' );
const sink = ( t, d ) => {
if ( t === 0 ) {
assert.ok( d, 'The sink should receive a talkback.' );
}
if ( t === 1 ) {
assert.equal( d, 'B', 'The sink should receive the last subject value.' );
}
};
subject( 0, sink );
assert.end();
});