@@ -8,16 +8,18 @@ const { createServer } = require('http')
88const { promisify } = require ( 'util' )
99const { once } = require ( 'events' )
1010const cookieValue = 'foo=bar'
11+ const subprotocolValue = 'foo-subprotocol'
1112
1213test ( 'basic websocket proxy' , async ( t ) => {
13- t . plan ( 3 )
14+ t . plan ( 4 )
1415
1516 const origin = createServer ( )
1617 const wss = new WebSocket . Server ( { server : origin } )
1718 t . teardown ( wss . close . bind ( wss ) )
1819 t . teardown ( origin . close . bind ( origin ) )
1920
2021 wss . on ( 'connection' , ( ws , request ) => {
22+ t . equal ( ws . protocol , subprotocolValue )
2123 t . equal ( request . headers . cookie , cookieValue )
2224 ws . on ( 'message' , ( message ) => {
2325 t . equal ( message . toString ( ) , 'hello' )
@@ -38,7 +40,7 @@ test('basic websocket proxy', async (t) => {
3840 t . teardown ( server . close . bind ( server ) )
3941
4042 const options = { headers : { cookie : cookieValue } }
41- const ws = new WebSocket ( `ws://localhost:${ server . server . address ( ) . port } ` , options )
43+ const ws = new WebSocket ( `ws://localhost:${ server . server . address ( ) . port } ` , [ subprotocolValue ] , options )
4244
4345 await once ( ws , 'open' )
4446
@@ -47,7 +49,6 @@ test('basic websocket proxy', async (t) => {
4749 stream . write ( 'hello' )
4850
4951 const [ buf ] = await once ( stream , 'data' )
50-
5152 t . equal ( buf . toString ( ) , 'hello' )
5253
5354 await Promise . all ( [
0 commit comments