@@ -141,9 +141,9 @@ describe('RedisPubSub', () => {
141
141
} ) ;
142
142
143
143
it ( 'concurrent subscribe, unsubscribe first sub before second sub complete' , done => {
144
- const subs = {
145
- first : null as Promise < number > ,
146
- second : null as Promise < number > ,
144
+ const promises = {
145
+ firstSub : null as Promise < number > ,
146
+ secondSub : null as Promise < number > ,
147
147
}
148
148
149
149
let firstCb , secondCb
@@ -152,7 +152,7 @@ describe('RedisPubSub', () => {
152
152
if ( ! firstCb ) {
153
153
firstCb = ( ) => cb ( null , channel )
154
154
// Handling first call, init second sub
155
- subs . second = pubSub . subscribe ( 'Posts' , ( ) => null )
155
+ promises . secondSub = pubSub . subscribe ( 'Posts' , ( ) => null )
156
156
// Continue first sub callback
157
157
firstCb ( )
158
158
} else {
@@ -167,26 +167,26 @@ describe('RedisPubSub', () => {
167
167
168
168
// First leg of the test, init first sub and immediately unsubscribe. The second sub is triggered in the redis cb
169
169
// before the first promise sub complete
170
- subs . first = pubSub . subscribe ( 'Posts' , ( ) => null )
170
+ promises . firstSub = pubSub . subscribe ( 'Posts' , ( ) => null )
171
171
. then ( subId => {
172
172
// This assertion is done against a private member, if you change the internals, you may want to change that
173
173
expect ( ( pubSub as any ) . subscriptionMap [ subId ] ) . not . to . be . an ( 'undefined' ) ;
174
174
pubSub . unsubscribe ( subId ) ;
175
175
176
176
// Continue second sub callback
177
- subs . first . then ( ( ) => secondCb ( ) )
177
+ promises . firstSub . then ( ( ) => secondCb ( ) )
178
178
return subId ;
179
179
} ) ;
180
180
181
181
// Second leg of the test, here we have unsubscribed from the first sub. We try unsubbing from the second sub
182
182
// as soon it is ready
183
- subs . first
183
+ promises . firstSub
184
184
. then ( ( subId ) => {
185
185
// This assertion is done against a private member, if you change the internals, you may want to change that
186
186
expect ( ( pubSub as any ) . subscriptionMap [ subId ] ) . to . be . an ( 'undefined' ) ;
187
187
expect ( ( ) => pubSub . unsubscribe ( subId ) ) . to . throw ( `There is no subscription of id "${ subId } "` ) ;
188
188
189
- return subs . second . then ( secondSubId => {
189
+ return promises . secondSub . then ( secondSubId => {
190
190
pubSub . unsubscribe ( secondSubId ) ;
191
191
} )
192
192
. then ( done )
0 commit comments