File tree Expand file tree Collapse file tree 1 file changed +5
-11
lines changed
Expand file tree Collapse file tree 1 file changed +5
-11
lines changed Original file line number Diff line number Diff line change @@ -155,24 +155,17 @@ describe('#distribution test (titanium)', function () {
155155 pubnub . reconnect ( ) ;
156156
157157 var finished = false ;
158- var sawConnected = false ;
159158
160159 pubnub . addListener ( {
161160 status : function ( st ) {
162161 try {
163- // Reconnect finishes asynchronously: first status is often PNSubscribeOperation (connected).
164- // Wait until connected, then unsubscribe, then assert on the leave request (PNUnsubscribeOperation).
165- if ( ! sawConnected ) {
166- if ( st . category === PubNub . CATEGORIES . PNConnectedCategory ) {
167- sawConnected = true ;
168- pubnub . unsubscribe ( { channels : [ myChannel1 ] } ) ;
169- }
170- return ;
171- }
172- if ( st . operation !== 'PNUnsubscribeOperation' ) {
162+ if ( st . category === 'PNConnectedCategory' ) {
163+ // this is expected due to async nature of the reconnect()
173164 return ;
174165 }
166+ expect ( st . category ) . to . be . equal ( 'PNDisconnectedCategory' ) ;
175167 if ( ! finished ) {
168+ // prevent calling done twice
176169 finished = true ;
177170 done ( ) ;
178171 }
@@ -181,5 +174,6 @@ describe('#distribution test (titanium)', function () {
181174 }
182175 } ,
183176 } ) ;
177+ pubnub . unsubscribe ( { channels : [ myChannel1 ] } ) ;
184178 } ) ;
185179} ) ;
You can’t perform that action at this time.
0 commit comments