File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change 11'use strict'
22
33const http = require ( 'http' )
4+ const util = require ( 'util' )
45const split = require ( 'split2' )
56const test = require ( 'tap' ) . test
67const Fastify = require ( 'fastify' )
@@ -317,11 +318,16 @@ test('Should be able to pass custom connectionOptions to createWebSocketStream',
317318 fastify . register ( fastifyWebsocket , { connectionOptions } )
318319
319320 fastify . get ( '/' , { websocket : true } , ( connection , request ) => {
320- t . equal ( connection . readableObjectMode , true )
321+ // readableObjectMode was added in Node v12.3.0 so for earlier versions
322+ // we check the encapsulated readable state directly
323+ const mode = ( typeof connection . readableObjectMode === 'undefined' )
324+ ? connection . _readableState . objectMode
325+ : connection . readableObjectMode
326+ t . equal ( mode , true )
321327 connection . socket . binaryType = 'arraybuffer'
322328
323329 connection . once ( 'data' , ( chunk ) => {
324- const message = new TextDecoder ( ) . decode ( chunk )
330+ const message = new util . TextDecoder ( ) . decode ( chunk )
325331 t . equal ( message , 'Hello' )
326332 } )
327333 t . teardown ( ( ) => connection . destroy ( ) )
You can’t perform that action at this time.
0 commit comments