refactor: improve testing setup

This commit is contained in:
Johannes Loher 2022-02-13 18:34:03 +01:00
parent 0c8f1e8bda
commit de060b381e
8 changed files with 48 additions and 30 deletions

27
spec/setup.ts Normal file
View file

@ -0,0 +1,27 @@
// SPDX-FileCopyrightText: 2022 Johannes Loher
//
// SPDX-License-Identifier: MIT
import en from "../lang/en.json";
function setupStubs() {
class StubGame {
constructor() {
this.i18n = {
localize: (key: string) => (key in en ? en[key as keyof typeof en] : key),
};
}
i18n: {
localize: (key: string) => string;
};
}
const game = new StubGame();
Object.defineProperties(globalThis, {
game: { value: game },
Game: { value: StubGame },
});
}
setupStubs();