[Test] Fix The Pokemon Salesman tests (#4345)

The expects didn't account for the possible shiny, which appends a `_shiny` to some dialogue tokens.
I've added regexes to account for that possibility
This commit is contained in:
flx-sta 2024-09-20 14:14:55 -07:00 committed by GitHub
parent 20ab2b9272
commit 0a5e9ff9e6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -53,19 +53,22 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
}); });
it("should have the correct properties", async () => { it("should have the correct properties", async () => {
const { encounterType, encounterTier, dialogue, options } = ThePokemonSalesmanEncounter;
await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, defaultParty); await game.runToMysteryEncounter(MysteryEncounterType.THE_POKEMON_SALESMAN, defaultParty);
expect(ThePokemonSalesmanEncounter.encounterType).toBe(MysteryEncounterType.THE_POKEMON_SALESMAN); expect(encounterType).toBe(MysteryEncounterType.THE_POKEMON_SALESMAN);
expect(ThePokemonSalesmanEncounter.encounterTier).toBe(MysteryEncounterTier.ULTRA); expect(encounterTier).toBe(MysteryEncounterTier.ULTRA);
expect(ThePokemonSalesmanEncounter.dialogue).toBeDefined(); expect(dialogue).toBeDefined();
expect(ThePokemonSalesmanEncounter.dialogue.intro).toStrictEqual([ expect(dialogue.intro).toStrictEqual([
{ text: `${namespace}.intro` }, { text: `${namespace}.intro` },
{ speaker: `${namespace}.speaker`, text: `${namespace}.intro_dialogue` } { speaker: `${namespace}.speaker`, text: `${namespace}.intro_dialogue` }
]); ]);
expect(ThePokemonSalesmanEncounter.dialogue.encounterOptionsDialogue?.title).toBe(`${namespace}.title`); const { title, description, query } = dialogue.encounterOptionsDialogue!;
expect(ThePokemonSalesmanEncounter.dialogue.encounterOptionsDialogue?.description).toBe(`${namespace}.description`); expect(title).toBe(`${namespace}.title`);
expect(ThePokemonSalesmanEncounter.dialogue.encounterOptionsDialogue?.query).toBe(`${namespace}.query`); expect(description).toMatch(new RegExp(`^${namespace}\\.description(_shiny)?$`));
expect(ThePokemonSalesmanEncounter.options.length).toBe(2); expect(query).toBe(`${namespace}.query`);
expect(options.length).toBe(2);
}); });
it("should not spawn outside of HUMAN_TRANSITABLE_BIOMES", async () => { it("should not spawn outside of HUMAN_TRANSITABLE_BIOMES", async () => {
@ -104,12 +107,13 @@ describe("The Pokemon Salesman - Mystery Encounter", () => {
describe("Option 1 - Purchase the pokemon", () => { describe("Option 1 - Purchase the pokemon", () => {
it("should have the correct properties", () => { it("should have the correct properties", () => {
const option = ThePokemonSalesmanEncounter.options[0]; const { optionMode, dialogue } = ThePokemonSalesmanEncounter.options[0];
expect(option.optionMode).toBe(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT);
expect(option.dialogue).toBeDefined(); expect(optionMode).toBe(MysteryEncounterOptionMode.DISABLED_OR_DEFAULT);
expect(option.dialogue).toStrictEqual({ expect(dialogue).toBeDefined();
expect(dialogue).toStrictEqual({
buttonLabel: `${namespace}.option.1.label`, buttonLabel: `${namespace}.option.1.label`,
buttonTooltip: `${namespace}.option.1.tooltip`, buttonTooltip: expect.stringMatching(new RegExp(`^${namespace}\\.option\\.1\\.tooltip(_shiny)?$`)),
selected: [ selected: [
{ {
text: `${namespace}.option.1.selected_message`, text: `${namespace}.option.1.selected_message`,