refactor: improve testing setup
This commit is contained in:
parent
0c8f1e8bda
commit
de060b381e
8 changed files with 48 additions and 30 deletions
27
spec/setup.ts
Normal file
27
spec/setup.ts
Normal 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();
|
Loading…
Add table
Add a link
Reference in a new issue