aboutsummaryrefslogtreecommitdiff
path: root/test/test.js
diff options
context:
space:
mode:
authordependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>2021-09-06 21:06:22 +0000
committerGitHub <noreply@github.com>2021-09-06 21:06:22 +0000
commit487f208565894f332ca58c13e1b208c3beb9c8c6 (patch)
treeb3209e94cc63658b5430bc1949b80140cc27efe4 /test/test.js
parent4f03cb71b30978b277ff292dbddeba182117a7cb (diff)
downloadskyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.gz
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.tar.bz2
skyblock-api-487f208565894f332ca58c13e1b208c3beb9c8c6.zip
Bump node-fetch from 2.6.1 to 3.0.0 (#116)
* Bump node-fetch from 2.6.1 to 3.0.0 Bumps [node-fetch](https://github.com/node-fetch/node-fetch) from 2.6.1 to 3.0.0. - [Release notes](https://github.com/node-fetch/node-fetch/releases) - [Changelog](https://github.com/node-fetch/node-fetch/blob/main/docs/CHANGELOG.md) - [Commits](https://github.com/node-fetch/node-fetch/compare/v2.6.1...v3.0.0) --- updated-dependencies: - dependency-name: node-fetch dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix issues with node fetch 3.0 * change module to esnext instead of commonjs * fix imports and tests * fix package-lock.json Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: mat <github@matdoes.dev> Co-authored-by: mat <27899617+mat-1@users.noreply.github.com>
Diffstat (limited to 'test/test.js')
-rw-r--r--test/test.js44
1 files changed, 23 insertions, 21 deletions
diff --git a/test/test.js b/test/test.js
index bb96849..88c2ba9 100644
--- a/test/test.js
+++ b/test/test.js
@@ -1,15 +1,17 @@
globalThis.isTest = true
+console.log('set globalThis.isTest to true', globalThis.isTest)
-const { levelForSkillXp } = require('../build/cleaners/skyblock/skills')
-const hypixelCached = require('../build/hypixelCached')
-const hypixelApi = require('../build/hypixelApi')
-const constants = require('../build/constants')
-const hypixel = require('../build/hypixel')
-const mojang = require('../build/mojang')
-const util = require('../build/util')
-const assert = require('assert')
-const path = require('path')
-const fs = require('fs')
+// we use `await import` instead of `import from` so globalThis.isTest is set before importing the modules
+const { levelForSkillXp } = await import('../build/cleaners/skyblock/skills.js')
+const hypixelCached = await import('../build/hypixelCached.js')
+const hypixelApi = await import('../build/hypixelApi.js')
+const constants = await import('../build/constants.js')
+const hypixel = await import('../build/hypixel.js')
+const mojang = await import('../build/mojang.js')
+const util = await import('../build/util.js')
+const assert = await import('assert')
+const path = await import('path')
+const fs = await import('fs')
const cachedJsonData = {}
@@ -26,7 +28,7 @@ async function readJsonData(dir) {
return parsedData
}
-hypixelApi.sendApiRequest = async ({ path, key, args }) => {
+hypixelApi.mockSendApiRequest(async ({ path, key, args }) => {
requestsSent ++
switch (path) {
case 'player': {
@@ -37,32 +39,32 @@ hypixelApi.sendApiRequest = async ({ path, key, args }) => {
}
}
console.log(path, args)
-}
+})
-mojang.profileFromUuid = async (uuid) => {
+mojang.mockProfileFromUuid(async (uuid) => {
requestsSent ++
const uuidToUsername = await readJsonData('mojang')
const undashedUuid = undashUuid(uuid)
const username = uuidToUsername[undashUuid(undashedUuid)]
return { username, uuid: undashedUuid }
-}
-mojang.profileFromUsername = async (username) => {
+})
+mojang.mockProfileFromUsername(async (username) => {
requestsSent ++
const uuidToUsername = await readJsonData('mojang')
const uuid = Object.keys(uuidToUsername).find(uuid => uuidToUsername[uuid] === username)
return { username, uuid }
-}
-mojang.profileFromUser = async (user) => {
+})
+mojang.mockProfileFromUser(async (user) => {
if (util.isUuid(user))
return await mojang.profileFromUuid(user)
else
return await mojang.profileFromUsername(user)
-}
+})
-constants.addJSONConstants = async(filename, addingValues, unit) => {}
-constants.fetchJSONConstant = async(filename) => {
+constants.mockAddJSONConstants(async(filename, addingValues, unit) => {})
+constants.mockFetchJSONConstant(async(filename) => {
return await readJsonData('constants/' + filename.slice(0, filename.length - '.json'.length))
-}
+})
/** Clear all the current caches and stuff */