@@ -8,28 +8,37 @@ const testedChannel = dc.channel('test');
88const testedSubscription = ( ) => { } ;
99const testedData = { foo : 'bar' } ;
1010
11- // should publish on meta channel for subscribe() on both inactive and active prototype
12- dc . subscribe ( 'diagnostics_channel.subscribe' , common . mustCall ( ( { channel, subscription } ) => {
13- assert . strictEqual ( channel , testedChannel ) ;
14- assert . strictEqual ( subscription , testedSubscription ) ;
15- } , 2 ) ) ; // called twice
16- testedChannel . subscribe ( testedSubscription ) ; // inactive prototype
17- testedChannel . subscribe ( testedSubscription ) ; // active prototype
18-
19- // should publish on meta channel for publish()
20- dc . subscribe ( 'diagnostics_channel.publish' , common . mustCall ( ( { channel, data } ) => {
21- assert . strictEqual ( channel , testedChannel ) ;
22- assert . strictEqual ( data , testedData ) ;
23- } ) ) ;
24- testedChannel . publish ( testedData ) ;
25-
26- // should publish on meta channel for unsubscribe() on both inactive and active prototype
27- dc . subscribe ( 'diagnostics_channel.unsubscribe' , common . mustCall ( ( { channel, subscription } ) => {
28- assert . strictEqual ( channel , testedChannel ) ;
29- assert . strictEqual ( subscription , testedSubscription ) ;
30- } , 2 ) ) ; // called twice
31- testedChannel . unsubscribe ( testedSubscription ) ; // active prototype
32- testedChannel . unsubscribe ( testedSubscription ) ; // inactive prototype
11+ {
12+ // should publish on meta channel for subscribe() on both inactive and active prototype
13+ const subscribeHandler = common . mustCall ( ( { channel, subscription } ) => {
14+ assert . strictEqual ( channel , testedChannel ) ;
15+ assert . strictEqual ( subscription , testedSubscription ) ;
16+ } , 2 ) ; // called twice
17+ dc . subscribe ( 'diagnostics_channel.subscribe' , subscribeHandler ) ;
18+ testedChannel . subscribe ( testedSubscription ) ; // inactive prototype
19+ testedChannel . subscribe ( testedSubscription ) ; // active prototype
20+ dc . unsubscribe ( 'diagnostics_channel.subscribe' , subscribeHandler ) ;
21+ }
3322
23+ {
24+ // should publish on meta channel for publish()
25+ const publishHandler = common . mustCall ( ( { channel, data } ) => {
26+ assert . strictEqual ( channel , testedChannel ) ;
27+ assert . strictEqual ( data , testedData ) ;
28+ } ) ;
29+ dc . subscribe ( 'diagnostics_channel.publish' , publishHandler ) ;
30+ testedChannel . publish ( testedData ) ;
31+ dc . unsubscribe ( 'diagnostics_channel.publish' , publishHandler ) ;
32+ }
3433
34+ {
35+ // should publish on meta channel for unsubscribe() on both inactive and active prototype
36+ const unsubscribeHandler = common . mustCall ( ( { channel, subscription } ) => {
37+ assert . strictEqual ( channel , testedChannel ) ;
38+ assert . strictEqual ( subscription , testedSubscription ) ;
39+ } , 2 ) ; // called twice
40+ dc . subscribe ( 'diagnostics_channel.unsubscribe' , unsubscribeHandler ) ;
41+ testedChannel . unsubscribe ( testedSubscription ) ; // active prototype
42+ testedChannel . unsubscribe ( testedSubscription ) ; // inactive prototype
43+ }
3544// TODO: should it publish on inactive channels ?
0 commit comments