Files
Draupnir/test/integration/utilsTest.ts
Aminda Suomalainen e4c02b96cd Add pre-commit configuration (#34)
* add .pre-commit-config.yaml

Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>

* .editorconfig: decrease indent size for text

* .pre-commit-config.yaml: remove prettier

Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>

* .editorconfig consistency.

* .pre-commit-config.yaml: restore sample hooks

* .editorconfig: disable indent_size for LICENSE & NOTICE

* pre-commit run --all-files

* tsconfig.json: tabs to spaces

* .pre-commit-config.yaml: update editorconfig-checker to 2.7.2

* .editorconfig: disable indent_size for markdown

* mjolnir-entrypoint.sh: retab

* .editorconfig: also exclude json from indent checking

* test/nginx.conf: retab

* test/integration/commands/redactCommandTest.ts: remove leading space

* retab or remove leading whitespaces for the rest of the files

* src/appservice/datastore.ts remove newlines

* test/integration/commands/roomTest.ts: remove leading space.

---------

Signed-off-by: Aminda Suomalainen <suomalainen+git@mikaela.info>
Co-authored-by: gnuxie <Gnuxie@protonmail.com>
2023-08-29 13:38:00 +01:00

34 lines
1.4 KiB
TypeScript

import { strict as assert } from "assert";
import { LogLevel } from "matrix-bot-sdk";
import ManagementRoomOutput from "../../src/ManagementRoomOutput";
describe("Test: utils", function() {
it("replaceRoomIdsWithPills correctly turns a room ID in to a pill", async function() {
const managementRoomAlias = this.config.managementRoom;
const managementRoomOutput: ManagementRoomOutput = this.mjolnir.managementRoomOutput;
await this.mjolnir.client.sendStateEvent(
this.mjolnir.managementRoomId,
"m.room.canonical_alias",
"",
{ alias: managementRoomAlias }
);
const message: any = await new Promise(async resolve => {
this.mjolnir.client.on('room.message', (roomId, event) => {
if (roomId === this.mjolnir.managementRoomId) {
if (event.content?.body?.startsWith("it's")) {
resolve(event);
}
}
})
await managementRoomOutput.logMessage(LogLevel.INFO, 'replaceRoomIdsWithPills test',
`it's fun here in ${this.mjolnir.managementRoomId}`,
[this.mjolnir.managementRoomId, "!myfaketestid:example.com"]);
});
assert.equal(
message.content.formatted_body,
`it's fun here in <a href="https://matrix.to/#/${encodeURIComponent(managementRoomAlias)}">${managementRoomAlias}</a>`
);
});
});