2021-05-17 14:55:13 +00:00
|
|
|
import { expectType } from 'tsd';
|
2022-09-23 15:21:29 +00:00
|
|
|
import * as foundkey from '../src';
|
2021-05-17 14:55:13 +00:00
|
|
|
|
|
|
|
describe('Streaming', () => {
|
|
|
|
test('emit type', async () => {
|
2022-09-23 15:42:30 +00:00
|
|
|
const stream = new foundkey.Stream('https://foundkey.test', { token: 'TOKEN' });
|
2021-05-23 04:34:36 +00:00
|
|
|
const mainChannel = stream.useChannel('main');
|
2021-05-17 14:55:13 +00:00
|
|
|
mainChannel.on('notification', notification => {
|
2022-09-23 15:21:29 +00:00
|
|
|
expectType<foundkey.entities.Notification>(notification);
|
2021-05-17 14:55:13 +00:00
|
|
|
});
|
|
|
|
});
|
2021-06-27 12:17:42 +00:00
|
|
|
|
|
|
|
test('params type', async () => {
|
2022-09-23 15:42:30 +00:00
|
|
|
const stream = new foundkey.Stream('https://foundkey.test', { token: 'TOKEN' });
|
2021-06-27 12:17:42 +00:00
|
|
|
// TODO: 「stream.useChannel の第二引数として受け入れる型が
|
|
|
|
// {
|
|
|
|
// otherparty?: User['id'] | null;
|
|
|
|
// group?: UserGroup['id'] | null;
|
|
|
|
// }
|
|
|
|
// になっている」というテストを行いたいけどtsdでの書き方がわからない
|
|
|
|
const messagingChannel = stream.useChannel('messaging', { otherparty: 'aaa' });
|
|
|
|
messagingChannel.on('message', message => {
|
2022-09-23 15:21:29 +00:00
|
|
|
expectType<foundkey.entities.MessagingMessage>(message);
|
2021-06-27 12:17:42 +00:00
|
|
|
});
|
|
|
|
});
|
2021-05-17 14:55:13 +00:00
|
|
|
});
|