Skip to content

Commit

Permalink
Merged from official repos
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeyTheA committed Jul 5, 2024
2 parents 9c04b2a + c5886bc commit 135b791
Show file tree
Hide file tree
Showing 3 changed files with 210 additions and 38 deletions.
149 changes: 149 additions & 0 deletions src/test/battle-stat.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
import {
BattleStat,
getBattleStatLevelChangeDescription,
getBattleStatName,
} from "#app/data/battle-stat.js";
import { describe, expect, it } from "vitest";
import { arrayOfRange, mockI18next } from "./utils/testUtils";

const TEST_BATTLE_STAT = -99 as unknown as BattleStat;
const TEST_POKEMON = "Testmon";
const TEST_STAT = "Teststat";

describe("battle-stat", () => {
describe("getBattleStatName", () => {
it("should return the correct name for each BattleStat", () => {
mockI18next();

expect(getBattleStatName(BattleStat.ATK)).toBe("pokemonInfo:Stat.ATK");
expect(getBattleStatName(BattleStat.DEF)).toBe("pokemonInfo:Stat.DEF");
expect(getBattleStatName(BattleStat.SPATK)).toBe(
"pokemonInfo:Stat.SPATK"
);
expect(getBattleStatName(BattleStat.SPDEF)).toBe(
"pokemonInfo:Stat.SPDEF"
);
expect(getBattleStatName(BattleStat.SPD)).toBe("pokemonInfo:Stat.SPD");
expect(getBattleStatName(BattleStat.ACC)).toBe("pokemonInfo:Stat.ACC");
expect(getBattleStatName(BattleStat.EVA)).toBe("pokemonInfo:Stat.EVA");
});

it("should fall back to ??? for an unknown BattleStat", () => {
expect(getBattleStatName(TEST_BATTLE_STAT)).toBe("???");
});
});

describe("getBattleStatLevelChangeDescription", () => {
it("should return battle:statRose for +1", () => {
mockI18next();

const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
1,
true
);

expect(message).toBe("battle:statRose");
});

it("should return battle:statSharplyRose for +2", () => {
mockI18next();

const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
2,
true
);

expect(message).toBe("battle:statSharplyRose");
});

it("should return battle:statRoseDrastically for +3 to +6", () => {
mockI18next();

arrayOfRange(3, 6).forEach((n) => {
const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
n,
true
);

expect(message).toBe("battle:statRoseDrastically");
});
});

it("should return battle:statWontGoAnyHigher for 7 or higher", () => {
mockI18next();

arrayOfRange(7, 10).forEach((n) => {
const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
n,
true
);

expect(message).toBe("battle:statWontGoAnyHigher");
});
});

it("should return battle:statFell for -1", () => {
mockI18next();

const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
1,
false
);

expect(message).toBe("battle:statFell");
});

it("should return battle:statHarshlyFell for -2", () => {
mockI18next();

const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
2,
false
);

expect(message).toBe("battle:statHarshlyFell");
});

it("should return battle:statSeverelyFell for -3 to -6", () => {
mockI18next();

arrayOfRange(3, 6).forEach((n) => {
const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
n,
false
);

expect(message).toBe("battle:statSeverelyFell");
});
});

it("should return battle:statWontGoAnyLower for -7 or lower", () => {
mockI18next();

arrayOfRange(7, 10).forEach((n) => {
const message = getBattleStatLevelChangeDescription(
TEST_POKEMON,
TEST_STAT,
n,
false
);

expect(message).toBe("battle:statWontGoAnyLower");
});
});
});
});
Loading

0 comments on commit 135b791

Please sign in to comment.