File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 31
31
"code" : " ^1.4.1" ,
32
32
"lab" : " ^5.13.0" ,
33
33
"precommit-hook" : " ^3.0.0" ,
34
+ "sinon" : " ^1.15.4" ,
34
35
"standard" : " ^4.5.2" ,
35
36
"stream-pair" : " ^1.0.3"
36
37
},
Original file line number Diff line number Diff line change @@ -150,9 +150,9 @@ function Swarm () {
150
150
if ( number === 0 ) { cb ( ) }
151
151
var c = new Counter ( number , cb )
152
152
153
- keys . map ( function ( key ) {
154
- c . hit ( )
153
+ keys . forEach ( function ( key ) {
155
154
self . connections [ key ] . conn . end ( )
155
+ c . hit ( )
156
156
} )
157
157
}
158
158
Original file line number Diff line number Diff line change 1
1
var Lab = require ( 'lab' )
2
2
var Code = require ( 'code' )
3
+ var sinon = require ( 'sinon' )
3
4
var lab = exports . lab = Lab . script ( )
4
5
5
6
var experiment = lab . experiment
@@ -85,6 +86,19 @@ experiment('BASICS', function () {
85
86
} )
86
87
} )
87
88
} )
89
+
90
+ experiment ( 'Swarm.closeConns' , function ( ) {
91
+ test ( 'calls end on all connections' , function ( done ) {
92
+ swarmA . openConnection ( peerB , function ( ) {
93
+ var key = Object . keys ( swarmA . connections ) [ 0 ]
94
+ sinon . spy ( swarmA . connections [ key ] . conn , 'end' )
95
+ swarmA . closeConns ( function ( ) {
96
+ expect ( swarmA . connections [ key ] . conn . end . called ) . to . be . equal ( true )
97
+ done ( )
98
+ } )
99
+ } )
100
+ } )
101
+ } )
88
102
} )
89
103
90
104
experiment ( 'BASE' , function ( ) {
You can’t perform that action at this time.
0 commit comments