File tree Expand file tree Collapse file tree 4 files changed +52
-2
lines changed Expand file tree Collapse file tree 4 files changed +52
-2
lines changed Original file line number Diff line number Diff line change 88 - " node_modules"
99before_script :
1010 - npm run build
11- script : npm run test:coveralls
11+ script :
12+ - npm run test:coveralls
13+ before_deploy :
14+ - npm install --global typedoc
15+ - typedoc --out ts-docs src
16+ deploy :
17+ provider : pages
18+ skip_cleanup : true
19+ keep-history : true
20+ local_dir : ts-docs
21+ github_token : $GITHUB_TOKEN
22+ on :
23+ branch : master
24+
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ with the NEM2 (a.k.a Catapult)
1616- NodeJS 9.X.X
1717- NodeJS 10.X.X
1818
19+ ## Installation
20+
21+ ``` npm install nem2-sdk rxjs ```
22+
1923## Documentation and Getting Started
2024
2125Get started and learn more about nem2-sdk-typescript-javascript, check the [ official documentation] [ docs ] .
@@ -47,4 +51,4 @@ Licensed under the [Apache License 2.0](LICENSE)
4751[ self ] : https://github.com/nemtech/nem2-sdk-typescript-javascript
4852[ docs ] : http://nemtech.github.io/getting-started/setup-workstation.html
4953[ issues ] : https://github.com/nemtech/nem2-sdk-typescript-javascript/issues
50- [ sdk-ref ] : http://nemtech.github.io/nem2-sdk-typescript-javascript
54+ [ sdk-ref ] : http://nemtech.github.io/nem2-sdk-typescript-javascript
Original file line number Diff line number Diff line change @@ -104,6 +104,7 @@ export class Listener {
104104 this . webSocket . onerror = ( err ) => {
105105 console . log ( 'WebSocket Error ' ) ;
106106 console . log ( err ) ;
107+ reject ( err ) ;
107108 } ;
108109 this . webSocket . onmessage = ( msg ) => {
109110 const message = JSON . parse ( msg . data as string ) ;
@@ -155,6 +156,17 @@ export class Listener {
155156 } ) ;
156157 }
157158
159+ /**
160+ * returns a boolean that repressents the open state
161+ * @returns a boolean
162+ */
163+ public isOpen ( ) : boolean {
164+ if ( this . webSocket ) {
165+ return this . webSocket . readyState === WebSocket . OPEN ;
166+ }
167+ return false ;
168+ }
169+
158170 /**
159171 * Close web socket connection.
160172 * @returns void
Original file line number Diff line number Diff line change @@ -23,4 +23,25 @@ describe('Listener', () => {
2323 expect ( 'ws://localhost:3000/ws' ) . to . be . equal ( listener . url ) ;
2424 listener . close ( ) ;
2525 } ) ;
26+
27+ describe ( 'isOpen' , ( ) => {
28+ it ( 'should return false when listener is created and not opened' , ( ) => {
29+ const listener = new Listener ( 'ws://localhost:3000' ) ;
30+ expect ( listener . isOpen ( ) ) . to . be . false ;
31+ listener . close ( ) ;
32+ } ) ;
33+ } ) ;
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+ } ) ;
2647} ) ;
You can’t perform that action at this time.
0 commit comments