Skip to content

Commit

Permalink
test: update test data
Browse files Browse the repository at this point in the history
  • Loading branch information
favna committed Mar 2, 2024
1 parent 6906cc7 commit c3b2d74
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 27 deletions.
22 changes: 15 additions & 7 deletions scripts/data-gen-scripts/scripted-updaters/update-test-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,30 @@ import { fetch, FetchMethods, FetchResultTypes } from '@sapphire/fetch';
import { writeFile } from 'node:fs/promises';
import { getPokemonWithFullDataAndEvolutions } from '../../../tests/testUtils/queries/pokemon-all-data.js';
import { userAgentHeader } from '../../utils.js';
import prettier from 'prettier';
import prettierConfig from '../../../.prettierrc.mjs';

const fullDataResponsesFolder = new URL('../../../tests/testUtils/full-data-responses/', import.meta.url);

const data = await Promise.all(['beldum', 'dragonair', 'eevee', 'rattataalola', 'salamence', 'syclar'].map((pokemon) => executeGraphQL(pokemon)));
const [beldumData, dragonairData, eeveeData, rattataalolaData, salamenceData, syclarData] = await Promise.all(
['beldum', 'dragonair', 'eevee', 'rattataalola', 'salamence', 'syclar'].map((pokemon) => executeGraphQL(pokemon))
data.map((response) => stringifyAndFormat(response))
);

await Promise.all([
writeFile(new URL('beldum.json', fullDataResponsesFolder), JSON.stringify(beldumData)),
writeFile(new URL('dragonair.json', fullDataResponsesFolder), JSON.stringify(dragonairData)),
writeFile(new URL('eevee.json', fullDataResponsesFolder), JSON.stringify(eeveeData)),
writeFile(new URL('rattata-alola.json', fullDataResponsesFolder), JSON.stringify(rattataalolaData)),
writeFile(new URL('salamence.json', fullDataResponsesFolder), JSON.stringify(salamenceData)),
writeFile(new URL('syclar.json', fullDataResponsesFolder), JSON.stringify(syclarData))
writeFile(new URL('beldum.json', fullDataResponsesFolder), beldumData),
writeFile(new URL('dragonair.json', fullDataResponsesFolder), dragonairData),
writeFile(new URL('eevee.json', fullDataResponsesFolder), eeveeData),
writeFile(new URL('rattata-alola.json', fullDataResponsesFolder), rattataalolaData),
writeFile(new URL('salamence.json', fullDataResponsesFolder), salamenceData),
writeFile(new URL('syclar.json', fullDataResponsesFolder), syclarData)
]);

async function stringifyAndFormat(response: PokemonResponse): Promise<string> {
const formatted = prettier.format(JSON.stringify(response), { ...prettierConfig, parser: 'json' });
return formatted;
}

async function executeGraphQL(pokemon: string): Promise<PokemonResponse> {
return fetch<PokemonResponse>(
'http://localhost:4000',
Expand Down
4 changes: 2 additions & 2 deletions tests/scenarios/pokemon/getPokemon.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ describe('getPokemon', () => {
classification: 'Ninja Pokémon',
color: 'Blue',
cosmeticFormes: null,
cry: null
cry: 'https://play.pokemonshowdown.com/audio/cries/greninja.mp3'
});
});

Expand Down Expand Up @@ -312,7 +312,7 @@ describe('getPokemon', () => {
base: 45,
percentageWithOrdinaryPokeballAtFullHealth: '11.9%'
},
classification: null,
classification: 'Ghost Flame Pokémon',
color: 'Yellow',
cosmeticFormes: null,
cry: null
Expand Down
6 changes: 3 additions & 3 deletions tests/testUtils/full-data-responses/beldum.json
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@
"classification": "Iron Ball Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/beldum.mp3",
"weight": 95.2,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -2072,7 +2072,7 @@
"classification": "Iron Claw Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/metang.mp3",
"weight": 202.5,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -12611,7 +12611,7 @@
"classification": "Iron Leg Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/metagross.mp3",
"weight": 550,
"legendary": false,
"mythical": false
Expand Down
6 changes: 3 additions & 3 deletions tests/testUtils/full-data-responses/dragonair.json
Original file line number Diff line number Diff line change
Expand Up @@ -9925,7 +9925,7 @@
"classification": "Dragon Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/dragonair.mp3",
"weight": 16.5,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -19876,7 +19876,7 @@
"classification": "Dragon Pokémon",
"color": "Brown",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/dragonite.mp3",
"weight": 210,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -29810,7 +29810,7 @@
"classification": "Dragon Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/dratini.mp3",
"weight": 3.3,
"legendary": false,
"mythical": false,
Expand Down
18 changes: 9 additions & 9 deletions tests/testUtils/full-data-responses/eevee.json
Original file line number Diff line number Diff line change
Expand Up @@ -10124,7 +10124,7 @@
"classification": "Evolution Pokémon",
"color": "Brown",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/eevee.mp3",
"weight": 6.5,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -20213,7 +20213,7 @@
"classification": "Bubble Jet Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/vaporeon.mp3",
"weight": 29,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -30316,7 +30316,7 @@
"classification": "Lightning Pokémon",
"color": "Yellow",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/jolteon.mp3",
"weight": 24.5,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -40407,7 +40407,7 @@
"classification": "Flame Pokémon",
"color": "Red",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/flareon.mp3",
"weight": 25,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -50523,7 +50523,7 @@
"classification": "Sun Pokémon",
"color": "Purple",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/espeon.mp3",
"weight": 26.5,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -60625,7 +60625,7 @@
"classification": "Moonlight Pokémon",
"color": "Black",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/umbreon.mp3",
"weight": 27,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -70716,7 +70716,7 @@
"classification": "Verdant Pokémon",
"color": "Green",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/leafeon.mp3",
"weight": 25.5,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -80818,7 +80818,7 @@
"classification": "Fresh Snow Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/glaceon.mp3",
"weight": 25.9,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -90909,7 +90909,7 @@
"classification": "Intertwining Pokémon",
"color": "Pink",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/sylveon.mp3",
"weight": 23.5,
"legendary": false,
"mythical": false,
Expand Down
6 changes: 3 additions & 3 deletions tests/testUtils/full-data-responses/salamence.json
Original file line number Diff line number Diff line change
Expand Up @@ -10930,7 +10930,7 @@
"classification": "Dragon Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/salamence.mp3",
"weight": 102.6,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -21848,7 +21848,7 @@
"classification": "Endurance Pokémon",
"color": "White",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/shelgon.mp3",
"weight": 110.5,
"legendary": false,
"mythical": false,
Expand Down Expand Up @@ -29936,7 +29936,7 @@
"classification": "Rock Head Pokémon",
"color": "Blue",
"cosmeticFormes": null,
"cry": null,
"cry": "https://play.pokemonshowdown.com/audio/cries/bagon.mp3",
"weight": 42.1,
"legendary": false,
"mythical": false
Expand Down

0 comments on commit c3b2d74

Please sign in to comment.