This commit is contained in:
syuilo
2021-05-23 13:34:36 +09:00
parent ca655c0628
commit 6ae5f76250
4 changed files with 30 additions and 27 deletions

View File

@@ -2,11 +2,11 @@ import WS from 'jest-websocket-mock';
import Stream from '../src/streaming';
describe('Streaming', () => {
test('useSharedConnection', async () => {
test('useChannel', 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');
const main = stream.useChannel('main');
main.on('meUpdated', payload => {
mainChannelReceived.push(payload);
});
@@ -35,11 +35,15 @@ describe('Streaming', () => {
server.close();
});
test('SharedConnection#dispose', async () => {
test('useChannel with parameters', async () => {
// TODO
});
test('Connection#dispose', 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');
const main = stream.useChannel('main');
main.on('meUpdated', payload => {
mainChannelReceived.push(payload);
});
@@ -68,4 +72,6 @@ describe('Streaming', () => {
});
// TODO: SharedConnection#dispose して一定時間経ったら disconnect メッセージがサーバーに送られてくるかのテスト
// TODO: チャンネル接続が使いまわされるかのテスト
});