release: v20240729 Co-authored-by: Laura Hausmann <laura@hausmann.dev> Co-authored-by: GitLab CI <project_7_bot_1bfaee5701aed20091a86249a967a6c1@noreply.firefish.dev> Co-authored-by: Hosted Weblate <hosted@weblate.org> Co-authored-by: Saamkhaih Kyakya <70475761+hiohlan@users.noreply.github.com> See merge request firefish/firefish!11214
32 lines
1,005 B
TypeScript
32 lines
1,005 B
TypeScript
import { expectType } from "tsd";
|
|
import * as firefish from "../src";
|
|
|
|
describe("Streaming", () => {
|
|
test("emit type", async () => {
|
|
const stream = new firefish.Stream("https://firefish.test", {
|
|
token: "TOKEN",
|
|
});
|
|
const mainChannel = stream.useChannel("main");
|
|
mainChannel.on("notification", (notification) => {
|
|
expectType<firefish.entities.Notification>(notification);
|
|
});
|
|
});
|
|
|
|
test("params type", async () => {
|
|
const stream = new firefish.Stream("https://firefish.test", {
|
|
token: "TOKEN",
|
|
});
|
|
// TODO: 「stream.useChannel の第二引数として受け入れる型が
|
|
// {
|
|
// otherparty?: User['id'] | null;
|
|
// group?: UserGroup['id'] | null;
|
|
// }
|
|
// になっている」というテストを行いたいけどtsdでの書き方がわからない
|
|
const messagingChannel = stream.useChannel("messaging", {
|
|
otherparty: "aaa",
|
|
});
|
|
messagingChannel.on("message", (message) => {
|
|
expectType<firefish.entities.MessagingMessage>(message);
|
|
});
|
|
});
|
|
});
|