@@ -508,52 +508,64 @@ describe('publish/subscribe', function () {
508508 } ) ;
509509
510510 it ( 'allows to listen to pmessageBuffer and pmessage' , function ( done ) {
511- var batch = sub . batch ( ) ;
512511 var end = helper . callFuncAfter ( done , 6 ) ;
513- assert . strictEqual ( sub . message_buffers , false ) ;
514- batch . psubscribe ( '*' ) ;
515- batch . subscribe ( '/foo' ) ;
516- batch . unsubscribe ( '/foo' ) ;
517- batch . unsubscribe ( helper . isNull ( ) ) ;
518- batch . subscribe ( [ '/foo' ] , helper . isString ( '/foo' ) ) ;
519- batch . exec ( ) ;
520- assert . strictEqual ( sub . shouldBuffer , false ) ;
521- sub . on ( 'pmessageBuffer' , function ( pattern , channel , message ) {
522- assert . strictEqual ( pattern . inspect ( ) , new Buffer ( '*' ) . inspect ( ) ) ;
523- assert . strictEqual ( channel . inspect ( ) , new Buffer ( '/foo' ) . inspect ( ) ) ;
524- sub . quit ( end ) ;
525- } ) ;
526- // Either message_buffers or buffers has to be true, but not both at the same time
527- assert . notStrictEqual ( sub . message_buffers , sub . buffers ) ;
528- sub . on ( 'pmessage' , function ( pattern , channel , message ) {
529- assert . strictEqual ( pattern , '*' ) ;
530- assert . strictEqual ( channel , '/foo' ) ;
531- assert . strictEqual ( message , 'hello world' ) ;
532- end ( ) ;
533- } ) ;
534- sub . on ( 'message' , function ( channel , message ) {
535- assert . strictEqual ( channel , '/foo' ) ;
536- assert . strictEqual ( message , 'hello world' ) ;
537- end ( ) ;
538- } ) ;
539- setTimeout ( function ( ) {
540- pub . pubsub ( 'numsub' , '/foo' , function ( err , res ) {
541- // There's one subscriber to this channel
542- assert . deepEqual ( res , [ '/foo' , 1 ] ) ;
543- end ( ) ;
512+ var data = Array ( 10000 ) . join ( 'äüs^öéÉÉ`e' ) ;
513+ sub . set ( 'foo' , data , function ( ) {
514+ sub . get ( 'foo' ) ;
515+ sub . stream . once ( 'data' , function ( ) {
516+ assert . strictEqual ( sub . message_buffers , false ) ;
517+ assert . strictEqual ( sub . shouldBuffer , false ) ;
518+ sub . on ( 'pmessageBuffer' , function ( pattern , channel , message ) {
519+ if ( parser !== 'javascript' && typeof pattern === 'string' ) {
520+ pattern = new Buffer ( pattern ) ;
521+ channel = new Buffer ( channel ) ;
522+ }
523+ assert . strictEqual ( pattern . inspect ( ) , new Buffer ( '*' ) . inspect ( ) ) ;
524+ assert . strictEqual ( channel . inspect ( ) , new Buffer ( '/foo' ) . inspect ( ) ) ;
525+ sub . quit ( end ) ;
526+ } ) ;
527+ if ( parser === 'javascript' ) {
528+ assert . notStrictEqual ( sub . message_buffers , sub . buffers ) ;
529+ }
530+
544531 } ) ;
545- pub . pubsub ( 'channels' , function ( err , res ) {
546- // There's exactly one channel that is listened too
547- assert . deepEqual ( res , [ '/foo' ] ) ;
532+ var batch = sub . batch ( ) ;
533+ batch . psubscribe ( '*' ) ;
534+ batch . subscribe ( '/foo' ) ;
535+ batch . unsubscribe ( '/foo' ) ;
536+ batch . unsubscribe ( helper . isNull ( ) ) ;
537+ batch . subscribe ( [ '/foo' ] , helper . isString ( '/foo' ) ) ;
538+ batch . exec ( function ( ) {
539+ pub . pubsub ( 'numsub' , '/foo' , function ( err , res ) {
540+ // There's one subscriber to this channel
541+ assert . deepEqual ( res , [ '/foo' , 1 ] ) ;
542+ end ( ) ;
543+ } ) ;
544+ pub . pubsub ( 'channels' , function ( err , res ) {
545+ // There's exactly one channel that is listened too
546+ assert . deepEqual ( res , [ '/foo' ] ) ;
547+ end ( ) ;
548+ } ) ;
549+ pub . pubsub ( 'numpat' , function ( err , res ) {
550+ // One pattern is active
551+ assert . strictEqual ( res , 1 ) ;
552+ end ( ) ;
553+ } ) ;
554+ pub . publish ( '/foo' , 'hello world' , helper . isNumber ( 2 ) ) ;
555+ } ) ;
556+ // Either message_buffers or buffers has to be true, but not both at the same time
557+ sub . on ( 'pmessage' , function ( pattern , channel , message ) {
558+ assert . strictEqual ( pattern , '*' ) ;
559+ assert . strictEqual ( channel , '/foo' ) ;
560+ assert . strictEqual ( message , 'hello world' ) ;
548561 end ( ) ;
549562 } ) ;
550- pub . pubsub ( 'numpat ', function ( err , res ) {
551- // One pattern is active
552- assert . strictEqual ( res , 1 ) ;
563+ sub . on ( 'message ', function ( channel , message ) {
564+ assert . strictEqual ( channel , '/foo' ) ;
565+ assert . strictEqual ( message , 'hello world' ) ;
553566 end ( ) ;
554567 } ) ;
555- pub . publish ( '/foo' , 'hello world' , helper . isNumber ( 2 ) ) ;
556- } , 50 ) ;
568+ } ) ;
557569 } ) ;
558570 } ) ;
559571
0 commit comments