File tree Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Expand file tree Collapse file tree 3 files changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -278,7 +278,11 @@ DeviceTree.prototype.finishRequest = function () {
278278 self . callback = undefined ;
279279 self . clearTimeout ( ) ;
280280 self . activeRequest = null ;
281- self . makeRequest ( ) ;
281+ try {
282+ self . makeRequest ( ) ;
283+ } catch ( e ) {
284+ console . log ( "warn:" + e . message )
285+ }
282286} ;
283287
284288DeviceTree . prototype . timeoutRequest = function ( id ) {
Original file line number Diff line number Diff line change 11{
22 "name" : " emberplus" ,
3- "version" : " 1.7.22 " ,
3+ "version" : " 1.7.23 " ,
44 "description" : " Javascript implementation of the Ember+ automation protocol" ,
55 "main" : " index.js" ,
66 "scripts" : {
2929 },
3030 "devDependencies" : {
3131 "eslint" : " ^5.5.0" ,
32- "jest" : " ^23.5.0"
32+ "jest" : " ^23.5.0" ,
33+ "sinon" : " ^7.4.1"
3334 }
3435}
Original file line number Diff line number Diff line change 11const fs = require ( "fs" ) ;
2+ const sinon = require ( "sinon" ) ;
23const Decoder = require ( '../' ) . Decoder ;
34const DeviceTree = require ( "../" ) . DeviceTree ;
45const TreeServer = require ( "../" ) . TreeServer ;
@@ -9,6 +10,7 @@ const PORT = 9008;
910
1011describe ( "DeviceTree" , ( ) => {
1112 describe ( "With server" , ( ) => {
13+ /** @type {TreeServer } */
1214 let server ;
1315 beforeAll ( ( ) => {
1416 return Promise . resolve ( )
@@ -42,6 +44,26 @@ describe("DeviceTree", () => {
4244 } )
4345 } ) ;
4446
47+ it ( "should gracefully connect and getDirectory" , ( ) => {
48+ let tree = new DeviceTree ( LOCALHOST , PORT ) ;
49+ let stub = sinon . stub ( tree . client , "sendBER" ) ;
50+ stub . onFirstCall ( ) . returns ( ) ;
51+ stub . onSecondCall ( ) . throws ( new Error ( "blah" ) ) ;
52+ stub . callThrough ( ) ;
53+ return Promise . resolve ( )
54+ . then ( ( ) => tree . connect ( ) )
55+ . then ( ( ) => { tree . getDirectory ( ) . catch ( ( ) => { } ) } )
56+ . then ( ( ) => tree . getDirectory ( ) )
57+ . then ( ( ) => {
58+ stub . restore ( ) ;
59+ tree . disconnect ( ) ;
60+ } , error => {
61+ stub . restore ( ) ;
62+ tree . disconnect ( ) ;
63+ throw error ;
64+ } )
65+
66+ } , 10000 ) ;
4567 it ( "should not disconnect after 5 seconds of inactivity" , ( ) => {
4668 return Promise . resolve ( )
4769 . then ( ( ) => {
You can’t perform that action at this time.
0 commit comments