@@ -206,49 +206,27 @@ describe('publish/subscribe', function () {
206206 sub . subscribe ( channel ) ;
207207 } ) ;
208208
209- it ( 'handles SUBSCRIBE_CLOSE_RESUBSCRIBE ' , function ( done ) {
209+ it ( 'subscribe; close; resubscribe with prototype inherited property names ' , function ( done ) {
210210 var count = 0 ;
211- /* Create two clients. c1 subscribes to two channels, c2 will publish to them.
212- c2 publishes the first message.
213- c1 gets the message and drops its connection. It must resubscribe itself.
214- When it resubscribes, c2 publishes the second message, on the same channel
215- c1 gets the message and drops its connection. It must resubscribe itself, again.
216- When it resubscribes, c2 publishes the third message, on the second channel
217- c1 gets the message and drops its connection. When it reconnects, the test ends.
218- */
211+ var channels = [ '__proto__' , 'channel 2' ] ;
212+ var msg = [ 'hi from channel __proto__' , 'hi from channel 2' ] ;
213+
219214 sub . on ( 'message' , function ( channel , message ) {
220- if ( channel === 'chan1' ) {
221- assert . strictEqual ( message , 'hi on channel 1' ) ;
222- sub . stream . end ( ) ;
223- } else if ( channel === 'chan2' ) {
224- assert . strictEqual ( message , 'hi on channel 2' ) ;
225- sub . stream . end ( ) ;
226- } else {
227- sub . quit ( ) ;
228- pub . quit ( ) ;
229- assert . fail ( 'test failed' ) ;
230- }
215+ var n = Math . max ( count - 1 , 0 ) ;
216+ assert . strictEqual ( channel , channels [ n ] ) ;
217+ assert . strictEqual ( message , msg [ n ] ) ;
218+ if ( count === 2 ) return done ( ) ;
219+ sub . stream . end ( ) ;
231220 } ) ;
232221
233- sub . subscribe ( 'chan1' , 'chan2' ) ;
222+ sub . subscribe ( channels ) ;
234223
235224 sub . on ( 'ready' , function ( err , results ) {
225+ pub . publish ( channels [ count ] , msg [ count ] ) ;
236226 count ++ ;
237- if ( count === 1 ) {
238- pub . publish ( 'chan1' , 'hi on channel 1' ) ;
239- return ;
240- } else if ( count === 2 ) {
241- pub . publish ( 'chan2' , 'hi on channel 2' ) ;
242- } else {
243- sub . quit ( function ( ) {
244- pub . quit ( function ( ) {
245- return done ( ) ;
246- } ) ;
247- } ) ;
248- }
249227 } ) ;
250228
251- pub . publish ( 'chan1' , 'hi on channel 1' ) ;
229+ pub . publish ( channels [ count ] , msg [ count ] ) ;
252230 } ) ;
253231 } ) ;
254232
0 commit comments