2021-09-23 15:12:08 +00:00
|
|
|
import config from "../../src/config";
|
2021-09-22 16:59:11 +00:00
|
|
|
import { Mjolnir } from "../../src/Mjolnir";
|
2021-09-23 15:12:08 +00:00
|
|
|
import { makeMjolnir, teardownManagementRoom } from "./mjolnirSetupUtils";
|
2021-09-22 16:59:11 +00:00
|
|
|
|
2021-09-23 15:12:08 +00:00
|
|
|
// when mjolnir starts it clobbers the config, which is cached between runs,
|
|
|
|
// by resolving the alias and setting it to a roomid.
|
|
|
|
export const mochaHooks = {
|
|
|
|
beforeEach: [
|
|
|
|
async function() {
|
|
|
|
this.managementRoomAlias = config.managementRoom
|
|
|
|
this.mjolnir = await makeMjolnir()
|
|
|
|
this.mjolnir.start()
|
|
|
|
}
|
|
|
|
],
|
|
|
|
afterEach: [
|
|
|
|
async function() {
|
|
|
|
console.log("stopping mjolnir");
|
|
|
|
await this.mjolnir.stop();
|
|
|
|
// unclobber mjolnir's dirty work, i thought the config was being cached
|
|
|
|
// and was global, but that might have just been supersitiion, needs confirming.
|
|
|
|
let managementRoomId = config.managementRoom;
|
|
|
|
config.managementRoom = this.managementRoomAlias;
|
|
|
|
// remove alias from management room and leave it.
|
|
|
|
await teardownManagementRoom(this.mjolnir.client, managementRoomId, this.managementRoomAlias);
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|