File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -107,6 +107,7 @@ export class Listener {
107107 this . webSocket . onerror = ( err ) => {
108108 console . log ( 'WebSocket Error ' ) ;
109109 console . log ( err ) ;
110+ reject ( err ) ;
110111 } ;
111112 this . webSocket . onmessage = ( msg ) => {
112113 const message = JSON . parse ( msg . data as string ) ;
Original file line number Diff line number Diff line change @@ -31,4 +31,17 @@ describe('Listener', () => {
3131 listener . close ( ) ;
3232 } ) ;
3333 } ) ;
34+
35+ describe ( 'onerror' , ( ) => {
36+ it ( 'should reject because of wrong server url' , async ( ) => {
37+ const listener = new Listener ( 'https://notcorrecturl:0000' ) ;
38+ await listener . open ( )
39+ . then ( ( result ) => {
40+ throw new Error ( 'This should not be called when expecting error' ) ;
41+ } )
42+ . catch ( ( error ) => {
43+ expect ( error . toString ( ) ) . to . be . equal ( "Error: getaddrinfo ENOTFOUND notcorrecturl notcorrecturl:0000" ) ;
44+ } )
45+ } ) ;
46+ } ) ;
3447} ) ;
You can’t perform that action at this time.
0 commit comments