From d0798e3182d3a5ac13e5ac6bb6022e1626f542aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A1szl=C3=B3=20K=C3=A1rolyi?= <laszlo@karolyi.hu> Date: Sat, 2 Jan 2021 12:14:07 +0100 Subject: [PATCH] Fix tests --- test/test_clientfactory.ts | 10 +++++----- test/test_presencehandler.ts | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_clientfactory.ts b/test/test_clientfactory.ts index ad2a29d..7c1d865 100644 --- a/test/test_clientfactory.ts +++ b/test/test_clientfactory.ts @@ -76,13 +76,13 @@ describe("ClientFactory", () => { describe("getDiscordId", () => { it("should fetch id successfully", async () => { const config = new DiscordBridgeConfigAuth(); - const cf = new DiscordClientFactory(null); + const cf = new DiscordClientFactory(null, config); const discordId = await cf.getDiscordId("passme"); expect(discordId).equals("12345"); }); it("should fail if the token is not recognised", async () => { const config = new DiscordBridgeConfigAuth(); - const cf = new DiscordClientFactory(null); + const cf = new DiscordClientFactory(null, config); try { await cf.getDiscordId("failme"); throw new Error("didn't fail"); @@ -102,7 +102,7 @@ describe("ClientFactory", () => { }); it("should return cached client", async () => { const config = new DiscordBridgeConfigAuth(); - const cf = new DiscordClientFactory(null); + const cf = new DiscordClientFactory(null, config); cf.clients.set("@user:localhost", "testclient"); const client = await cf.getClient("@user:localhost"); expect(client).equals("testclient"); @@ -116,14 +116,14 @@ describe("ClientFactory", () => { }); it("should fetch user client if userid matches", async () => { const config = new DiscordBridgeConfigAuth(); - const cf = new DiscordClientFactory(STORE); + const cf = new DiscordClientFactory(STORE, config); const client = await cf.getClient("@valid:localhost"); expect(client).is.not.null; expect(cf.clients.has("@valid:localhost")).to.be.true; }); it("should fail if the user client cannot log in", async () => { const config = new DiscordBridgeConfigAuth(); - const cf = new DiscordClientFactory(STORE); + const cf = new DiscordClientFactory(STORE, config); cf.botClient = 1; const client = await cf.getClient("@invalid:localhost"); expect(client).to.equal(cf.botClient); diff --git a/test/test_presencehandler.ts b/test/test_presencehandler.ts index 8b1bf49..cbf4d05 100644 --- a/test/test_presencehandler.ts +++ b/test/test_presencehandler.ts @@ -98,7 +98,7 @@ describe("PresenceHandler", () => { const member = new MockPresence(new MockUser("ghi", "alice"), "def", "online"); await handler.ProcessUser(member as any); appservice.getIntentForSuffix(member.userID) - .underlyingClient.wasCalled("setPresenceStatus", true, "online", undefined); + .underlyingClient.wasCalled("setPresenceStatus", true, "online", ""); }); it("processes an offline user", async () => { lastStatus = null; @@ -106,7 +106,7 @@ describe("PresenceHandler", () => { const member = new MockPresence(new MockUser("abc", "alice"), "def", "offline"); await handler.ProcessUser(member as any); appservice.getIntentForSuffix(member.userID) - .underlyingClient.wasCalled("setPresenceStatus", true, "offline", undefined); + .underlyingClient.wasCalled("setPresenceStatus", true, "offline", ""); }); it("processes an idle user", async () => { lastStatus = null; @@ -114,7 +114,7 @@ describe("PresenceHandler", () => { const member = new MockPresence(new MockUser("abc", "alice"), "def", "idle"); await handler.ProcessUser(member as any); appservice.getIntentForSuffix(member.userID) - .underlyingClient.wasCalled("setPresenceStatus", true, "unavailable", undefined); + .underlyingClient.wasCalled("setPresenceStatus", true, "unavailable", ""); }); it("processes an dnd user", async () => { lastStatus = null; -- GitLab