Fix Toxic Orb test

This commit is contained in:
NightKev 2024-10-11 08:54:27 -07:00
parent d96289a2db
commit e42460b893

View File

@ -1,7 +1,4 @@
import { StatusEffect } from "#app/data/status-effect"; import { StatusEffect } from "#app/data/status-effect";
import { EnemyCommandPhase } from "#app/phases/enemy-command-phase";
import { MessagePhase } from "#app/phases/message-phase";
import { TurnEndPhase } from "#app/phases/turn-end-phase";
import i18next from "#app/plugins/i18n"; import i18next from "#app/plugins/i18n";
import { Abilities } from "#enums/abilities"; import { Abilities } from "#enums/abilities";
import { Moves } from "#enums/moves"; import { Moves } from "#enums/moves";
@ -27,40 +24,33 @@ describe("Items - Toxic orb", () => {
beforeEach(() => { beforeEach(() => {
game = new GameManager(phaserGame); game = new GameManager(phaserGame);
const moveToUse = Moves.GROWTH; game.override
const oppMoveToUse = Moves.TACKLE; .battleType("single")
game.override.battleType("single"); .enemySpecies(Species.MAGIKARP)
game.override.enemySpecies(Species.RATTATA); .ability(Abilities.BALL_FETCH)
game.override.ability(Abilities.INSOMNIA); .enemyAbility(Abilities.BALL_FETCH)
game.override.enemyAbility(Abilities.INSOMNIA); .moveset(Moves.SPLASH)
game.override.startingLevel(2000); .enemyMoveset(Moves.SPLASH)
game.override.moveset([ moveToUse ]); .startingHeldItems([{
game.override.enemyMoveset([ oppMoveToUse, oppMoveToUse, oppMoveToUse, oppMoveToUse ]); name: "TOXIC_ORB",
game.override.startingHeldItems([{ }]);
name: "TOXIC_ORB",
}]);
vi.spyOn(i18next, "t"); vi.spyOn(i18next, "t");
}); });
it("TOXIC ORB", async () => { it("should badly poison the holder", async () => {
const moveToUse = Moves.GROWTH; await game.classicMode.startBattle([ Species.FEEBAS ]);
await game.startBattle([
Species.MIGHTYENA,
Species.MIGHTYENA,
]);
expect(game.scene.modifiers[0].type.id).toBe("TOXIC_ORB");
game.move.select(moveToUse); const player = game.scene.getPlayerPokemon()!;
expect(player.getHeldItems()[0].type.id).toBe("TOXIC_ORB");
// will run the 13 phase from enemyCommandPhase to TurnEndPhase game.move.select(Moves.SPLASH);
await game.phaseInterceptor.runFrom(EnemyCommandPhase).to(TurnEndPhase); await game.phaseInterceptor.to("TurnEndPhase");
// Toxic orb should trigger here await game.phaseInterceptor.to("MessagePhase");
await game.phaseInterceptor.run(MessagePhase);
expect(i18next.t).toHaveBeenCalledWith("statusEffect:toxic.obtainSource", expect.anything()); expect(i18next.t).toHaveBeenCalledWith("statusEffect:toxic.obtainSource", expect.anything());
await game.phaseInterceptor.run(MessagePhase); await game.phaseInterceptor.to("MessagePhase");
expect(i18next.t).toHaveBeenCalledWith("statusEffect:toxic.activation", expect.anything()); expect(i18next.t).toHaveBeenCalledWith("statusEffect:toxic.activation", expect.anything());
expect(game.scene.getParty()[0].status!.effect).toBe(StatusEffect.TOXIC); expect(player.status?.effect).toBe(StatusEffect.TOXIC);
}, 20000); }, 20000);
}); });