Skip to content

Commit

Permalink
Changed the tests so they work now with the i18n hting
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeTappert committed Jul 10, 2024
1 parent eeea805 commit 6d162f9
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 60 deletions.
1 change: 0 additions & 1 deletion src/data/battle-stat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,5 @@ export function getBattleStatLevelChangeDescription(pokemonNameWithAffix: string
}
}
})();

return i18next.t(stringKey as ParseKeys, { pokemonNameWithAffix, stats, count });
}
119 changes: 60 additions & 59 deletions src/test/localization/battle-stat.test.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,38 @@
import {beforeAll, describe, expect, it} from "vitest";
import { getBattleStatName, getBattleStatLevelChangeDescription } from "#app/data/battle-stat.js";
import { BattleStat } from "#app/data/battle-stat.js";
import { pokemonInfo as enPokemonInfo } from "#app/locales/en/pokemon-info.js";
import { battle as enBattleStat } from "#app/locales/en/battle.js";
import { pokemonInfo as dePokemonInfo } from "#app/locales/de/pokemon-info.js";
import { battle as deBattleStat } from "#app/locales/de/battle.js";
import { pokemonInfo as esPokemonInfo } from "#app/locales/es/pokemon-info.js";
import { battle as esBattleStat } from "#app/locales/es/battle.js";
import { pokemonInfo as frPokemonInfo } from "#app/locales/fr/pokemon-info.js";
import { battle as frBattleStat } from "#app/locales/fr/battle.js";
import { pokemonInfo as itPokemonInfo } from "#app/locales/it/pokemon-info.js";
import { battle as itBattleStat } from "#app/locales/it/battle.js";
import { pokemonInfo as koPokemonInfo } from "#app/locales/ko/pokemon-info.js";
import { battle as koBattleStat } from "#app/locales/ko/battle.js";
import { pokemonInfo as ptBrPokemonInfo } from "#app/locales/pt_BR/pokemon-info.js";
import { battle as ptBrBattleStat } from "#app/locales/pt_BR/battle.js";
import { pokemonInfo as zhCnPokemonInfo } from "#app/locales/zh_CN/pokemon-info.js";
import { battle as zhCnBattleStat } from "#app/locales/zh_CN/battle.js";
import { pokemonInfo as zhTwPokemonInfo } from "#app/locales/zh_TW/pokemon-info.js";
import { battle as zhTwBattleStat } from "#app/locales/zh_TW/battle.js";
import {getBattleStatName, getBattleStatLevelChangeDescription} from "#app/data/battle-stat.js";
import {BattleStat} from "#app/data/battle-stat.js";
import {pokemonInfo as enPokemonInfo} from "#app/locales/en/pokemon-info.js";
import {battle as enBattleStat} from "#app/locales/en/battle.js";
import {pokemonInfo as dePokemonInfo} from "#app/locales/de/pokemon-info.js";
import {battle as deBattleStat} from "#app/locales/de/battle.js";
import {pokemonInfo as esPokemonInfo} from "#app/locales/es/pokemon-info.js";
import {battle as esBattleStat} from "#app/locales/es/battle.js";
import {pokemonInfo as frPokemonInfo} from "#app/locales/fr/pokemon-info.js";
import {battle as frBattleStat} from "#app/locales/fr/battle.js";
import {pokemonInfo as itPokemonInfo} from "#app/locales/it/pokemon-info.js";
import {battle as itBattleStat} from "#app/locales/it/battle.js";
import {pokemonInfo as koPokemonInfo} from "#app/locales/ko/pokemon-info.js";
import {battle as koBattleStat} from "#app/locales/ko/battle.js";
import {pokemonInfo as ptBrPokemonInfo} from "#app/locales/pt_BR/pokemon-info.js";
import {battle as ptBrBattleStat} from "#app/locales/pt_BR/battle.js";
import {pokemonInfo as zhCnPokemonInfo} from "#app/locales/zh_CN/pokemon-info.js";
import {battle as zhCnBattleStat} from "#app/locales/zh_CN/battle.js";
import {pokemonInfo as zhTwPokemonInfo} from "#app/locales/zh_TW/pokemon-info.js";
import {battle as zhTwBattleStat} from "#app/locales/zh_TW/battle.js";

