pokerogue/src/test/lokalisation/status-effect.test.ts
Enoch 0bc4f26b9d
[Localization] localized status-effect.ts and translate. (#2528)
* make postposition not to dynamic for localize

* localize status-effect.ts

* added test code, modified english postposition, modifed toxic_orb test to make it always fix in English.

* Update src/locales/zh_CN/status-effect.ts

Co-authored-by: Yonmaru40 <47717431+40chyan@users.noreply.github.com>

* Update src/locales/fr/status-effect.ts

Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr>

* Update src/locales/de/status-effect.ts

Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com>

* Update src/locales/de/status-effect.ts

* added test code for check message key

* remove multi-language tests (except english)

* Update src/locales/pt_BR/status-effect.ts

Co-authored-by: José Ricardo Fleury Oliveira <josefleury@discente.ufg.br>

* remove language and change test code to check method call and parameter

* Update src/locales/es/status-effect.ts

Co-authored-by: GoldTra <162721984+GoldTra@users.noreply.github.com>

* Update src/locales/en/status-effect.ts

Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr>

* Apply review suggestion

* Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

* Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

* Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

* add Test with empty string parameter

* Update src/locales/es/status-effect.ts

Co-authored-by: InnocentGameDev <asdargmng@gmail.com>

* Update src/locales/fr/status-effect.ts

Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr>

---------

Co-authored-by: 송지원 <jiwsong@gmarket.com>
Co-authored-by: Yonmaru40 <47717431+40chyan@users.noreply.github.com>
Co-authored-by: Lugiad' <adrien.grivel@hotmail.fr>
Co-authored-by: Jannik Tappert <38758606+CodeTappert@users.noreply.github.com>
Co-authored-by: José Ricardo Fleury Oliveira <josefleury@discente.ufg.br>
Co-authored-by: GoldTra <162721984+GoldTra@users.noreply.github.com>
Co-authored-by: InnocentGameDev <asdargmng@gmail.com>
2024-07-02 10:22:46 -04:00

302 lines
11 KiB
TypeScript

import { beforeAll, describe, expect, it, vi } from "vitest";
import {
StatusEffect,
getStatusEffectActivationText,
getStatusEffectDescriptor,
getStatusEffectHealText,
getStatusEffectObtainText,
getStatusEffectOverlapText,
} from "#app/data/status-effect";
import i18next, { ParseKeys } from "i18next";
import { afterEach } from "node:test";
const tMock = (key: ParseKeys) => key;
const pokemonName = "PKM";
const sourceText = "SOURCE";
describe("status-effect", () => {
beforeAll(() => {
i18next.init();
});
describe("NONE", () => {
const statusEffect = StatusEffect.NONE;
it("should return the obtain text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectActivationText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:none.activation");
});
it("should return the overlap text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:none.overlap");
});
it("should return the heal text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectHealText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:none.heal");
});
it("should return the descriptor", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectDescriptor(statusEffect);
expect(text).toBe("statusEffect:none.description");
});
});
describe("POISON", () => {
const statusEffect = StatusEffect.POISON;
it("should return the obtain text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectActivationText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:poison.activation");
});
it("should return the descriptor", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectDescriptor(statusEffect);
expect(text).toBe("statusEffect:poison.description");
});
it("should return the heal text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectHealText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:poison.heal");
});
it("should return the overlap text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:poison.overlap");
});
});
describe("TOXIC", () => {
const statusEffect = StatusEffect.TOXIC;
it("should return the obtain text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectActivationText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:toxic.activation");
});
it("should return the descriptor", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectDescriptor(statusEffect);
expect(text).toBe("statusEffect:toxic.description");
});
it("should return the heal text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectHealText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:toxic.heal");
});
it("should return the overlap text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:toxic.overlap");
});
});
describe("PARALYSIS", () => {
const statusEffect = StatusEffect.PARALYSIS;
it("should return the obtain text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectActivationText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:paralysis.activation");
});
it("should return the descriptor", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectDescriptor(statusEffect);
expect(text).toBe("statusEffect:paralysis.description");
});
it("should return the heal text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectHealText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:paralysis.heal");
});
it("should return the overlap text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:paralysis.overlap");
});
});
describe("SLEEP", () => {
const statusEffect = StatusEffect.SLEEP;
it("should return the obtain text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectActivationText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:sleep.activation");
});
it("should return the descriptor", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectDescriptor(statusEffect);
expect(text).toBe("statusEffect:sleep.description");
});
it("should return the heal text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectHealText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:sleep.heal");
});
it("should return the overlap text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:sleep.overlap");
});
});
describe("FREEZE", () => {
const statusEffect = StatusEffect.FREEZE;
it("should return the obtain text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectActivationText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:freeze.activation");
});
it("should return the descriptor", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectDescriptor(statusEffect);
expect(text).toBe("statusEffect:freeze.description");
});
it("should return the heal text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectHealText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:freeze.heal");
});
it("should return the overlap text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:freeze.overlap");
});
});
describe("BURN", () => {
const statusEffect = StatusEffect.BURN;
it("should return the obtain text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
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", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectActivationText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:burn.activation");
});
it("should return the descriptor", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectDescriptor(statusEffect);
expect(text).toBe("statusEffect:burn.description");
});
it("should return the heal text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectHealText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:burn.heal");
});
it("should return the overlap text", () => {
vi.spyOn(i18next, "t").mockImplementation(tMock);
const text = getStatusEffectOverlapText(statusEffect, pokemonName);
expect(text).toBe("statusEffect:burn.overlap");
});
});
afterEach(() => {
vi.resetAllMocks();
});
});