Merge pull request #5228 from DayKev/add-eslint-promises-rule

[Test] Add eslint rule enforcing proper `await` usage in tests
This commit is contained in:
Sirz Benjie 2025-02-09 18:57:22 -06:00 committed by GitHub
commit c5968d52ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 97 additions and 90 deletions

View File

@ -5,6 +5,7 @@ import importX from 'eslint-plugin-import-x';
export default [ export default [
{ {
name: "eslint-config",
files: ["src/**/*.{ts,tsx,js,jsx}"], files: ["src/**/*.{ts,tsx,js,jsx}"],
ignores: ["dist/*", "build/*", "coverage/*", "public/*", ".github/*", "node_modules/*", ".vscode/*"], ignores: ["dist/*", "build/*", "coverage/*", "public/*", ".github/*", "node_modules/*", ".vscode/*"],
languageOptions: { languageOptions: {
@ -48,5 +49,22 @@ export default [
"no-multiple-empty-lines": ["error", { "max": 2, "maxEOF": 1, "maxBOF": 0 }], // Disallows multiple empty lines "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 "@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/
}
} }
] ]

View File

@ -53,11 +53,11 @@ describe("Abilities - Shield Dust", () => {
expect(move.id).toBe(Moves.AIR_SLASH); expect(move.id).toBe(Moves.AIR_SLASH);
const chance = new NumberHolder(move.chance); const chance = new NumberHolder(move.chance);
applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false); await applyAbAttrs(MoveEffectChanceMultiplierAbAttr, phase.getUserPokemon()!, null, false, chance, move, phase.getFirstTarget(), false);
applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getFirstTarget()!, phase.getUserPokemon()!, null, null, false, chance); await applyPreDefendAbAttrs(IgnoreMoveEffectsAbAttr, phase.getFirstTarget()!, phase.getUserPokemon()!, null, null, false, chance);
expect(chance.value).toBe(0); expect(chance.value).toBe(0);
}, 20000); });
//TODO King's Rock Interaction Unit Test //TODO King's Rock Interaction Unit Test
}); });

View File

