Add test for filtering by shiny

This commit is contained in:
Sirz Benjie 2025-04-14 12:08:44 -05:00
parent 927a456be8
commit 268bb2f8ab
No known key found for this signature in database
GPG Key ID: 4A524B4D196C759E

View File

@ -328,6 +328,48 @@ describe("UI - Pokedex", () => {
).toBe(true); ).toBe(true);
}); });
it("filtering by shiny status shows the caught pokemon with the selected shiny tier", async () => {
await game.importData("./test/testUtils/saves/data_pokedex_tests.prsv");
const pokedexHandler = await runToOpenPokedex();
// @ts-expect-error - `filterBar` is private
const filter = pokedexHandler.filterBar.getFilter(DropDownColumn.CAUGHT);
filter.toggleOptionState(3);
// @ts-expect-error - `filteredPokemonData` is private
let filteredPokemon = pokedexHandler.filteredPokemonData.map(pokemon => pokemon.species.speciesId);
// Red shiny
expect(filteredPokemon.length).toBe(1);
expect(filteredPokemon[0], "tier 1 shiny").toBe(Species.CATERPIE);
// tier 2 shiny
filter.toggleOptionState(3);
filter.toggleOptionState(2);
// @ts-expect-error - `filteredPokemonData` is private
filteredPokemon = pokedexHandler.filteredPokemonData.map(pokemon => pokemon.species.speciesId);
expect(filteredPokemon.length).toBe(1);
expect(filteredPokemon[0], "tier 2 shiny").toBe(Species.RATTATA);
filter.toggleOptionState(2);
filter.toggleOptionState(1);
// @ts-expect-error - `filteredPokemonData` is private
filteredPokemon = pokedexHandler.filteredPokemonData.map(pokemon => pokemon.species.speciesId);
expect(filteredPokemon.length).toBe(1);
expect(filteredPokemon[0], "tier 3 shiny").toBe(Species.EKANS);
// filter by no shiny
filter.toggleOptionState(1);
filter.toggleOptionState(4);
// @ts-expect-error - `filteredPokemonData` is private
filteredPokemon = pokedexHandler.filteredPokemonData.map(pokemon => pokemon.species.speciesId);
expect(filteredPokemon.length).toBe(27);
expect(filteredPokemon, "not shiny").not.toContain(Species.CATERPIE);
expect(filteredPokemon, "not shiny").not.toContain(Species.RATTATA);
expect(filteredPokemon, "not shiny").not.toContain(Species.EKANS);
});
/**************************** /****************************
* Tests for UI Input * * Tests for UI Input *
****************************/ ****************************/