From 0a182c498e23bb0ab481410346114fce47d9355d Mon Sep 17 00:00:00 2001 From: Matt <7128721+TobiTenno@users.noreply.github.com> Date: Sun, 23 Jun 2024 12:02:02 -0500 Subject: [PATCH] feat: change how syndcate arrays parse (#540) BREAKING CHANGE: async data moved to build functions --- .c8rc.json | 16 +++++ .commitlintrc.ts | 17 +++++ .eslintignore | 4 ++ .eslintrc.yaml | 11 +++ .lintstagedrc.yaml | 8 +++ .mocharc.yml | 3 + .npmignore | 10 +++ README.md | 9 +-- babel.config.cjs | 9 +++ clean-package.config.js | 17 +++++ lib/WorldState.js | 53 ++++++++++++-- lib/models/SyndicateJob.js | 21 +++++- lib/models/SyndicateMission.js | 27 +++++-- lib/models/WorldEvent.js | 51 +++++++++---- main.js | 3 +- package-lock.json | 1 + package.json | 103 +++------------------------ test/integration/integration.spec.js | 41 +++++++---- test/unit/event.spec.js | 12 ++-- test/unit/syndicatejob.spec.js | 29 +++----- test/unit/syndicatemission.spec.js | 6 +- test/unit/system.spec.js | 1 + test/unit/worldstate.spec.js | 2 +- 23 files changed, 283 insertions(+), 171 deletions(-) create mode 100644 .c8rc.json create mode 100644 .commitlintrc.ts create mode 100644 .eslintignore create mode 100644 .eslintrc.yaml create mode 100644 .lintstagedrc.yaml create mode 100644 .mocharc.yml create mode 100644 babel.config.cjs create mode 100644 clean-package.config.js diff --git a/.c8rc.json b/.c8rc.json new file mode 100644 index 000000000..0f1076fce --- /dev/null +++ b/.c8rc.json @@ -0,0 +1,16 @@ +{ + "exclude": [ + "test/**", + "lib/DarkSector*.js", + "lib/Alert.js", + "lib/PersistentEnemy.js", + "lib/GlobalUpgrade.js", + "lib/ChallengeInstance.js", + "lib/WeeklyChallenge.js" + ], + "reporter": [ + "lcov", + "text" + ], + "skip-full": true +} diff --git a/.commitlintrc.ts b/.commitlintrc.ts new file mode 100644 index 000000000..d25091f66 --- /dev/null +++ b/.commitlintrc.ts @@ -0,0 +1,17 @@ +import { RuleConfigSeverity } from '@commitlint/types'; + +export default { + extends: [ + '@commitlint/config-conventional' + ], + rules: { + 'body-max-line-length': [ + RuleConfigSeverity.Disabled + ], + 'subject-case': [ + RuleConfigSeverity.Error, + 'never', + ['sentence-case', 'start-case'] + ] + } +} diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..a84798b0f --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +.github/** +docs/** +resources/** +types/** diff --git a/.eslintrc.yaml b/.eslintrc.yaml new file mode 100644 index 000000000..58f0bf0cb --- /dev/null +++ b/.eslintrc.yaml @@ -0,0 +1,11 @@ +parser: '@babel/eslint-parser' +parserOptions: + ecmaFeatures: + modules: true + ecmaVersion: 6 + sourceType: module +extends: '@wfcd/eslint-config/strict-esm-jsdoc' +rules: + import/extensions: + - error + - ignorePackages diff --git a/.lintstagedrc.yaml b/.lintstagedrc.yaml new file mode 100644 index 000000000..859510b51 --- /dev/null +++ b/.lintstagedrc.yaml @@ -0,0 +1,8 @@ +'*.**,!package*.json': + - 'npm run fmt:fix' +'*.js': + - eslint --fix --cache + - npm test -- --reporter=mocha-minimalist-reporter +package*.json: + - npm dedupe + - npx sort-package-json diff --git a/.mocharc.yml b/.mocharc.yml new file mode 100644 index 000000000..4b52eb111 --- /dev/null +++ b/.mocharc.yml @@ -0,0 +1,3 @@ +exit: true +spec: test/**/*.spec.js +timeout: 10000 diff --git a/.npmignore b/.npmignore index 5528b1e8e..7f4eb4551 100644 --- a/.npmignore +++ b/.npmignore @@ -38,3 +38,13 @@ data.*.json package.json.backup .install/ +# Other project configuration files +.c8rc.json +.commitlintrc.ts +.eslintignore +.eslintrc.yaml +.eslintcache +.lintstagedrc.yaml +.mocharc.yml +babel.config.cjs +clean-package.config.js diff --git a/README.md b/README.md index 89ffc8b9f..471462613 100644 --- a/README.md +++ b/README.md @@ -23,11 +23,12 @@ For the most part, you'll have a better experience consuming the product of this ## Example usage ```javascript -const worldstateData = await require('request-promise')('http://content.warframe.com/dynamic/worldState.php'); +// import WorldState from 'warframe-worldstate-data'; +// using this syntax to make it precisely testable in a test +const WorldStateParser = await import('warframe-worldstate-parser'); +const worldstateData = await fetch('https://content.warframe.com/dynamic/worldState.php').then((data) => data.text()); -const WorldState = require('warframe-worldstate-parser'); - -const ws = new WorldState(worldstateData); +const ws = await WorldStateParser(worldstateData); console.log(ws.alerts[0].toString()); ``` diff --git a/babel.config.cjs b/babel.config.cjs new file mode 100644 index 000000000..a6f40f156 --- /dev/null +++ b/babel.config.cjs @@ -0,0 +1,9 @@ +module.exports = { + plugins: [ + '@babel/plugin-transform-class-properties', + '@babel/plugin-transform-private-methods' + ], + presets: [ + '@babel/preset-env' + ] +} diff --git a/clean-package.config.js b/clean-package.config.js new file mode 100644 index 000000000..d601bcf62 --- /dev/null +++ b/clean-package.config.js @@ -0,0 +1,17 @@ +export default { + remove: [ + 'devDependencies', + 'scripts', + 'release', + 'eslintIgnore', + 'eslintConfig', + 'c8', + 'mocha', + 'clean-package', + 'directories', + 'prettier', + 'babel', + 'lint-staged', + 'overrides' + ] +} diff --git a/lib/WorldState.js b/lib/WorldState.js index cbbbfac21..558d86f1b 100644 --- a/lib/WorldState.js +++ b/lib/WorldState.js @@ -58,7 +58,7 @@ export function parseArray(ParserClass, dataArray, deps, uniqueField) { const arr = (dataArray || []).map((d) => new ParserClass(d, deps)); if (uniqueField) { const utemp = {}; - arr.sort((a, b) => a.id.localeCompare(b.id)); + arr.sort((a, b) => a.id?.localeCompare(b.id)); arr.forEach((obj) => { utemp[obj[uniqueField]] = obj; }); @@ -71,14 +71,55 @@ export function parseArray(ParserClass, dataArray, deps, uniqueField) { return arr; } +/** + * Parse array of objects that requires async parsing + * @param {object} ParserClass class for parsing data - must expose a static build method + * @param {Array} dataArray array of raw data + * @param {Dependency} deps shared dependency object + * @param {*} [uniqueField] field to treat as unique + * @returns {Promise} array of parsed objects + */ +export const parseAsyncArray = async (ParserClass, dataArray, deps, uniqueField) => { + const arr = []; + // eslint-disable-next-line no-restricted-syntax + for await (const d of dataArray ?? []) { + arr.push(await ParserClass.build(d, deps)); + } + if (uniqueField) { + const utemp = {}; + arr.sort((a, b) => a.id.localeCompare(b.id)); + arr.forEach((obj) => { + utemp[obj[uniqueField]] = obj; + }); + return Array.from(arr).filter((obj) => { + if (obj && obj.active && typeof obj.active !== 'undefined') return obj.active; + /* istanbul ignore next */ + return true; + }); + } + return arr; +}; + /** * Parses Warframe Worldstate JSON */ -export default class WorldState { +export class WorldState { + static async build(json, deps = defaultDeps) { + const ws = new WorldState(json, deps); + const data = JSON.parse(json); + + ws.events = await parseAsyncArray(WorldEvent, data.Goals, deps); + ws.syndicateMissions = await parseAsyncArray(SyndicateMission, data.SyndicateMissions, deps, 'syndicate'); + + return ws; + } + /** * Generates the worldstate json as a string into usable objects * @param {string} json The worldstate JSON string * @param {Dependency} [deps] The options object + * @class + * @async */ constructor(json, deps = defaultDeps) { if (typeof json !== 'string') { @@ -114,7 +155,7 @@ export default class WorldState { * The current events * @type {Array.} */ - this.events = parseArray(WorldEvent, data.Goals, deps); + this.events = []; /** * The current alerts @@ -132,7 +173,7 @@ export default class WorldState { * The current syndicate missions * @type {Array.} */ - this.syndicateMissions = parseArray(SyndicateMission, data.SyndicateMissions, deps, 'syndicate'); + this.syndicateMissions = []; /** * The current fissures: 'ActiveMissions' & 'VoidStorms' @@ -298,7 +339,7 @@ export default class WorldState { } /** - * Current syndicate outposts + * Current sentient outposts * @type {SentientOutpost} */ this.sentientOutposts = new SentientOutpost(data.Tmp, deps); @@ -322,3 +363,5 @@ export default class WorldState { this.duviriCycle = new DuviriCycle(deps); } } + +export default async (json, deps) => WorldState.build(json, deps); diff --git a/lib/models/SyndicateJob.js b/lib/models/SyndicateJob.js index 2813babd9..fbf8aed93 100644 --- a/lib/models/SyndicateJob.js +++ b/lib/models/SyndicateJob.js @@ -84,10 +84,28 @@ const FIFTY_MINUTES = 3000000; */ export default class SyndicateJob extends WorldstateObject { /** + * Generate a job with async data (reward pool) * @param {object} data The syndicate mission data * @param {Date} expiry The syndicate job expiration * @param {object} deps The dependencies object * @param {string} deps.locale Locale to use for translations + * @returns {Promise} The created SyndicateJob object with rewardPool + */ + static async build(data, expiry, deps) { + const job = new SyndicateJob(data, expiry, deps); + job.rewardPool = await getBountyRewards(data.rewards, data.isVault, data); + + return job; + } + + /** + * Construct a job without async data (reward pool) + * @param {object} data The syndicate mission data + * @param {Date} expiry The syndicate job expiration + * @param {object} deps The dependencies object + * @param {string} deps.locale Locale to use for translations + * + * This DOES NOT populate the reward pool */ constructor(data, expiry, { locale = 'en' }) { super({ @@ -103,9 +121,6 @@ export default class SyndicateJob extends WorldstateObject { * @type {Array.} */ this.rewardPool = []; - getBountyRewards(data.rewards, data.isVault, data).then((rewards) => { - this.rewardPool = rewards; - }); const chamber = ((data.locationTag || '').match(/[A-Z]+(?![a-z])|[A-Z]?[a-z]+|\d+/g) || []).join(' '); diff --git a/lib/models/SyndicateMission.js b/lib/models/SyndicateMission.js index d3ef7a5e0..604494c9c 100644 --- a/lib/models/SyndicateMission.js +++ b/lib/models/SyndicateMission.js @@ -10,6 +10,27 @@ import WorldstateObject from './WorldstateObject.js'; * @augments {WorldstateObject} */ export default class SyndicateMission extends WorldstateObject { + /** + * Build a new SyndicateMission with async operations & data + * @param {object} data The syndicate mission data + * @param {object} deps The dependencies object + * @param {string} deps.locale Locale to use for translations + * @returns {Promise.} SyndicateMission object w/ async resolution of jobs + */ + static async build(data, deps) { + const syndicateMission = new SyndicateMission(data, deps); + if (data.Jobs) { + const jobs = []; + // eslint-disable-next-line no-restricted-syntax + for await (const job of data.Jobs ?? []) { + jobs.push(await SyndicateJob.build(job, syndicateMission.expiry, deps)); + } + syndicateMission.jobs = jobs; + } + + return syndicateMission; + } + /** * @param {object} data The syndicate mission data * @param {object} deps The dependencies object @@ -18,10 +39,6 @@ export default class SyndicateMission extends WorldstateObject { constructor(data, { locale = 'en' } = { locale: 'en' }) { super(data); - const deps = { - locale, - }; - /** * The date and time at which the syndicate mission starts * @type {Date} @@ -56,7 +73,7 @@ export default class SyndicateMission extends WorldstateObject { * The jobs for this syndicate. Will normally be [] * @type {Array.} */ - this.jobs = (data.Jobs || []).map((j) => new SyndicateJob(j, this.expiry, deps)); + this.jobs = []; /** * Unique identifier for this mission set built from the end time and syndicate diff --git a/lib/models/WorldEvent.js b/lib/models/WorldEvent.js index 85e8c0857..5f77e24cf 100644 --- a/lib/models/WorldEvent.js +++ b/lib/models/WorldEvent.js @@ -27,6 +27,34 @@ import Reward from './Reward.js'; * @augments {WorldstateObject} */ export default class WorldEvent extends WorldstateObject { + /** + * Asynchronously build a new WorldEvent + * @param {object} data The event data + * @param {object} deps The dependencies object + * @param {string} deps.locale Locale to use for translations + * @returns {Promise.} The created WorldEvent object + */ + static async build(data, deps) { + const event = new WorldEvent(data, deps); + if (data.Jobs) { + const jobs = []; + // eslint-disable-next-line no-restricted-syntax + for await (const job of data.Jobs ?? []) { + jobs.push(await SyndicateJob.build(job, event.expiry, deps)); + } + event.jobs = jobs; + } + if (data.PreviousJobs) { + const previousJobs = []; + // eslint-disable-next-line no-restricted-syntax + for await (const job of data.PreviousJobs ?? []) { + previousJobs.push(await SyndicateJob.build(job, event.expiry, deps)); + } + event.previousJobs = previousJobs; + } + return event; + } + /** * @param {object} data The event data * @param {object} deps The dependencies object @@ -132,13 +160,8 @@ export default class WorldEvent extends WorldstateObject { this.health = typeof data.HealthPct !== 'undefined' ? Number.parseFloat(((data.HealthPct || 0.0) * 100).toFixed(2)) : undefined; - if (data.JobAffiliationTag) { - this.affiliatedWith = syndicate(data.JobAffiliationTag, locale); - if (data.Jobs) { - this.jobs = (data.Jobs || []).map((j) => new SyndicateJob(j, this.expiry, opts)); - this.previousJobs = (data.PreviousJobs || []).map((j) => new SyndicateJob(j, this.expiry, opts)); - } - } + this.jobs = []; + this.previousJobs = []; /** * Previous job id @@ -191,22 +214,22 @@ export default class WorldEvent extends WorldstateObject { } /** - * Whether or not to show the total score at the end of the mission + * Whether to show the total score at the end of the mission * @type {boolean} */ this.showTotalAtEndOfMission = data.ShowTotalAtEOM; /** - * Whether or not the event is personal + * Whether the event is personal * @type {boolean} */ this.isPersonal = data.Personal; /** - * Whether or not the event is community + * Whether the event is community * @type {boolean} */ this.isCommunity = data.Community; - /** + /* * Affectors for this mission * @type {string[]} */ @@ -241,10 +264,14 @@ export default class WorldEvent extends WorldstateObject { expiry: parseDate(data.NextAltExpiry), activation: parseDate(data.NextAltActivation), }; + + if (data.JobAffiliationTag) { + this.affiliatedWith = syndicate(data.JobAffiliationTag, locale); + } } /** - * Get whether or not the event has expired + * Get whether the event has expired * @returns {boolean} whether the event has expired */ getExpired() { diff --git a/main.js b/main.js index f1ef7c180..7e892ed86 100644 --- a/main.js +++ b/main.js @@ -1,3 +1,4 @@ -import WorldState from './lib/WorldState.js'; +import { WorldState } from './lib/WorldState.js'; export default WorldState; +export * from './lib/WorldState.js'; diff --git a/package-lock.json b/package-lock.json index 3332cb8a6..1f894b021 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,6 +11,7 @@ "devDependencies": { "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", + "@commitlint/types": "^19.0.3", "@types/chai": "^4.2.11", "@types/sinon-chai": "^3.2.5", "c8": "^10.0.0", diff --git a/package.json b/package.json index d7188d1ef..2125fae6a 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,12 @@ "contributors": [ "nspacestd (https://github.com/nspacestd)" ], + "exports": { + ".": { + "import": "./main.js", + "types": "./types/index.d.ts" + } + }, "type": "module", "main": "main.js", "types": "./types/main.d.ts", @@ -40,89 +46,13 @@ "printcov": "c8 report", "test": "mocha", "test:coverage": "c8 npm test", - "test:integration": "npm run test -- -g 'should parse live pc worldstate data'", - "validate": "npm ls" - }, - "commitlint": { - "extends": [ - "@commitlint/config-conventional" - ], - "rules": { - "body-max-line-length": [ - 0 - ] - } - }, - "lint-staged": { - "*.**,!package*.json": [ - "npm run fmt:fix" - ], - "*.js": [ - "eslint --fix --cache", - "npm test -- --reporter=mocha-minimalist-reporter" - ], - "package*.json": [ - "npm dedupe", - "npx sort-package-json" - ] - }, - "babel": { - "plugins": [ - "@babel/plugin-transform-class-properties", - "@babel/plugin-transform-private-methods" - ], - "presets": [ - "@babel/preset-env" - ] + "test:integration": "npm run test -- -g 'should parse live pc worldstate data'" }, "prettier": "@wfcd/eslint-config/prettier", - "eslintConfig": { - "parser": "@babel/eslint-parser", - "parserOptions": { - "ecmaFeatures": { - "modules": true - }, - "ecmaVersion": 6, - "sourceType": "module" - }, - "extends": "@wfcd/eslint-config/strict-esm-jsdoc", - "rules": { - "import/extensions": [ - "error", - "ignorePackages" - ] - } - }, - "eslintIgnore": [ - ".github/**", - "docs/**", - "resources/**", - "types/**" - ], - "mocha": { - "exit": true, - "spec": "test/**/*.spec.js", - "timeout": 10000 - }, - "c8": { - "exclude": [ - "test/**", - "lib/DarkSector*.js", - "lib/Alert.js", - "lib/PersistentEnemy.js", - "lib/GlobalUpgrade.js", - "lib/ChallengeInstance.js", - "lib/WeeklyChallenge.js" - ], - "reporter": [ - "lcov", - "text" - ], - "skip-full": true - }, "devDependencies": { "@commitlint/cli": "^19.2.1", "@commitlint/config-conventional": "^19.1.0", + "@commitlint/types": "^19.0.3", "@types/chai": "^4.2.11", "@types/sinon-chai": "^3.2.5", "c8": "^10.0.0", @@ -142,23 +72,6 @@ "engines": { "node": ">=18.19.0" }, - "clean-package": { - "remove": [ - "devDependencies", - "scripts", - "release", - "eslintIgnore", - "eslintConfig", - "c8", - "mocha", - "clean-package", - "directories", - "prettier", - "babel", - "lint-staged", - "overrides" - ] - }, "overrides": { "sinon-chai": { "chai": "^5.0.3" diff --git a/test/integration/integration.spec.js b/test/integration/integration.spec.js index b3cd05efd..3035e30fa 100644 --- a/test/integration/integration.spec.js +++ b/test/integration/integration.spec.js @@ -1,11 +1,10 @@ import fs from 'node:fs/promises'; import path from 'node:path'; +import WorldState from 'warframe-worldstate-parser'; import * as chai from 'chai'; import sinonChai from 'sinon-chai'; -import WorldState from '../../lib/WorldState.js'; - const logger = { error: () => {}, debug: () => {}, @@ -17,25 +16,21 @@ const { expect } = chai; chai.should(); chai.use(sinonChai); +const json = async (url) => fetch(url).then((res) => res.json()); +const text = async (url) => fetch(url).then((res) => res.text()); + describe('WorldState (integration)', () => { it(`should parse live pc worldstate data`, async function () { this.timeout = 10000; // allow 10 seconds to parse the worldstate - const kuvaData = await fetch('https://10o.io/arbitrations.json').then((res) => res.json()); - const ws = await fetch('https://content.warframe.com/dynamic/worldState.php').then((res) => res.text()); + const kuvaData = await json('https://10o.io/arbitrations.json'); + const ws = await text('https://content.warframe.com/dynamic/worldState.php'); - let wsl; - (() => { - try { - // once without kuva data - // wsl = new WorldState(ws, { logger, locale: 'en' }); - wsl = new WorldState(ws, { logger, locale: 'en', kuvaData }); - } catch (e) { - console.error(e); // eslint-disable-line no-console - throw e; - } + (async () => { + await WorldState.build(ws, { logger, locale: 'en' }); }).should.not.throw(); - expect(wsl.news).to.exist; + const wsl = await WorldState.build(ws, { logger, locale: 'en', kuvaData }); + expect(wsl?.news).to.exist; wsl?.news?.forEach((article) => { if (article.message.toLowerCase().includes('stream')) { article.should.include({ stream: true }); @@ -52,6 +47,9 @@ describe('WorldState (integration)', () => { expect(Ostrons.syndicate).to.equal('Ostrons'); expect(Ostrons.jobs).to.exist; expect(Ostrons.jobs).to.be.an('array'); + expect(Ostrons.jobs).to.have.length.gte(1); + wsl.syndicateMissions.some((m) => !!m.jobs.some((job) => job.rewardPool.length > 0)).should.be.true; + expect(wsl?.fissures).to.exist; expect(wsl?.sentientOutposts.id).to.not.contain('dataOverride'); @@ -63,4 +61,17 @@ describe('WorldState (integration)', () => { ); } }); + + it('should run the README example', async () => { + const example = async () => { + const WorldStateParser = await import('warframe-worldstate-parser'); + const worldstateData = await fetch('https://content.warframe.com/dynamic/worldState.php').then((data) => + data.text() + ); + const ws = await WorldStateParser(worldstateData); + console.log(ws.alerts[0].toString()); + }; + + example.should.not.throw(); + }); }); diff --git a/test/unit/event.spec.js b/test/unit/event.spec.js index 3b20d828a..3ab36835f 100644 --- a/test/unit/event.spec.js +++ b/test/unit/event.spec.js @@ -23,22 +23,22 @@ describe('Event', () => { }); }); describe('#toString()', () => { - it('should only include the rewards if the event has any', () => { - const e = new Event({ _id: { $oid: 'id' }, Expiry: { sec: 1 } }); + it('should only include the rewards if the event has any', async () => { + const e = await new Event({ _id: { $oid: 'id' }, Expiry: { sec: 1 } }); e.toString().should.not.match(/Rewards/); e.rewards = ['reward1']; e.toString().should.match(/Rewards/); }); - it('should not include the node if the event has one', () => { - const e = new Event({ _id: { $oid: 'id' }, Expiry: { sec: 1 } }); + it('should not include the node if the event has one', async () => { + const e = await new Event({ _id: { $oid: 'id' }, Expiry: { sec: 1 } }); e.toString().should.not.match(/Battle on/); e.node = 'Node'; e.toString().should.match(/Battle on/); }); - it('should only include the victim node if the event has one', () => { - const e = new Event({ _id: { $oid: 'id' }, Expiry: { sec: 1 } }); + it('should only include the victim node if the event has one', async () => { + const e = await new Event({ _id: { $oid: 'id' }, Expiry: { sec: 1 } }); e.toString().should.not.match(/Protect/); e.victim = 'Victim Node'; diff --git a/test/unit/syndicatejob.spec.js b/test/unit/syndicatejob.spec.js index 4319c0274..e54990a69 100644 --- a/test/unit/syndicatejob.spec.js +++ b/test/unit/syndicatejob.spec.js @@ -24,33 +24,22 @@ describe('SyndicateJob', () => { }); describe('.rewardPool', () => { - const poolTest = (data) => - function (done) { + const poolTest = async (data) => + async function () { this.timeout(1100000000); - const job = new SyndicateJob(data, new Date(), { locale }); - - let interval; + const job = await SyndicateJob.build(data, new Date(), { locale }); const verify = (rewardPool) => { rewardPool.should.be.an('array'); rewardPool.length.should.be.at.least(1); - done(); - clearInterval(interval); }; - interval = setInterval(() => { - if (job.rewardPool.length) verify(job.rewardPool); - }, 100); - - setTimeout(() => { - clearInterval(interval); - verify(job.rewardPool); - }, 10000); + if (job.rewardPool?.length) verify(job.rewardPool); }; - it('should exist when requested', poolTest(isoVaultBounty)); - it('should support plague star', poolTest(plagueStarBounty)); - it('should support Cetus F Tier', poolTest(CetusFTier)); - it('should support Deimos F Tier', poolTest(CambionFTier)); - it('should support Unmatched tiers', poolTest(NoMatchJob)); + it('should exist when requested', async () => poolTest(isoVaultBounty)); + it('should support plague star', async () => poolTest(plagueStarBounty)); + it('should support Cetus F Tier', async () => poolTest(CetusFTier)); + it('should support Deimos F Tier', async () => poolTest(CambionFTier)); + it('should support Unmatched tiers', async () => poolTest(NoMatchJob)); }); }); diff --git a/test/unit/syndicatemission.spec.js b/test/unit/syndicatemission.spec.js index 7c2e9be1e..e85a9e6ae 100644 --- a/test/unit/syndicatemission.spec.js +++ b/test/unit/syndicatemission.spec.js @@ -17,7 +17,7 @@ describe('SyndicateMission', function () { }); describe('#toString()', function () { - it('should format the string correctly according to the data', function () { + it('should format the string correctly according to the data', async function () { const testData = { _id: { $oid: '1234sg' }, Activation: { sec: 1241 }, @@ -25,12 +25,10 @@ describe('SyndicateMission', function () { Tag: 'syndicate', Nodes: [], }; - const s = new SyndicateMission(testData); + const s = await new SyndicateMission(testData); s.toString().should.contain('No missions'); - s.nodes.push('node'); - s.toString().should.contain('has missions'); }); }); diff --git a/test/unit/system.spec.js b/test/unit/system.spec.js index 78a1b2280..7f3e2c5e8 100644 --- a/test/unit/system.spec.js +++ b/test/unit/system.spec.js @@ -1,5 +1,6 @@ import * as chai from 'chai'; +// eslint-disable-next-line import/no-named-as-default import WorldState from '../../main.js'; import kuvaMock from '../data/kuvalog.json' assert { type: 'json' }; import sentientMock from '../data/anomaly.json' assert { type: 'json' }; diff --git a/test/unit/worldstate.spec.js b/test/unit/worldstate.spec.js index d7e578bfa..39771dc7b 100644 --- a/test/unit/worldstate.spec.js +++ b/test/unit/worldstate.spec.js @@ -3,7 +3,7 @@ import sinon from 'sinon'; import sinonChai from 'sinon-chai'; import WorldStateObject from '../../lib/models/WorldstateObject.js'; -import WorldState, { parseArray } from '../../lib/WorldState.js'; +import { WorldState, parseArray } from '../../lib/WorldState.js'; chai.should(); chai.use(sinonChai);