From 7943f33dbb1e342620f00f33c4c9a26eb0282000 Mon Sep 17 00:00:00 2001 From: Guzio Date: Wed, 22 Apr 2026 13:50:27 +0000 Subject: [PATCH 1/2] What were those imports for, anyway? --- src/d2m/converters/thread-to-announcement.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/d2m/converters/thread-to-announcement.js b/src/d2m/converters/thread-to-announcement.js index bd3412c..b3a4487 100644 --- a/src/d2m/converters/thread-to-announcement.js +++ b/src/d2m/converters/thread-to-announcement.js @@ -1,9 +1,7 @@ // @ts-check -const assert = require("assert").strict - const passthrough = require("../../passthrough") -const {discord, sync, db, select} = passthrough +const {sync, select} = passthrough /** @type {import("../../matrix/utils")} */ const mxUtils = sync.require("../../matrix/utils") const {reg} = require("../../matrix/read-registration.js") From b007822174401473be56c929d06d0bfc5f554899 Mon Sep 17 00:00:00 2001 From: Guzio Date: Wed, 22 Apr 2026 13:54:49 +0000 Subject: [PATCH 2/2] Okey, let's be real: Those tests were an embarrassment. --- src/matrix/utils.test.js | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/src/matrix/utils.test.js b/src/matrix/utils.test.js index 8db998d..6887252 100644 --- a/src/matrix/utils.test.js +++ b/src/matrix/utils.test.js @@ -417,6 +417,11 @@ test("set user power: privileged users must demote themselves", async t => { t.equal(called, 3) }) +test("getThreadRoomFromThreadEvent: real message with a thread", t => { + const room = getThreadRoomFromThreadEvent("$fdD9o7NxMA4VPexlAiIx2CB9JbsiGhJeyJgnZG7U5xg") + t.equal(room, "!FuDZhlOAtqswlyxzeR:cadence.moe") +}) + test("getThreadRoomFromThreadEvent: real message, but without a thread", t => { const room = getThreadRoomFromThreadEvent("$Ij3qo7NxMA4VPexlAiIx2CB9JbsiGhJeyt-2OvkAUe4") const msg = "Expected null/undefined, got: "+room @@ -424,11 +429,6 @@ test("getThreadRoomFromThreadEvent: real message, but without a thread", t => { else t.pass(msg) }) -test("getThreadRoomFromThreadEvent: real message with a thread", t => { - const room = getThreadRoomFromThreadEvent("$fdD9o7NxMA4VPexlAiIx2CB9JbsiGhJeyJgnZG7U5xg") - t.equal(room, "!FuDZhlOAtqswlyxzeR:cadence.moe") -}) - test("getThreadRoomFromThreadEvent: fake message", t => { const room = getThreadRoomFromThreadEvent("$ThisEvent-IdDoesNotExistInTheDatabase4Sure") const msg = "Expected null/undefined, got: "+room @@ -436,19 +436,4 @@ test("getThreadRoomFromThreadEvent: fake message", t => { else t.pass(msg) }) -test("getThreadRoomFromThreadEvent: null", t => { - const room = getThreadRoomFromThreadEvent(null) - t.equal(room, null) -}) - -test("getThreadRoomFromThreadEvent: undefined", t => { - const room = getThreadRoomFromThreadEvent(undefined) - t.equal(room, undefined) -}) - -test("getThreadRoomFromThreadEvent: no value at all", t => { - const room = getThreadRoomFromThreadEvent() //This line should be giving a type-error, so it's not @ts-ignored on purpose. This is to test the desired behavior of that function, ie. „it CAN TAKE an undefined VALUE (as tested above), but you can just LEAVE the value completely undefined” (well, you can leave it like that from JS syntax perspective (which is why this test passes), but it makes no sense from usage standpoint, as it just gives back undefined). So this isn't a logic test (that's handled above), as much as it is a TypeScript test. - t.equal(room, undefined) -}) - module.exports.mockGetEffectivePower = mockGetEffectivePower