diff options
author | mat <github@matdoes.dev> | 2022-03-28 17:45:35 +0000 |
---|---|---|
committer | mat <github@matdoes.dev> | 2022-03-28 17:45:35 +0000 |
commit | adc1a7af012744e5b837d07ed1919776b821cdc1 (patch) | |
tree | b47b74d8f99aa1f9fef9c11a5ac224473578bc19 /test-data-generator/index.ts | |
parent | 44a8aebcb40f1d02b93218bcf5ccfa8e87621abb (diff) | |
download | skyblock-api-adc1a7af012744e5b837d07ed1919776b821cdc1.tar.gz skyblock-api-adc1a7af012744e5b837d07ed1919776b821cdc1.tar.bz2 skyblock-api-adc1a7af012744e5b837d07ed1919776b821cdc1.zip |
update tests
Diffstat (limited to 'test-data-generator/index.ts')
-rw-r--r-- | test-data-generator/index.ts | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/test-data-generator/index.ts b/test-data-generator/index.ts index bf8f34b..c8009c1 100644 --- a/test-data-generator/index.ts +++ b/test-data-generator/index.ts @@ -20,8 +20,17 @@ const playerUuids = [ ] async function writeTestData(requestPath: string, name: string, contents: any) { - const dir = path.join(process.cwd(), '..', 'test', 'data', requestPath) - await fs.mkdir(path.dirname(path.join(dir, `${name}.json`)), { recursive: true }) + if (!name) { + const splitRequestPath = requestPath.split('/') + name = splitRequestPath[splitRequestPath.length - 1] + requestPath = splitRequestPath.slice(0, -1).join('/') + } + const dir = path.join(process.cwd(), 'test', 'data', requestPath) + try { + await fs.mkdir(path.dirname(path.join(dir, `${name}.json`)), { recursive: true }) + } catch (err) { + console.error(err) + } await fs.writeFile(path.join(dir, `${name}.json`), JSON.stringify(contents, null, 2)) } @@ -45,6 +54,7 @@ async function addConstants() { 'stats', 'values', 'zones', + 'harp_songs' ] for (const constantName of constantNames) { const constantData = await constants.fetchJSONConstant(constantName + '.json') @@ -55,6 +65,7 @@ async function addConstants() { } async function main() { + await addResponse('resources/skyblock/items', {}, '') const uuidsToUsername = {} for (const playerUuid of playerUuids) { await addResponse('player', { uuid: playerUuid }, playerUuid) @@ -66,6 +77,8 @@ async function main() { await writeTestData('', 'mojang', uuidsToUsername) await addConstants() + + console.log('Done!') } main()
\ No newline at end of file |