From 78861f8a31d68ee630c99a779e52f91e2e925cd9 Mon Sep 17 00:00:00 2001 From: syuilo Date: Mon, 28 Jun 2021 18:34:25 +0900 Subject: [PATCH] add test --- test/streaming.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/streaming.ts b/test/streaming.ts index 4e2337f33b..2095c94efc 100644 --- a/test/streaming.ts +++ b/test/streaming.ts @@ -93,6 +93,27 @@ describe('Streaming', () => { server.close(); }); + test('Connection#send', async () => { + const server = new WS('wss://misskey.test/streaming'); + const stream = new Stream('https://misskey.test', { token: 'TOKEN' }); + + const messaging = stream.useChannel('messaging', { otherparty: 'aaa' }); + messaging.send('read', { id: 'aaa' }); + + await server.connected; + const connectMsg = JSON.parse(await server.nextMessage as string); + const channelId = connectMsg.body.id; + const msg = JSON.parse(await server.nextMessage as string); + + expect(msg.type).toEqual('ch'); + expect(msg.body.id).toEqual(channelId); + expect(msg.body.type).toEqual('read'); + expect(msg.body.body).toEqual({ id: 'aaa' }); + + stream.close(); + server.close(); + }); + test('Connection#dispose', async () => { const server = new WS('wss://misskey.test/streaming'); const stream = new Stream('https://misskey.test', { token: 'TOKEN' });