diff --git a/package.json b/package.json index 174f8bd..2ab9a2a 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "private": true, "scripts": { "build": "tsc", + "postbuild": "rm -rf lib/test/ && cp -r lib/src/* lib/ && rm -rf lib/src/", "lint": "tslint --project ./tsconfig.json -t stylish", "start:dev": "yarn build && node --async-stack-traces lib/index.js", "test": "ts-mocha --project ./tsconfig.json test/commands/**/*.ts", diff --git a/test/integration/clientHelper.ts b/test/integration/clientHelper.ts index bf6902f..7b38900 100644 --- a/test/integration/clientHelper.ts +++ b/test/integration/clientHelper.ts @@ -19,7 +19,7 @@ const REGISTRATION_RETRY_BASE_DELAY_MS = 100; export async function registerUser(username: string, displayname: string, password: string, admin: boolean): Promise { let registerUrl = `${config.homeserverUrl}/_synapse/admin/v1/register` const data: {nonce: string} = await new Promise((resolve, reject) => { - getRequestFn()({uri: registerUrl, method: "GET", timeout: 60000}, (error, response, resBody) => { + getRequestFn()({uri: registerUrl, method: "GET", timeout: 60000}, (error: any, response: any, resBody: any) => { error ? reject(error) : resolve(JSON.parse(resBody)) }); }); @@ -42,7 +42,7 @@ export async function registerUser(username: string, displayname: string, passwo timeout: 60000 } return await new Promise((resolve, reject) => { - getRequestFn()(params, error => error ? reject(error) : resolve()); + getRequestFn()(params, (error: any) => error ? reject(error) : resolve()); }); } catch (ex) { // In case of timeout or throttling, backoff and retry. @@ -79,7 +79,7 @@ export type RegistrationOptions = { /** * Register a new test user. * - * @returns A string that is both the username and password of a new user. + * @returns A string that is both the username and password of a new user. */ async function registerNewTestUser(options: RegistrationOptions) { do { @@ -174,8 +174,8 @@ export async function resetRatelimitForUser(userId: string) { * @param cb The callback when a m.notice event is found in targetRoomId. * @returns The callback to pass to `MatrixClient.on('room.message', cb)` */ -export function noticeListener(targetRoomdId: string, cb) { - return (roomId, event) => { +export function noticeListener(targetRoomdId: string, cb: (event: any) => void) { + return (roomId: string, event: any) => { if (roomId !== targetRoomdId) return; if (event?.content?.msgtype !== "m.notice") return; cb(event); diff --git a/test/integration/mjolnirSetupUtils.ts b/test/integration/mjolnirSetupUtils.ts index bf7c924..2a4939b 100644 --- a/test/integration/mjolnirSetupUtils.ts +++ b/test/integration/mjolnirSetupUtils.ts @@ -82,10 +82,10 @@ export async function makeMjolnir(): Promise { await overrideRatelimitForUser(await client.getUserId()); patchMatrixClient(); await ensureAliasedRoomExists(client, config.managementRoom); - let mjolnir = await Mjolnir.setupMjolnirFromConfig(client); + let mj = await Mjolnir.setupMjolnirFromConfig(client); globalClient = client; - globalMjolnir = mjolnir; - return mjolnir; + globalMjolnir = mj; + return mj; } /** diff --git a/tsconfig.json b/tsconfig.json index 79ca60a..a6e9d29 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -19,6 +19,7 @@ ] }, "include": [ - "./src/**/*" + "./src/**/*", + "./test/integration/manualLaunchScript.ts" ] }