diff --git a/scripts/data-gen-scripts/scripted-updaters/update-test-files.ts b/scripts/data-gen-scripts/scripted-updaters/update-test-files.ts index 398ef342b5..62efc007d6 100644 --- a/scripts/data-gen-scripts/scripted-updaters/update-test-files.ts +++ b/scripts/data-gen-scripts/scripted-updaters/update-test-files.ts @@ -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 { + const formatted = prettier.format(JSON.stringify(response), { ...prettierConfig, parser: 'json' }); + return formatted; +} + async function executeGraphQL(pokemon: string): Promise { return fetch( 'http://localhost:4000', diff --git a/tests/scenarios/pokemon/getPokemon.test.ts b/tests/scenarios/pokemon/getPokemon.test.ts index 35c1609061..cbb1823265 100644 --- a/tests/scenarios/pokemon/getPokemon.test.ts +++ b/tests/scenarios/pokemon/getPokemon.test.ts @@ -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' }); }); @@ -312,7 +312,7 @@ describe('getPokemon', () => { base: 45, percentageWithOrdinaryPokeballAtFullHealth: '11.9%' }, - classification: null, + classification: 'Ghost Flame Pokémon', color: 'Yellow', cosmeticFormes: null, cry: null diff --git a/tests/testUtils/full-data-responses/beldum.json b/tests/testUtils/full-data-responses/beldum.json index 6b5599d676..65290dfbea 100644 --- a/tests/testUtils/full-data-responses/beldum.json +++ b/tests/testUtils/full-data-responses/beldum.json @@ -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, @@ -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, @@ -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 diff --git a/tests/testUtils/full-data-responses/dragonair.json b/tests/testUtils/full-data-responses/dragonair.json index e14e2907a2..6fc4922f2a 100644 --- a/tests/testUtils/full-data-responses/dragonair.json +++ b/tests/testUtils/full-data-responses/dragonair.json @@ -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, @@ -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, @@ -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, diff --git a/tests/testUtils/full-data-responses/eevee.json b/tests/testUtils/full-data-responses/eevee.json index 0990a826ce..121f905684 100644 --- a/tests/testUtils/full-data-responses/eevee.json +++ b/tests/testUtils/full-data-responses/eevee.json @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, @@ -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, diff --git a/tests/testUtils/full-data-responses/salamence.json b/tests/testUtils/full-data-responses/salamence.json index 867453c7b8..c364ccb9e3 100644 --- a/tests/testUtils/full-data-responses/salamence.json +++ b/tests/testUtils/full-data-responses/salamence.json @@ -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, @@ -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, @@ -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