@ -45,9 +45,9 @@ describe("Abilities - Unseen Fist", () => {
it( it(
"should not apply if the source has Long Reach", "should not apply if the source has Long Reach",
() => { async () => {
game.override.passiveAbility(Abilities.LONG_REACH); game.override.passiveAbility(Abilities.LONG_REACH);
testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, false); await testUnseenFistHitResult(game, Moves.QUICK_ATTACK, Moves.PROTECT, false);
} }
); );
@ -67,7 +67,7 @@ describe("Abilities - Unseen Fist", () => {
game.override.enemyLevel(1); game.override.enemyLevel(1);
game.override.moveset([ Moves.TACKLE ]); game.override.moveset([ Moves.TACKLE ]);
await game.startBattle(); await game.classicMode.startBattle();
const enemyPokemon = game.scene.getEnemyPokemon()!; const enemyPokemon = game.scene.getEnemyPokemon()!;
enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, enemyPokemon.id); enemyPokemon.addTag(BattlerTagType.SUBSTITUTE, 0, Moves.NONE, enemyPokemon.id);
@ -86,7 +86,7 @@ async function testUnseenFistHitResult(game: GameManager, attackMove: Moves, pro
game.override.moveset([ attackMove ]); game.override.moveset([ attackMove ]);
game.override.enemyMoveset([ protectMove, protectMove, protectMove, protectMove ]); game.override.enemyMoveset([ protectMove, protectMove, protectMove, protectMove ]);
await game.startBattle(); await game.classicMode.startBattle();
const leadPokemon = game.scene.getPlayerPokemon()!; const leadPokemon = game.scene.getPlayerPokemon()!;
expect(leadPokemon).not.toBe(undefined); expect(leadPokemon).not.toBe(undefined);

View File

@ -20,8 +20,8 @@ const pokemonName = "PKM";
const sourceText = "SOURCE"; const sourceText = "SOURCE";
describe("Status Effect Messages", () => { describe("Status Effect Messages", () => {
beforeAll(() => { beforeAll(async () => {
i18next.init(); await i18next.init();
}); });
describe("NONE", () => { describe("NONE", () => {

View File

@ -40,10 +40,10 @@ describe("Evolution", () => {
eevee.abilityIndex = 2; eevee.abilityIndex = 2;
trapinch.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); 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); expect(trapinch.abilityIndex).toBe(1);
}); });
@ -55,10 +55,10 @@ describe("Evolution", () => {
bulbasaur.abilityIndex = 0; bulbasaur.abilityIndex = 0;
charmander.abilityIndex = 1; 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); 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); expect(charmander.abilityIndex).toBe(1);
}); });
@ -68,7 +68,7 @@ describe("Evolution", () => {
const squirtle = game.scene.getPlayerPokemon()!; const squirtle = game.scene.getPlayerPokemon()!;
squirtle.abilityIndex = 5; 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); expect(squirtle.abilityIndex).toBe(0);
}); });
@ -80,7 +80,7 @@ describe("Evolution", () => {
nincada.metBiome = -1; nincada.metBiome = -1;
nincada.gender = 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 ninjask = game.scene.getPlayerParty()[0];
const shedinja = game.scene.getPlayerParty()[1]; const shedinja = game.scene.getPlayerParty()[1];
expect(ninjask.abilityIndex).toBe(2); expect(ninjask.abilityIndex).toBe(2);

View File

@ -31,7 +31,7 @@ describe("Items - Light Ball", () => {
it("LIGHT_BALL activates in battle correctly", async() => { it("LIGHT_BALL activates in battle correctly", async() => {
game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "LIGHT_BALL" }]); game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "LIGHT_BALL" }]);
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([ await game.classicMode.startBattle([
Species.PIKACHU Species.PIKACHU
]); ]);
@ -64,7 +64,7 @@ describe("Items - Light Ball", () => {
}); });
it("LIGHT_BALL held by PIKACHU", async() => { it("LIGHT_BALL held by PIKACHU", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.PIKACHU Species.PIKACHU
]); ]);
@ -83,7 +83,7 @@ describe("Items - Light Ball", () => {
expect(spAtkValue.value / spAtkStat).toBe(1); expect(spAtkValue.value / spAtkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue);
@ -92,7 +92,7 @@ describe("Items - Light Ball", () => {
}, 20000); }, 20000);
it("LIGHT_BALL held by fused PIKACHU (base)", async() => { it("LIGHT_BALL held by fused PIKACHU (base)", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.PIKACHU, Species.PIKACHU,
Species.MAROWAK Species.MAROWAK
]); ]);
@ -122,7 +122,7 @@ describe("Items - Light Ball", () => {
expect(spAtkValue.value / spAtkStat).toBe(1); expect(spAtkValue.value / spAtkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue);
@ -161,7 +161,7 @@ describe("Items - Light Ball", () => {
expect(spAtkValue.value / spAtkStat).toBe(1); expect(spAtkValue.value / spAtkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue);
@ -189,7 +189,7 @@ describe("Items - Light Ball", () => {
expect(spAtkValue.value / spAtkStat).toBe(1); expect(spAtkValue.value / spAtkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "LIGHT_BALL" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPATK, spAtkValue);

View File

@ -31,7 +31,7 @@ describe("Items - Metal Powder", () => {
it("METAL_POWDER activates in battle correctly", async() => { it("METAL_POWDER activates in battle correctly", async() => {
game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "METAL_POWDER" }]); game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "METAL_POWDER" }]);
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([ await game.classicMode.startBattle([
Species.DITTO Species.DITTO
]); ]);
@ -79,7 +79,7 @@ describe("Items - Metal Powder", () => {
expect(defValue.value / defStat).toBe(1); expect(defValue.value / defStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
expect(defValue.value / defStat).toBe(2); expect(defValue.value / defStat).toBe(2);
@ -112,7 +112,7 @@ describe("Items - Metal Powder", () => {
expect(defValue.value / defStat).toBe(1); expect(defValue.value / defStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
expect(defValue.value / defStat).toBe(2); expect(defValue.value / defStat).toBe(2);
@ -145,7 +145,7 @@ describe("Items - Metal Powder", () => {
expect(defValue.value / defStat).toBe(1); expect(defValue.value / defStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
expect(defValue.value / defStat).toBe(2); expect(defValue.value / defStat).toBe(2);
@ -167,7 +167,7 @@ describe("Items - Metal Powder", () => {
expect(defValue.value / defStat).toBe(1); expect(defValue.value / defStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "METAL_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.DEF, defValue);
expect(defValue.value / defStat).toBe(1); expect(defValue.value / defStat).toBe(1);

View File

@ -31,7 +31,7 @@ describe("Items - Quick Powder", () => {
it("QUICK_POWDER activates in battle correctly", async() => { it("QUICK_POWDER activates in battle correctly", async() => {
game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "QUICK_POWDER" }]); game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "QUICK_POWDER" }]);
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([ await game.classicMode.startBattle([
Species.DITTO Species.DITTO
]); ]);
@ -64,7 +64,7 @@ describe("Items - Quick Powder", () => {
}); });
it("QUICK_POWDER held by DITTO", async() => { it("QUICK_POWDER held by DITTO", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.DITTO Species.DITTO
]); ]);
@ -79,14 +79,14 @@ describe("Items - Quick Powder", () => {
expect(spdValue.value / spdStat).toBe(1); expect(spdValue.value / spdStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue);
expect(spdValue.value / spdStat).toBe(2); expect(spdValue.value / spdStat).toBe(2);
}, 20000); });
it("QUICK_POWDER held by fused DITTO (base)", async() => { it("QUICK_POWDER held by fused DITTO (base)", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.DITTO, Species.DITTO,
Species.MAROWAK Species.MAROWAK
]); ]);
@ -112,14 +112,14 @@ describe("Items - Quick Powder", () => {
expect(spdValue.value / spdStat).toBe(1); expect(spdValue.value / spdStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue);
expect(spdValue.value / spdStat).toBe(2); expect(spdValue.value / spdStat).toBe(2);
}, 20000); });
it("QUICK_POWDER held by fused DITTO (part)", async() => { it("QUICK_POWDER held by fused DITTO (part)", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.MAROWAK, Species.MAROWAK,
Species.DITTO Species.DITTO
]); ]);
@ -145,14 +145,14 @@ describe("Items - Quick Powder", () => {
expect(spdValue.value / spdStat).toBe(1); expect(spdValue.value / spdStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue);
expect(spdValue.value / spdStat).toBe(2); expect(spdValue.value / spdStat).toBe(2);
}, 20000); });
it("QUICK_POWDER not held by DITTO", async() => { it("QUICK_POWDER not held by DITTO", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.MAROWAK Species.MAROWAK
]); ]);
@ -167,9 +167,9 @@ describe("Items - Quick Powder", () => {
expect(spdValue.value / spdStat).toBe(1); expect(spdValue.value / spdStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "QUICK_POWDER" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.SPD, spdValue);
expect(spdValue.value / spdStat).toBe(1); expect(spdValue.value / spdStat).toBe(1);
}, 20000); });
}); });

