From 33fcff8db2100894936aa48073dd36e637a6f2fa Mon Sep 17 00:00:00 2001 From: Will Hunt <will@half-shot.uk> Date: Tue, 3 Nov 2020 09:58:16 +0000 Subject: [PATCH] Get tests to pass --- src/matrixmessageprocessor.ts | 2 +- test/mocks/collection.ts | 4 ++++ test/test_matrixmessageprocessor.ts | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/matrixmessageprocessor.ts b/src/matrixmessageprocessor.ts index 1b62c84..c33a19e 100644 --- a/src/matrixmessageprocessor.ts +++ b/src/matrixmessageprocessor.ts @@ -124,7 +124,7 @@ export class MatrixMessageProcessor { const USER_REGEX = /^@_discord_([0-9]*)/; const match = mxid.match(USER_REGEX); const member = match && await guild.members.fetch(match[1]); - if (!match || member) { + if (!match || !member) { return null; } return match[1]; diff --git a/test/mocks/collection.ts b/test/mocks/collection.ts index 7773f44..65db424 100644 --- a/test/mocks/collection.ts +++ b/test/mocks/collection.ts @@ -39,4 +39,8 @@ export class MockCollectionManager<T1, T2> { public resolve(id: T1) { return this.innerCache.get(id); } + + public async fetch(id: T1) { + return this.innerCache.get(id); + } } diff --git a/test/test_matrixmessageprocessor.ts b/test/test_matrixmessageprocessor.ts index 0c5e2b2..bcbf78c 100644 --- a/test/test_matrixmessageprocessor.ts +++ b/test/test_matrixmessageprocessor.ts @@ -253,7 +253,7 @@ describe("MatrixMessageProcessor", () => { guild.emojis.cache.set("123456", emoji); const msg = getHtmlMessage("<img alt=\"test_emoji\">"); const result = await mp.FormatMessage(msg, guild as any); - expect(result).is.equal("<:test_emoji:123456>"); + expect(result).is.equal("test\\_emoji"); }); it("Inserts emojis by mxc url", async () => { const mp = new MatrixMessageProcessor(bot, config); -- GitLab