From a05f47d5cc4673fa25acc51be40a975141ab1361 Mon Sep 17 00:00:00 2001 From: syuilo Date: Sun, 2 Jan 2022 02:11:25 +0900 Subject: [PATCH] improve test --- test/streaming.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/test/streaming.ts b/test/streaming.ts index 2095c94efc..913db8b287 100644 --- a/test/streaming.ts +++ b/test/streaming.ts @@ -10,7 +10,10 @@ describe('Streaming', () => { main.on('meUpdated', payload => { mainChannelReceived.push(payload); }); - await server.connected; + + const ws = await server.connected; + expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN'); + const msg = JSON.parse(await server.nextMessage as string); const mainChannelId = msg.body.id; expect(msg.type).toEqual('connect'); @@ -44,7 +47,10 @@ describe('Streaming', () => { messaging.on('message', payload => { messagingChannelReceived.push(payload); }); - await server.connected; + + const ws = await server.connected; + expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN'); + const msg = JSON.parse(await server.nextMessage as string); const messagingChannelId = msg.body.id; expect(msg.type).toEqual('connect'); @@ -78,7 +84,8 @@ describe('Streaming', () => { stream.useChannel('messaging', { otherparty: 'aaa' }); stream.useChannel('messaging', { otherparty: 'bbb' }); - await server.connected; + const ws = await server.connected; + expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN'); const msg = JSON.parse(await server.nextMessage as string); const messagingChannelId = msg.body.id; @@ -100,7 +107,9 @@ describe('Streaming', () => { const messaging = stream.useChannel('messaging', { otherparty: 'aaa' }); messaging.send('read', { id: 'aaa' }); - await server.connected; + const ws = await server.connected; + expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN'); + const connectMsg = JSON.parse(await server.nextMessage as string); const channelId = connectMsg.body.id; const msg = JSON.parse(await server.nextMessage as string); @@ -122,7 +131,10 @@ describe('Streaming', () => { main.on('meUpdated', payload => { mainChannelReceived.push(payload); }); - await server.connected; + + const ws = await server.connected; + expect(new URLSearchParams(new URL(ws.url).search).get('i')).toEqual('TOKEN'); + const msg = JSON.parse(await server.nextMessage as string); const mainChannelId = msg.body.id; expect(msg.type).toEqual('connect');