Skip to content
Snippets Groups Projects
Commit aace7a19 authored by syuilo's avatar syuilo
Browse files

add streaming test

parent 00bbd9c7
No related branches found
No related tags found
No related merge requests found
import WS from 'jest-websocket-mock';
import Stream from '../src/streaming';
describe('Streaming', () => {
test('success', async () => {
const server = new WS('wss://misskey.test/streaming');
const stream = new Stream('https://misskey.test', { token: 'TOKEN' });
const mainChannelReceived: any[] = [];
const main = stream.useSharedConnection('main');
main.on('foo', payload => {
mainChannelReceived.push(payload);
});
await server.connected;
const msg = JSON.parse(await server.nextMessage as string);
const mainChannelId = msg.body.id;
expect(msg.type).toEqual('connect');
expect(msg.body.channel).toEqual('main');
expect(mainChannelId != null).toEqual(true);
server.send(JSON.stringify({
type: 'channel',
body: {
id: mainChannelId,
type: 'foo',
body: {
bar: 'buzz'
}
}
}));
expect(mainChannelReceived[0]).toEqual({
bar: 'buzz'
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment