2021-09-22 12:59:11 -04:00
|
|
|
import config from "../../src/config";
|
|
|
|
import { newTestUser, noticeListener } from "./clientHelper"
|
|
|
|
|
2021-10-07 08:42:08 -04:00
|
|
|
describe("Test: !help command", () => {
|
2021-09-22 12:59:11 -04:00
|
|
|
let client;
|
|
|
|
before(async function () {
|
|
|
|
client = await newTestUser(true);
|
|
|
|
await client.start();
|
|
|
|
})
|
|
|
|
it('Mjolnir responded to !mjolnir help', async function() {
|
|
|
|
this.timeout(30000);
|
2021-09-23 11:12:08 -04:00
|
|
|
console.log(`management room ${config.managementRoom}`);
|
2021-09-22 12:59:11 -04:00
|
|
|
// send a messgage
|
|
|
|
await client.joinRoom(config.managementRoom);
|
|
|
|
// listener for getting the event reply
|
|
|
|
let reply = new Promise((resolve, reject) => {
|
|
|
|
client.on('room.message', noticeListener(config.managementRoom, (event) => {
|
|
|
|
if (event.content.body.includes("Print status information")) {
|
|
|
|
resolve(event);
|
|
|
|
}
|
|
|
|
}))});
|
|
|
|
// check we get one back
|
2021-09-23 11:12:08 -04:00
|
|
|
console.log(config);
|
2021-09-22 12:59:11 -04:00
|
|
|
await client.sendMessage(config.managementRoom, {msgtype: "m.text", body: "!mjolnir help"})
|
|
|
|
await reply
|
|
|
|
})
|
|
|
|
after(async function () {
|
|
|
|
await client.stop();
|
|
|
|
})
|
|
|
|
})
|