import i18next, {initI18n} from "#app/plugins/i18n";
import { KoreanPostpositionProcessor } from "i18next-korean-postposition-processor";
import {KoreanPostpositionProcessor} from "i18next-korean-postposition-processor";

interface BattleStatTestUnit {
stat: BattleStat,
key: string
stat: BattleStat,
key: string
}

interface BattleStatLevelTestUnit {
levels: integer,
up: boolean,
key: string
levels: integer,
up: boolean,
key: string
changedStats: integer
}

function testBattleStatName(stat: BattleStat, expectMessage: string) {
Expand All @@ -40,8 +41,8 @@ function testBattleStatName(stat: BattleStat, expectMessage: string) {
expect(message).toBe(expectMessage);
}

function testBattleStatLevelChangeDescription(levels: integer, up: boolean, expectMessage: string) {
const message = getBattleStatLevelChangeDescription("{{pokemonNameWithAffix}}", "{{stats}}", levels, up);
function testBattleStatLevelChangeDescription(levels: integer, up: boolean, expectMessage: string, changedStats: integer) {
const message = getBattleStatLevelChangeDescription("{{pokemonNameWithAffix}}", "{{stats}}", levels, up, changedStats);
console.log(`message ${message}, expected ${expectMessage}`);
expect(message).toBe(expectMessage);
}
Expand All @@ -53,28 +54,28 @@ describe("Test for BattleStat Localization", () => {
beforeAll(() => {
initI18n();

battleStatUnits.push({ stat: BattleStat.ATK, key: "Stat.ATK" });
battleStatUnits.push({ stat: BattleStat.DEF, key: "Stat.DEF" });
battleStatUnits.push({ stat: BattleStat.SPATK, key: "Stat.SPATK" });
battleStatUnits.push({ stat: BattleStat.SPDEF, key: "Stat.SPDEF" });
battleStatUnits.push({ stat: BattleStat.SPD, key: "Stat.SPD" });
battleStatUnits.push({ stat: BattleStat.ACC, key: "Stat.ACC" });
battleStatUnits.push({ stat: BattleStat.EVA, key: "Stat.EVA" });

battleStatLevelUnits.push({ levels: 1, up: true, key: "statRose" });
battleStatLevelUnits.push({ levels: 2, up: true, key: "statSharplyRose" });
battleStatLevelUnits.push({ levels: 3, up: true, key: "statRoseDrastically" });
battleStatLevelUnits.push({ levels: 4, up: true, key: "statRoseDrastically" });
battleStatLevelUnits.push({ levels: 5, up: true, key: "statRoseDrastically" });
battleStatLevelUnits.push({ levels: 6, up: true, key: "statRoseDrastically" });
battleStatLevelUnits.push({ levels: 7, up: true, key: "statWontGoAnyHigher" });
battleStatLevelUnits.push({ levels: 1, up: false, key: "statFell" });
battleStatLevelUnits.push({ levels: 2, up: false, key: "statHarshlyFell" });
battleStatLevelUnits.push({ levels: 3, up: false, key: "statSeverelyFell" });
battleStatLevelUnits.push({ levels: 4, up: false, key: "statSeverelyFell" });
battleStatLevelUnits.push({ levels: 5, up: false, key: "statSeverelyFell" });
battleStatLevelUnits.push({ levels: 6, up: false, key: "statSeverelyFell" });
battleStatLevelUnits.push({ levels: 7, up: false, key: "statWontGoAnyLower" });
battleStatUnits.push({stat: BattleStat.ATK, key: "Stat.ATK"});
battleStatUnits.push({stat: BattleStat.DEF, key: "Stat.DEF"});
battleStatUnits.push({stat: BattleStat.SPATK, key: "Stat.SPATK"});
battleStatUnits.push({stat: BattleStat.SPDEF, key: "Stat.SPDEF"});
battleStatUnits.push({stat: BattleStat.SPD, key: "Stat.SPD"});
battleStatUnits.push({stat: BattleStat.ACC, key: "Stat.ACC"});
battleStatUnits.push({stat: BattleStat.EVA, key: "Stat.EVA"});

battleStatLevelUnits.push({levels: 1, up: true, key: "statRose_one", changedStats: 1});
battleStatLevelUnits.push({levels: 2, up: true, key: "statSharplyRose_one", changedStats: 1});
battleStatLevelUnits.push({levels: 3, up: true, key: "statRoseDrastically_one", changedStats: 1});
battleStatLevelUnits.push({levels: 4, up: true, key: "statRoseDrastically_one", changedStats: 1});
battleStatLevelUnits.push({levels: 5, up: true, key: "statRoseDrastically_one", changedStats: 1});
battleStatLevelUnits.push({levels: 6, up: true, key: "statRoseDrastically_one", changedStats: 1});
battleStatLevelUnits.push({levels: 7, up: true, key: "statWontGoAnyHigher_one", changedStats: 1});
battleStatLevelUnits.push({levels: 1, up: false, key: "statFell_one", changedStats: 1});
battleStatLevelUnits.push({levels: 2, up: false, key: "statHarshlyFell_one", changedStats: 1});
battleStatLevelUnits.push({levels: 3, up: false, key: "statSeverelyFell_one", changedStats: 1});
battleStatLevelUnits.push({levels: 4, up: false, key: "statSeverelyFell_one", changedStats: 1});
battleStatLevelUnits.push({levels: 5, up: false, key: "statSeverelyFell_one", changedStats: 1});
battleStatLevelUnits.push({levels: 6, up: false, key: "statSeverelyFell_one", changedStats: 1});
battleStatLevelUnits.push({levels: 7, up: false, key: "statWontGoAnyLower_one", changedStats: 1});
});

it("Test getBattleStatName() in English", async () => {
Expand All @@ -87,7 +88,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in English", async () => {
i18next.changeLanguage("en");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, enBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, enBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -101,7 +102,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in Español", async () => {
i18next.changeLanguage("es");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, esBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, esBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -115,7 +116,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in Italiano", async () => {
i18next.changeLanguage("it");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, itBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, itBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -129,7 +130,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in Français", async () => {
i18next.changeLanguage("fr");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, frBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, frBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -143,7 +144,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in Deutsch", async () => {
i18next.changeLanguage("de");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, deBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, deBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -157,7 +158,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in Português (BR)", async () => {
i18next.changeLanguage("pt-BR");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, ptBrBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, ptBrBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -171,7 +172,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in 简体中文", async () => {
i18next.changeLanguage("zh-CN");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, zhCnBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, zhCnBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -185,7 +186,7 @@ describe("Test for BattleStat Localization", () => {
it("Test getBattleStatLevelChangeDescription() in 繁體中文", async () => {
i18next.changeLanguage("zh-TW");
battleStatLevelUnits.forEach(unit => {
testBattleStatLevelChangeDescription(unit.levels, unit.up, zhTwBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, zhTwBattleStat[unit.key], unit.changedStats);
});
});

Expand All @@ -201,7 +202,7 @@ describe("Test for BattleStat Localization", () => {
battleStatLevelUnits.forEach(unit => {
const processor = new KoreanPostpositionProcessor();
const message = processor.process(koBattleStat[unit.key]);
testBattleStatLevelChangeDescription(unit.levels, unit.up, message);
testBattleStatLevelChangeDescription(unit.levels, unit.up, message, unit.changedStats);
});
});
});
Expand Down

0 comments on commit 6d162f9

Please sign in to comment.