[Test] Add eslint rule enforcing proper `await` usage in tests
This commit is contained in:
parent
db37dcc204
commit
c2a7afc5ba
|
@ -5,6 +5,7 @@ import importX from 'eslint-plugin-import-x';
|
|||
|
||||
export default [
|
||||
{
|
||||
name: "eslint-config",
|
||||
files: ["src/**/*.{ts,tsx,js,jsx}"],
|
||||
ignores: ["dist/*", "build/*", "coverage/*", "public/*", ".github/*", "node_modules/*", ".vscode/*"],
|
||||
languageOptions: {
|
||||
|
@ -48,5 +49,22 @@ export default [
|
|||
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }], // Disallows multiple empty lines
|
||||
"@typescript-eslint/consistent-type-imports": "error", // Enforces type-only imports wherever possible
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "eslint-tests",
|
||||
files: ["src/test/**.test.ts"],
|
||||
languageOptions: {
|
||||
parser: parser,
|
||||
parserOptions: {
|
||||
"project": ["./tsconfig.json"]
|
||||
}
|
||||
},
|
||||
plugins: {
|
||||
"@typescript-eslint": tseslint
|
||||
},
|
||||
rules: {
|
||||
"@typescript-eslint/no-floating-promises": "error", // Require Promise-like statements to be handled appropriately. - https://typescript-eslint.io/rules/no-floating-promises/
|
||||
"@typescript-eslint/no-misused-promises": "error", // Disallow Promises in places not designed to handle them. - https://typescript-eslint.io/rules/no-misused-promises/
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -40,10 +40,10 @@ describe("Evolution", () => {
|
|||
eevee.abilityIndex = 2;
|
||||
trapinch.abilityIndex = 2;
|
||||
|
||||
eevee.evolve(pokemonEvolutions[Species.EEVEE][6], eevee.getSpeciesForm());
|
||||
await eevee.evolve(pokemonEvolutions[Species.EEVEE][6], eevee.getSpeciesForm());
|
||||
expect(eevee.abilityIndex).toBe(2);
|
||||
|
||||
trapinch.evolve(pokemonEvolutions[Species.TRAPINCH][0], trapinch.getSpeciesForm());
|
||||
await trapinch.evolve(pokemonEvolutions[Species.TRAPINCH][0], trapinch.getSpeciesForm());
|
||||
expect(trapinch.abilityIndex).toBe(1);
|
||||
});
|
||||
|
||||
|
@ -55,10 +55,10 @@ describe("Evolution", () => {
|
|||
bulbasaur.abilityIndex = 0;
|
||||
charmander.abilityIndex = 1;
|
||||
|
||||
bulbasaur.evolve(pokemonEvolutions[Species.BULBASAUR][0], bulbasaur.getSpeciesForm());
|
||||
await bulbasaur.evolve(pokemonEvolutions[Species.BULBASAUR][0], bulbasaur.getSpeciesForm());
|
||||
expect(bulbasaur.abilityIndex).toBe(0);
|
||||
|
||||
charmander.evolve(pokemonEvolutions[Species.CHARMANDER][0], charmander.getSpeciesForm());
|
||||
await charmander.evolve(pokemonEvolutions[Species.CHARMANDER][0], charmander.getSpeciesForm());
|
||||
expect(charmander.abilityIndex).toBe(1);
|
||||
});
|
||||
|
||||
|
@ -68,7 +68,7 @@ describe("Evolution", () => {
|
|||
const squirtle = game.scene.getPlayerPokemon()!;
|
||||
squirtle.abilityIndex = 5;
|
||||
|
||||
squirtle.evolve(pokemonEvolutions[Species.SQUIRTLE][0], squirtle.getSpeciesForm());
|
||||
await squirtle.evolve(pokemonEvolutions[Species.SQUIRTLE][0], squirtle.getSpeciesForm());
|
||||
expect(squirtle.abilityIndex).toBe(0);
|
||||
});
|
||||
|
||||
|
@ -80,7 +80,7 @@ describe("Evolution", () => {
|
|||
nincada.metBiome = -1;
|
||||
nincada.gender = 1;
|
||||
|
||||
nincada.evolve(pokemonEvolutions[Species.NINCADA][0], nincada.getSpeciesForm());
|
||||
await nincada.evolve(pokemonEvolutions[Species.NINCADA][0], nincada.getSpeciesForm());
|
||||
const ninjask = game.scene.getPlayerParty()[0];
|
||||
const shedinja = game.scene.getPlayerParty()[1];
|
||||
expect(ninjask.abilityIndex).toBe(2);
|
||||
|
|
Loading…
Reference in New Issue