aboutsummaryrefslogtreecommitdiff
path: root/test-data-generator/index.ts
diff options
context:
space:
mode:
authormat <github@matdoes.dev>2022-03-28 17:45:35 +0000
committermat <github@matdoes.dev>2022-03-28 17:45:35 +0000
commitadc1a7af012744e5b837d07ed1919776b821cdc1 (patch)
treeb47b74d8f99aa1f9fef9c11a5ac224473578bc19 /test-data-generator/index.ts
parent44a8aebcb40f1d02b93218bcf5ccfa8e87621abb (diff)
downloadskyblock-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.ts17
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