From 08f2866998e3255be01292317454fd4eb9bcc4cb Mon Sep 17 00:00:00 2001 From: flx-sta <50131232+flx-sta@users.noreply.github.com> Date: Thu, 19 Sep 2024 11:36:45 -0700 Subject: [PATCH] remove localization tests we don't need to test if i18next is working. This is the job of i18next itself --- src/test/localization/french.test.ts | 42 --- src/test/localization/status-effect.test.ts | 293 -------------------- src/test/localization/terrain.test.ts | 191 ------------- 3 files changed, 526 deletions(-) delete mode 100644 src/test/localization/french.test.ts delete mode 100644 src/test/localization/status-effect.test.ts delete mode 100644 src/test/localization/terrain.test.ts diff --git a/src/test/localization/french.test.ts b/src/test/localization/french.test.ts deleted file mode 100644 index 92b4c82d7cb..00000000000 --- a/src/test/localization/french.test.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { initI18n } from "#app/plugins/i18n"; -import { Species } from "#enums/species"; -import GameManager from "#test/utils/gameManager"; -import i18next from "i18next"; -import Phaser from "phaser"; -import { afterEach, beforeAll, describe, expect, it } from "vitest"; - -describe("Lokalization - french", () => { - let phaserGame: Phaser.Game; - let game: GameManager; - - beforeAll(() => { - initI18n(); - phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS, - }); - }); - - afterEach(() => { - game.phaseInterceptor.restoreOg(); - }); - - it("test bulbasaur name english", async () => { - game = new GameManager(phaserGame); - await game.startBattle([ - Species.BULBASAUR, - ]); - expect(game.scene.getParty()[0].name).toBe("Bulbasaur"); - }, 20000); - - it("test bulbasaure name french", async () => { - const locale = "fr"; - i18next.changeLanguage(locale); - localStorage.setItem("prLang", locale); - game = new GameManager(phaserGame); - - await game.startBattle([ - Species.BULBASAUR, - ]); - expect(game.scene.getParty()[0].name).toBe("Bulbizarre"); - }, 20000); -}); diff --git a/src/test/localization/status-effect.test.ts b/src/test/localization/status-effect.test.ts deleted file mode 100644 index 9dcab5aeb5f..00000000000 --- a/src/test/localization/status-effect.test.ts +++ /dev/null @@ -1,293 +0,0 @@ -import { StatusEffect, getStatusEffectActivationText, getStatusEffectDescriptor, getStatusEffectHealText, getStatusEffectObtainText, getStatusEffectOverlapText } from "#app/data/status-effect"; -import { mockI18next } from "#test/utils/testUtils"; -import i18next from "i18next"; -import { afterEach, beforeAll, describe, expect, it, vi } from "vitest"; - -const pokemonName = "PKM"; -const sourceText = "SOURCE"; - -describe("status-effect", () => { - beforeAll(() => { - i18next.init(); - }); - - describe("NONE", () => { - const statusEffect = StatusEffect.NONE; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:none.obtain"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).toBe("statusEffect:none.obtain"); - }); - - it("should return the source-obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName, sourceText); - expect(text).toBe("statusEffect:none.obtainSource"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).not.toBe("statusEffect:none.obtainSource"); - }); - - it("should return the activation text", () => { - mockI18next(); - const text = getStatusEffectActivationText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:none.activation"); - }); - - it("should return the overlap text", () => { - mockI18next(); - const text = getStatusEffectOverlapText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:none.overlap"); - }); - - it("should return the heal text", () => { - mockI18next(); - const text = getStatusEffectHealText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:none.heal"); - }); - - it("should return the descriptor", () => { - mockI18next(); - const text = getStatusEffectDescriptor(statusEffect); - expect(text).toBe("statusEffect:none.description"); - }); - }); - - describe("POISON", () => { - const statusEffect = StatusEffect.POISON; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:poison.obtain"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).toBe("statusEffect:poison.obtain"); - }); - - it("should return the activation text", () => { - mockI18next(); - const text = getStatusEffectActivationText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:poison.activation"); - }); - - it("should return the descriptor", () => { - mockI18next(); - const text = getStatusEffectDescriptor(statusEffect); - expect(text).toBe("statusEffect:poison.description"); - }); - - it("should return the heal text", () => { - mockI18next(); - const text = getStatusEffectHealText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:poison.heal"); - }); - - it("should return the overlap text", () => { - mockI18next(); - const text = getStatusEffectOverlapText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:poison.overlap"); - }); - }); - - describe("TOXIC", () => { - const statusEffect = StatusEffect.TOXIC; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:toxic.obtain"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).toBe("statusEffect:toxic.obtain"); - }); - - it("should return the activation text", () => { - mockI18next(); - const text = getStatusEffectActivationText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:toxic.activation"); - }); - - it("should return the descriptor", () => { - mockI18next(); - const text = getStatusEffectDescriptor(statusEffect); - expect(text).toBe("statusEffect:toxic.description"); - }); - - it("should return the heal text", () => { - mockI18next(); - const text = getStatusEffectHealText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:toxic.heal"); - }); - - it("should return the overlap text", () => { - mockI18next(); - const text = getStatusEffectOverlapText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:toxic.overlap"); - }); - }); - - describe("PARALYSIS", () => { - const statusEffect = StatusEffect.PARALYSIS; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:paralysis.obtain"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).toBe("statusEffect:paralysis.obtain"); - }); - - it("should return the activation text", () => { - mockI18next(); - const text = getStatusEffectActivationText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:paralysis.activation"); - }); - - it("should return the descriptor", () => { - mockI18next(); - const text = getStatusEffectDescriptor(statusEffect); - expect(text).toBe("statusEffect:paralysis.description"); - }); - - it("should return the heal text", () => { - mockI18next(); - const text = getStatusEffectHealText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:paralysis.heal"); - }); - - it("should return the overlap text", () => { - mockI18next(); - const text = getStatusEffectOverlapText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:paralysis.overlap"); - }); - }); - - describe("SLEEP", () => { - const statusEffect = StatusEffect.SLEEP; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:sleep.obtain"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).toBe("statusEffect:sleep.obtain"); - }); - - it("should return the activation text", () => { - mockI18next(); - const text = getStatusEffectActivationText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:sleep.activation"); - }); - - it("should return the descriptor", () => { - mockI18next(); - const text = getStatusEffectDescriptor(statusEffect); - expect(text).toBe("statusEffect:sleep.description"); - }); - - it("should return the heal text", () => { - mockI18next(); - const text = getStatusEffectHealText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:sleep.heal"); - }); - - it("should return the overlap text", () => { - mockI18next(); - const text = getStatusEffectOverlapText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:sleep.overlap"); - }); - }); - - describe("FREEZE", () => { - const statusEffect = StatusEffect.FREEZE; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:freeze.obtain"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).toBe("statusEffect:freeze.obtain"); - }); - - it("should return the activation text", () => { - mockI18next(); - const text = getStatusEffectActivationText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:freeze.activation"); - }); - - it("should return the descriptor", () => { - mockI18next(); - const text = getStatusEffectDescriptor(statusEffect); - expect(text).toBe("statusEffect:freeze.description"); - }); - - it("should return the heal text", () => { - mockI18next(); - const text = getStatusEffectHealText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:freeze.heal"); - }); - - it("should return the overlap text", () => { - mockI18next(); - const text = getStatusEffectOverlapText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:freeze.overlap"); - }); - }); - - describe("BURN", () => { - const statusEffect = StatusEffect.BURN; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getStatusEffectObtainText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:burn.obtain"); - - const emptySourceText = getStatusEffectObtainText(statusEffect, pokemonName, ""); - expect(emptySourceText).toBe("statusEffect:burn.obtain"); - }); - - it("should return the activation text", () => { - mockI18next(); - const text = getStatusEffectActivationText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:burn.activation"); - }); - - it("should return the descriptor", () => { - mockI18next(); - const text = getStatusEffectDescriptor(statusEffect); - expect(text).toBe("statusEffect:burn.description"); - }); - - it("should return the heal text", () => { - mockI18next(); - const text = getStatusEffectHealText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:burn.heal"); - }); - - it("should return the overlap text", () => { - mockI18next(); - const text = getStatusEffectOverlapText(statusEffect, pokemonName); - expect(text).toBe("statusEffect:burn.overlap"); - }); - }); - - afterEach(() => { - vi.resetAllMocks(); - }); -}); diff --git a/src/test/localization/terrain.test.ts b/src/test/localization/terrain.test.ts deleted file mode 100644 index ed280177a06..00000000000 --- a/src/test/localization/terrain.test.ts +++ /dev/null @@ -1,191 +0,0 @@ -import { TerrainType, getTerrainName } from "#app/data/terrain"; -import { getTerrainBlockMessage, getTerrainClearMessage, getTerrainStartMessage } from "#app/data/weather"; -import { Species } from "#enums/species"; -import GameManager from "#test/utils/gameManager"; -import { mockI18next } from "#test/utils/testUtils"; -import i18next from "i18next"; -import Phaser from "phaser"; -import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; - -describe("terrain", () => { - let phaserGame: Phaser.Game; - let game: GameManager; - - beforeAll(() => { - phaserGame = new Phaser.Game({ - type: Phaser.HEADLESS, - }); - i18next.init(); - }); - - beforeEach(() => { - game = new GameManager(phaserGame); - game.override.battleType("single"); - }); - - describe("NONE", () => { - const terrainType = TerrainType.NONE; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getTerrainName(terrainType); - expect(text).toBe(""); - }); - - it("should return the start text", () => { - mockI18next(); - - const text = getTerrainStartMessage(terrainType); - expect(text).toBeNull(); - }); - - it("should return the clear text", () => { - mockI18next(); - const text = getTerrainClearMessage(terrainType); - expect(text).toBeNull(); - }); - - it("should return the block text", async () => { - await game.startBattle([Species.MAGIKARP]); - const pokemon = game.scene.getPlayerPokemon()!; - mockI18next(); - const text = getTerrainBlockMessage(pokemon, terrainType); - expect(text).toBe("terrain:defaultBlockMessage"); - }); - }); - - describe("MISTY", () => { - const terrainType = TerrainType.MISTY; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getTerrainName(terrainType); - expect(text).toBe("terrain:misty"); - }); - - it("should return the start text", () => { - mockI18next(); - - const text = getTerrainStartMessage(terrainType); - expect(text).toBe("terrain:mistyStartMessage"); - }); - - it("should return the clear text", () => { - mockI18next(); - const text = getTerrainClearMessage(terrainType); - expect(text).toBe("terrain:mistyClearMessage"); - }); - - it("should return the block text", async () => { - await game.startBattle([Species.MAGIKARP]); - const pokemon = game.scene.getPlayerPokemon()!; - mockI18next(); - const text = getTerrainBlockMessage(pokemon, terrainType); - expect(text).toBe("terrain:mistyBlockMessage"); - }); - }); - - describe("ELECTRIC", () => { - const terrainType = TerrainType.ELECTRIC; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getTerrainName(terrainType); - expect(text).toBe("terrain:electric"); - }); - - it("should return the start text", () => { - mockI18next(); - - const text = getTerrainStartMessage(terrainType); - expect(text).toBe("terrain:electricStartMessage"); - }); - - it("should return the clear text", () => { - mockI18next(); - const text = getTerrainClearMessage(terrainType); - expect(text).toBe("terrain:electricClearMessage"); - }); - - it("should return the block text", async () => { - await game.startBattle([Species.MAGIKARP]); - const pokemon = game.scene.getPlayerPokemon()!; - mockI18next(); - const text = getTerrainBlockMessage(pokemon, terrainType); - expect(text).toBe("terrain:defaultBlockMessage"); - }); - }); - - describe("GRASSY", () => { - const terrainType = TerrainType.GRASSY; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getTerrainName(terrainType); - expect(text).toBe("terrain:grassy"); - }); - - it("should return the start text", () => { - mockI18next(); - - const text = getTerrainStartMessage(terrainType); - expect(text).toBe("terrain:grassyStartMessage"); - }); - - it("should return the clear text", () => { - mockI18next(); - const text = getTerrainClearMessage(terrainType); - expect(text).toBe("terrain:grassyClearMessage"); - }); - - it("should return the block text", async () => { - await game.startBattle([Species.MAGIKARP]); - const pokemon = game.scene.getPlayerPokemon()!; - mockI18next(); - const text = getTerrainBlockMessage(pokemon, terrainType); - expect(text).toBe("terrain:defaultBlockMessage"); - }); - }); - - describe("PSYCHIC", () => { - const terrainType = TerrainType.PSYCHIC; - - it("should return the obtain text", () => { - mockI18next(); - - const text = getTerrainName(terrainType); - expect(text).toBe("terrain:psychic"); - }); - - it("should return the start text", () => { - mockI18next(); - - const text = getTerrainStartMessage(terrainType); - expect(text).toBe("terrain:psychicStartMessage"); - }); - - it("should return the clear text", () => { - mockI18next(); - const text = getTerrainClearMessage(terrainType); - expect(text).toBe("terrain:psychicClearMessage"); - }); - - it("should return the block text", async () => { - await game.startBattle([Species.MAGIKARP]); - const pokemon = game.scene.getPlayerPokemon()!; - mockI18next(); - const text = getTerrainBlockMessage(pokemon, terrainType); - expect(text).toBe("terrain:defaultBlockMessage"); - }); - }); - - - afterEach(() => { - game.phaseInterceptor.restoreOg(); - vi.resetAllMocks(); - }); -});