@@ -137,6 +137,30 @@ describe('StatusManager', () => {
137137 expect ( socket . emit . args [ 2 ] ) . to . deep . equal ( [ 'probe:isIPv6Supported:update' , true ] ) ;
138138 } ) ;
139139
140+ it ( 'should treat rejected execa error with 0% packet loss as successful (happens if command times out)' , async ( ) => {
141+ const statusManager = new StatusManager ( socket , pingCmd ) ;
142+ pingCmd . rejects ( { stdout : pingSuccess , stderr : 'Command timed out' , exitCode : 143 } ) ;
143+ await statusManager . start ( ) ;
144+ expect ( pingCmd . callCount ) . to . equal ( 6 ) ;
145+ expect ( statusManager . getStatus ( ) ) . to . equal ( 'ready' ) ;
146+ expect ( socket . emit . callCount ) . to . equal ( 3 ) ;
147+ expect ( socket . emit . args [ 0 ] ) . to . deep . equal ( [ 'probe:status:update' , 'ready' ] ) ;
148+ expect ( socket . emit . args [ 1 ] ) . to . deep . equal ( [ 'probe:isIPv4Supported:update' , true ] ) ;
149+ expect ( socket . emit . args [ 2 ] ) . to . deep . equal ( [ 'probe:isIPv6Supported:update' , true ] ) ;
150+ } ) ;
151+
152+ it ( 'should treat rejected execa error with packet loss as failed' , async ( ) => {
153+ const statusManager = new StatusManager ( socket , pingCmd ) ;
154+ pingCmd . rejects ( { stdout : pingPacketLoss , stderr : 'Command timed out' , exitCode : 143 } ) ;
155+ await statusManager . start ( ) ;
156+ expect ( pingCmd . callCount ) . to . equal ( 6 ) ;
157+ expect ( statusManager . getStatus ( ) ) . to . equal ( 'ping-test-failed' ) ;
158+ expect ( socket . emit . callCount ) . to . equal ( 3 ) ;
159+ expect ( socket . emit . args [ 0 ] ) . to . deep . equal ( [ 'probe:status:update' , 'ping-test-failed' ] ) ;
160+ expect ( socket . emit . args [ 1 ] ) . to . deep . equal ( [ 'probe:isIPv4Supported:update' , false ] ) ;
161+ expect ( socket . emit . args [ 2 ] ) . to . deep . equal ( [ 'probe:isIPv6Supported:update' , false ] ) ;
162+ } ) ;
163+
140164 it ( 'should run check in a fixed intervals and do emit with a status every time' , async ( ) => {
141165 const statusManager = new StatusManager ( socket , pingCmd ) ;
142166 expect ( pingCmd . callCount ) . to . equal ( 0 ) ;
0 commit comments