View File

@ -31,7 +31,7 @@ describe("Items - Thick Club", () => {
it("THICK_CLUB activates in battle correctly", async() => { it("THICK_CLUB activates in battle correctly", async() => {
game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "THICK_CLUB" }]); game.override.startingHeldItems([{ name: "SPECIES_STAT_BOOSTER", type: "THICK_CLUB" }]);
const consoleSpy = vi.spyOn(console, "log"); const consoleSpy = vi.spyOn(console, "log");
await game.startBattle([ await game.classicMode.startBattle([
Species.CUBONE Species.CUBONE
]); ]);
@ -64,7 +64,7 @@ describe("Items - Thick Club", () => {
}); });
it("THICK_CLUB held by CUBONE", async() => { it("THICK_CLUB held by CUBONE", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.CUBONE Species.CUBONE
]); ]);
@ -79,14 +79,14 @@ describe("Items - Thick Club", () => {
expect(atkValue.value / atkStat).toBe(1); expect(atkValue.value / atkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
expect(atkValue.value / atkStat).toBe(2); expect(atkValue.value / atkStat).toBe(2);
}, 20000); });
it("THICK_CLUB held by MAROWAK", async() => { it("THICK_CLUB held by MAROWAK", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.MAROWAK Species.MAROWAK
]); ]);
@ -101,14 +101,14 @@ describe("Items - Thick Club", () => {
expect(atkValue.value / atkStat).toBe(1); expect(atkValue.value / atkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
expect(atkValue.value / atkStat).toBe(2); expect(atkValue.value / atkStat).toBe(2);
}, 20000); });
it("THICK_CLUB held by ALOLA_MAROWAK", async() => { it("THICK_CLUB held by ALOLA_MAROWAK", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.ALOLA_MAROWAK Species.ALOLA_MAROWAK
]); ]);
@ -123,18 +123,18 @@ describe("Items - Thick Club", () => {
expect(atkValue.value / atkStat).toBe(1); expect(atkValue.value / atkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
expect(atkValue.value / atkStat).toBe(2); expect(atkValue.value / atkStat).toBe(2);
}, 20000); });
it("THICK_CLUB held by fused CUBONE line (base)", async() => { it("THICK_CLUB held by fused CUBONE line (base)", async() => {
// Randomly choose from the Cubone line // Randomly choose from the Cubone line
const species = [ Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK ]; const species = [ Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK ];
const randSpecies = Utils.randInt(species.length); const randSpecies = Utils.randInt(species.length);
await game.startBattle([ await game.classicMode.startBattle([
species[randSpecies], species[randSpecies],
Species.PIKACHU Species.PIKACHU
]); ]);
@ -160,18 +160,18 @@ describe("Items - Thick Club", () => {
expect(atkValue.value / atkStat).toBe(1); expect(atkValue.value / atkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
expect(atkValue.value / atkStat).toBe(2); expect(atkValue.value / atkStat).toBe(2);
}, 20000); });
it("THICK_CLUB held by fused CUBONE line (part)", async() => { it("THICK_CLUB held by fused CUBONE line (part)", async() => {
// Randomly choose from the Cubone line // Randomly choose from the Cubone line
const species = [ Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK ]; const species = [ Species.CUBONE, Species.MAROWAK, Species.ALOLA_MAROWAK ];
const randSpecies = Utils.randInt(species.length); const randSpecies = Utils.randInt(species.length);
await game.startBattle([ await game.classicMode.startBattle([
Species.PIKACHU, Species.PIKACHU,
species[randSpecies] species[randSpecies]
]); ]);
@ -197,14 +197,14 @@ describe("Items - Thick Club", () => {
expect(atkValue.value / atkStat).toBe(1); expect(atkValue.value / atkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
expect(atkValue.value / atkStat).toBe(2); expect(atkValue.value / atkStat).toBe(2);
}, 20000); });
it("THICK_CLUB not held by CUBONE", async() => { it("THICK_CLUB not held by CUBONE", async() => {
await game.startBattle([ await game.classicMode.startBattle([
Species.PIKACHU Species.PIKACHU
]); ]);
@ -219,9 +219,9 @@ describe("Items - Thick Club", () => {
expect(atkValue.value / atkStat).toBe(1); expect(atkValue.value / atkStat).toBe(1);
// Giving Eviolite to party member and testing if it applies // Giving Eviolite to party member and testing if it applies
game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true); await game.scene.addModifier(modifierTypes.SPECIES_STAT_BOOSTER().generateType([], [ "THICK_CLUB" ])!.newModifier(partyMember), true);
game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue); game.scene.applyModifiers(SpeciesStatBoosterModifier, true, partyMember, Stat.ATK, atkValue);
expect(atkValue.value / atkStat).toBe(1); expect(atkValue.value / atkStat).toBe(1);
}, 20000); });
}); });

View File

@ -45,14 +45,10 @@ describe("Moves - Dragon Rage", () => {
game.override.enemyPassiveAbility(Abilities.BALL_FETCH); game.override.enemyPassiveAbility(Abilities.BALL_FETCH);
game.override.enemyLevel(100); game.override.enemyLevel(100);
await game.startBattle(); await game.classicMode.startBattle();
partyPokemon = game.scene.getPlayerParty()[0]; partyPokemon = game.scene.getPlayerParty()[0];
enemyPokemon = game.scene.getEnemyPokemon()!; enemyPokemon = game.scene.getEnemyPokemon()!;
// remove berries
game.scene.removePartyMemberModifiers(0);
game.scene.clearEnemyHeldItemModifiers();
}); });
it("ignores weaknesses", async () => { it("ignores weaknesses", async () => {

View File

@ -41,14 +41,10 @@ describe("Moves - Fissure", () => {
game.override.enemyPassiveAbility(Abilities.BALL_FETCH); game.override.enemyPassiveAbility(Abilities.BALL_FETCH);
game.override.enemyLevel(100); game.override.enemyLevel(100);
await game.startBattle(); await game.classicMode.startBattle();
partyPokemon = game.scene.getPlayerParty()[0]; partyPokemon = game.scene.getPlayerParty()[0];
enemyPokemon = game.scene.getEnemyPokemon()!; enemyPokemon = game.scene.getEnemyPokemon()!;
// remove berries
game.scene.removePartyMemberModifiers(0);
game.scene.clearEnemyHeldItemModifiers();
}); });
it("ignores damage modification from abilities, for example FUR_COAT", async () => { it("ignores damage modification from abilities, for example FUR_COAT", async () => {

View File

@ -132,7 +132,7 @@ describe("Moves - Toxic Spikes", () => {
const sessionData : SessionSaveData = gameData["getSessionSaveData"](); const sessionData : SessionSaveData = gameData["getSessionSaveData"]();
localStorage.setItem("sessionTestData", encrypt(JSON.stringify(sessionData), true)); localStorage.setItem("sessionTestData", encrypt(JSON.stringify(sessionData), true));
const recoveredData : SessionSaveData = gameData.parseSessionData(decrypt(localStorage.getItem("sessionTestData")!, true)); const recoveredData : SessionSaveData = gameData.parseSessionData(decrypt(localStorage.getItem("sessionTestData")!, true));
gameData.loadSession(0, recoveredData); await gameData.loadSession(0, recoveredData);
expect(sessionData.arena.tags).toEqual(recoveredData.arena.tags); expect(sessionData.arena.tags).toEqual(recoveredData.arena.tags);
localStorage.removeItem("sessionTestData"); localStorage.removeItem("sessionTestData");

View File

@ -48,12 +48,12 @@ describe("Mystery Encounter Utils", () => {
expect(result.species.speciesId).toBe(Species.ARCEUS); expect(result.species.speciesId).toBe(Species.ARCEUS);
}); });
it("gets a fainted pokemon from player party if isAllowedInBattle is false", () => { it("gets a fainted pokemon from player party if isAllowedInBattle is false", async () => {
// Both pokemon fainted // Both pokemon fainted
scene.getPlayerParty().forEach(p => { scene.getPlayerParty().forEach(p => {
p.hp = 0; p.hp = 0;
p.trySetStatus(StatusEffect.FAINT); p.trySetStatus(StatusEffect.FAINT);
p.updateInfo(); void p.updateInfo();
}); });
// Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal) // Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal)
@ -68,12 +68,12 @@ describe("Mystery Encounter Utils", () => {
expect(result.species.speciesId).toBe(Species.ARCEUS); expect(result.species.speciesId).toBe(Species.ARCEUS);
}); });
it("gets an unfainted legal pokemon from player party if isAllowed is true and isFainted is false", () => { it("gets an unfainted legal pokemon from player party if isAllowed is true and isFainted is false", async () => {
// Only faint 1st pokemon // Only faint 1st pokemon
const party = scene.getPlayerParty(); const party = scene.getPlayerParty();
party[0].hp = 0; party[0].hp = 0;
party[0].trySetStatus(StatusEffect.FAINT); party[0].trySetStatus(StatusEffect.FAINT);
party[0].updateInfo(); await party[0].updateInfo();
// Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal) // Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal)
game.override.seed("random"); game.override.seed("random");
@ -87,12 +87,12 @@ describe("Mystery Encounter Utils", () => {
expect(result.species.speciesId).toBe(Species.MANAPHY); expect(result.species.speciesId).toBe(Species.MANAPHY);
}); });
it("returns last unfainted pokemon if doNotReturnLastAbleMon is false", () => { it("returns last unfainted pokemon if doNotReturnLastAbleMon is false", async () => {
// Only faint 1st pokemon // Only faint 1st pokemon
const party = scene.getPlayerParty(); const party = scene.getPlayerParty();
party[0].hp = 0; party[0].hp = 0;
party[0].trySetStatus(StatusEffect.FAINT); party[0].trySetStatus(StatusEffect.FAINT);
party[0].updateInfo(); await party[0].updateInfo();
// Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal) // Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal)
game.override.seed("random"); game.override.seed("random");
@ -106,12 +106,12 @@ describe("Mystery Encounter Utils", () => {
expect(result.species.speciesId).toBe(Species.MANAPHY); expect(result.species.speciesId).toBe(Species.MANAPHY);
}); });
it("never returns last unfainted pokemon if doNotReturnLastAbleMon is true", () => { it("never returns last unfainted pokemon if doNotReturnLastAbleMon is true", async () => {
// Only faint 1st pokemon // Only faint 1st pokemon
const party = scene.getPlayerParty(); const party = scene.getPlayerParty();
party[0].hp = 0; party[0].hp = 0;
party[0].trySetStatus(StatusEffect.FAINT); party[0].trySetStatus(StatusEffect.FAINT);
party[0].updateInfo(); await party[0].updateInfo();
// Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal) // Seeds are calculated to return index 0 first, 1 second (if both pokemon are legal)
game.override.seed("random"); game.override.seed("random");
@ -152,12 +152,12 @@ describe("Mystery Encounter Utils", () => {
expect(result.species.speciesId).toBe(Species.ARCEUS); expect(result.species.speciesId).toBe(Species.ARCEUS);
}); });
it("returns highest level unfainted if unfainted is true", () => { it("returns highest level unfainted if unfainted is true", async () => {
const party = scene.getPlayerParty(); const party = scene.getPlayerParty();
party[0].level = 100; party[0].level = 100;
party[0].hp = 0; party[0].hp = 0;
party[0].trySetStatus(StatusEffect.FAINT); party[0].trySetStatus(StatusEffect.FAINT);
party[0].updateInfo(); await party[0].updateInfo();
party[1].level = 10; party[1].level = 10;
const result = getHighestLevelPlayerPokemon(true); const result = getHighestLevelPlayerPokemon(true);
@ -191,12 +191,12 @@ describe("Mystery Encounter Utils", () => {
expect(result.species.speciesId).toBe(Species.ARCEUS); expect(result.species.speciesId).toBe(Species.ARCEUS);
}); });
it("returns lowest level unfainted if unfainted is true", () => { it("returns lowest level unfainted if unfainted is true", async () => {
const party = scene.getPlayerParty(); const party = scene.getPlayerParty();
party[0].level = 10; party[0].level = 10;
party[0].hp = 0; party[0].hp = 0;
party[0].trySetStatus(StatusEffect.FAINT); party[0].trySetStatus(StatusEffect.FAINT);
party[0].updateInfo(); await party[0].updateInfo();
party[1].level = 100; party[1].level = 100;
const result = getLowestLevelPlayerPokemon(true); const result = getLowestLevelPlayerPokemon(true);

View File

@ -2,8 +2,6 @@ import { BerryType } from "#app/enums/berry-type";
import { Button } from "#app/enums/buttons"; import { Button } from "#app/enums/buttons";
import { Moves } from "#app/enums/moves"; import { Moves } from "#app/enums/moves";
import { Species } from "#app/enums/species"; import { Species } from "#app/enums/species";
import { BattleEndPhase } from "#app/phases/battle-end-phase";
import { SelectModifierPhase } from "#app/phases/select-modifier-phase";
import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler"; import ModifierSelectUiHandler from "#app/ui/modifier-select-ui-handler";
import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler"; import PartyUiHandler, { PartyUiMode } from "#app/ui/party-ui-handler";
import { Mode } from "#app/ui/ui"; import { Mode } from "#app/ui/ui";
@ -12,7 +10,6 @@ import Phaser from "phaser";
import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext"; import type BBCodeText from "phaser3-rex-plugins/plugins/bbcodetext";
import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest"; import { afterEach, beforeAll, beforeEach, describe, expect, it } from "vitest";
describe("UI - Transfer Items", () => { describe("UI - Transfer Items", () => {
let phaserGame: Phaser.Game; let phaserGame: Phaser.Game;
let game: GameManager; let game: GameManager;
@ -41,7 +38,7 @@ describe("UI - Transfer Items", () => {
game.override.enemySpecies(Species.MAGIKARP); game.override.enemySpecies(Species.MAGIKARP);
game.override.enemyMoveset([ Moves.SPLASH ]); game.override.enemyMoveset([ Moves.SPLASH ]);
await game.startBattle([ Species.RAYQUAZA, Species.RAYQUAZA, Species.RAYQUAZA ]); await game.classicMode.startBattle([ Species.RAYQUAZA, Species.RAYQUAZA, Species.RAYQUAZA ]);
game.move.select(Moves.DRAGON_CLAW); game.move.select(Moves.DRAGON_CLAW);
@ -52,10 +49,10 @@ describe("UI - Transfer Items", () => {
handler.setCursor(1); handler.setCursor(1);
handler.processInput(Button.ACTION); handler.processInput(Button.ACTION);
game.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER); void game.scene.ui.setModeWithoutClear(Mode.PARTY, PartyUiMode.MODIFIER_TRANSFER);
}); });
await game.phaseInterceptor.to(BattleEndPhase); await game.phaseInterceptor.to("BattleEndPhase");
}); });
it("check red tint for held item limit in transfer menu", async () => { it("check red tint for held item limit in transfer menu", async () => {
@ -72,7 +69,7 @@ describe("UI - Transfer Items", () => {
game.phaseInterceptor.unlock(); game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.to(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
}, 20000); }, 20000);
it("check transfer option for pokemon to transfer to", async () => { it("check transfer option for pokemon to transfer to", async () => {
@ -91,6 +88,6 @@ describe("UI - Transfer Items", () => {
game.phaseInterceptor.unlock(); game.phaseInterceptor.unlock();
}); });
await game.phaseInterceptor.to(SelectModifierPhase); await game.phaseInterceptor.to("SelectModifierPhase");
}, 20000); }, 20000);
}); });