File tree Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Expand file tree Collapse file tree 1 file changed +23
-8
lines changed Original file line number Diff line number Diff line change @@ -115,19 +115,34 @@ describe('CrossStorageClient', function() {
115
115
storage . onConnect ( ) . then ( done ) ;
116
116
} ) ;
117
117
118
- it ( 'is not fulfilled if a connection is not established' , function ( done ) {
118
+ it ( 'rejects if no connection could be established' , function ( done ) {
119
119
var storage = new CrossStorageClient ( 'http://localhost:9999' ) ;
120
- var invoked = false ;
121
120
122
- storage . onConnect ( ) . then ( function ( ) {
123
- invoked = true ;
121
+ storage . onConnect ( ) [ 'catch' ] ( function ( err ) {
122
+ expect ( err . message ) . to . be ( 'CrossStorageClient could not connect' ) ;
123
+ done ( ) ;
124
124
} ) ;
125
+ } ) ;
126
+
127
+ it ( 'can be used multiple times prior to connection' , function ( done ) {
128
+ var storage , count , incrOnConnect , i ;
129
+
130
+ storage = new CrossStorageClient ( url ) ;
131
+ count = 0 ;
132
+ incrOnConnect = function ( ) {
133
+ storage . onConnect ( ) . then ( function ( ) {
134
+ count ++ ;
135
+ } ) ;
136
+ } ;
125
137
126
- setTimeout ( function ( ) {
127
- if ( ! invoked ) return done ( ) ;
138
+ for ( i = 0 ; i < 5 ; i ++ ) {
139
+ incrOnConnect ( ) ;
140
+ }
128
141
129
- done ( new Error ( 'onConnect fired without connecting' ) ) ;
130
- } , 100 ) ;
142
+ storage . onConnect ( ) . then ( function ( ) {
143
+ expect ( count ) . to . be ( 5 ) ;
144
+ done ( ) ;
145
+ } ) ;
131
146
} ) ;
132
147
} ) ;
133
148
You can’t perform that action at this time.
0 commit comments