hookshot/tests/AdminRoomTest.ts

30 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-11-22 21:31:39 +00:00
/* eslint-disable @typescript-eslint/no-explicit-any */
import { expect } from "chai";
import { AdminRoom } from "../src/AdminRoom";
2021-04-11 18:15:13 +01:00
import { NotifFilter } from "../src/NotificationFilters";
2020-11-22 21:31:39 +00:00
import { UserTokenStore } from "../src/UserTokenStore";
import { IntentMock } from "./utils/IntentMock";
const ROOM_ID = "!foo:bar";
function createAdminRoom(data: any = {admin_user: "@admin:bar"}): [AdminRoom, IntentMock] {
const intent = IntentMock.create();
if (!data.admin_user) {
data.admin_user = "@admin:bar";
}
const tokenStore = new UserTokenStore("notapath", intent);
2021-04-11 18:15:13 +01:00
return [new AdminRoom(ROOM_ID, data, NotifFilter.getDefaultContent(), intent, tokenStore, {} as any, ), intent];
2020-11-22 21:31:39 +00:00
}
describe("AdminRoom", () => {
it("will present help text", async () => {
const [adminRoom, intent] = createAdminRoom();
await adminRoom.handleCommand("$foo:bar", "help");
expect(intent.sentEvents).to.have.lengthOf(1);
expect(intent.sentEvents[0]).to.deep.equal({
roomId: ROOM_ID,
2021-11-17 14:22:44 +00:00
content: AdminRoom.helpMessage(),
2020-11-22 21:31:39 +00:00
});
});
})