diff --git a/.eslintignore b/.eslintignore index 0ef022e71..198118748 100644 --- a/.eslintignore +++ b/.eslintignore @@ -2,6 +2,10 @@ node_modules/ dist/ input/ +.dist +.tmp +.package + assets/ css/ .cypress/ diff --git a/test/Netscript/DynamicRamCalculation.test.js b/test/Netscript/DynamicRamCalculation.test.js index 59f82db3d..67b16b74b 100644 --- a/test/Netscript/DynamicRamCalculation.test.js +++ b/test/Netscript/DynamicRamCalculation.test.js @@ -1,3 +1,6 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { jest, describe, expect, test } from '@jest/globals' + import { NetscriptFunctions } from "../../src/NetscriptFunctions"; import { getRamCost, RamCostConstants } from "../../src/Netscript/RamCostGenerator"; import { Environment } from "../../src/Netscript/Environment"; @@ -9,11 +12,6 @@ jest.mock(`!!raw-loader!../NetscriptDefinitions.d.ts`, () => '', { virtual: true, }); -jest.mock("../../src/Netscript/killWorkerScript", () => ({ - __esModule: true, - killWorkerScript: jest.fn(), -})); - const ScriptBaseCost = RamCostConstants.ScriptBaseRamCost; describe("Netscript Dynamic RAM Calculation/Generation Tests", function () { @@ -115,12 +113,13 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () { * @param {string[]} fnDesc - describes the name of the function being tested, * including the namespace(s). e.g. ["gang", "getMemberNames"] */ - async function testZeroDynamicRamCost(fnDesc) { + async function testZeroDynamicRamCost(fnDesc, skipRun = false) { if (!Array.isArray(fnDesc)) { throw new Error("Non-array passed to testZeroDynamicRamCost()"); } const expected = getRamCost(...fnDesc); expect(expected).toEqual(0); + if (skipRun) return; const code = `${fnDesc.join(".")}();`; @@ -315,7 +314,7 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () { it("exit()", async function () { const f = ["exit"]; - await testZeroDynamicRamCost(f); + await testZeroDynamicRamCost(f, true); }); it("scp()", async function () { diff --git a/test/Netscript/StaticRamCalculation.test.js b/test/Netscript/StaticRamCalculation.test.js index 14ec03176..0a976e318 100644 --- a/test/Netscript/StaticRamCalculation.test.js +++ b/test/Netscript/StaticRamCalculation.test.js @@ -1,14 +1,12 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { jest, describe, expect, test } from '@jest/globals' + import { getRamCost, RamCostConstants } from "../../src/Netscript/RamCostGenerator"; import { calculateRamUsage } from "../../src/Script/RamCalculations"; const ScriptBaseCost = RamCostConstants.ScriptBaseRamCost; const HacknetNamespaceCost = RamCostConstants.ScriptHacknetNodesRamCost; -jest.mock("../../src/Netscript/killWorkerScript", () => ({ - __esModule: true, - killWorkerScript: jest.fn(), -})); - describe("Netscript Static RAM Calculation/Generation Tests", function () { // Tests numeric equality, allowing for floating point imprecision function testEquality(val, expected) { diff --git a/test/StockMarket.test.ts b/test/StockMarket.test.ts index 49bceb122..92c2d720f 100644 --- a/test/StockMarket.test.ts +++ b/test/StockMarket.test.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { jest, describe, expect, test } from '@jest/globals' + import { CONSTANTS } from "../src/Constants"; import { Player } from "../src/Player"; import { IMap } from "../src/types"; @@ -132,14 +135,14 @@ describe("Stock Market Tests", function () { const stock = new Stock(params); expect(stock).not.toEqual(null); - expect(stock.price).toBeGreaterThan(params.initPrice.min); - expect(stock.price).toBeLessThan(params.initPrice.max); - expect(stock.mv).toBeGreaterThan(params.mv.min / params.mv.divisor); - expect(stock.mv).toBeLessThan(params.mv.max / params.mv.divisor); - expect(stock.spreadPerc).toBeGreaterThan(params.spreadPerc.min / params.spreadPerc.divisor); - expect(stock.spreadPerc).toBeLessThan(params.spreadPerc.max / params.spreadPerc.divisor); - expect(stock.shareTxForMovement).toBeGreaterThan(params.shareTxForMovement.min); - expect(stock.shareTxForMovement).toBeLessThan(params.shareTxForMovement.max); + expect(stock.price).toBeGreaterThanOrEqual(params.initPrice.min); + expect(stock.price).toBeLessThanOrEqual(params.initPrice.max); + expect(stock.mv).toBeGreaterThanOrEqual(params.mv.min / params.mv.divisor); + expect(stock.mv).toBeLessThanOrEqual(params.mv.max / params.mv.divisor); + expect(stock.spreadPerc).toBeGreaterThanOrEqual(params.spreadPerc.min / params.spreadPerc.divisor); + expect(stock.spreadPerc).toBeLessThanOrEqual(params.spreadPerc.max / params.spreadPerc.divisor); + expect(stock.shareTxForMovement).toBeGreaterThanOrEqual(params.shareTxForMovement.min); + expect(stock.shareTxForMovement).toBeLessThanOrEqual(params.shareTxForMovement.max); }); it("should round the 'totalShare' prop to the nearest 100k", function () { @@ -855,7 +858,7 @@ describe("Stock Market Tests", function () { it("should return true and properly update stock properties for successful transactions", function () { const shares = 1e3; const cost = getBuyTransactionCost(stock, shares, PositionTypes.Long); - expect(cost).not.null; + expect(cost).not.toBeNull(); // Checked above // eslint-disable-next-line @typescript-eslint/no-non-null-assertion @@ -949,7 +952,7 @@ describe("Stock Market Tests", function () { it("should return true and properly update stock properties for successful transactions", function () { const shares = 1e3; const cost = getBuyTransactionCost(stock, shares, PositionTypes.Short); - expect(cost).not.null; + expect(cost).not.toBeNull(); // Checked above // eslint-disable-next-line @typescript-eslint/no-non-null-assertion diff --git a/test/StringHelperFunctions.test.ts b/test/StringHelperFunctions.test.ts index 3e6267163..637963c6a 100644 --- a/test/StringHelperFunctions.test.ts +++ b/test/StringHelperFunctions.test.ts @@ -1,3 +1,5 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { jest, describe, expect, test } from '@jest/globals' import { convertTimeMsToTimeElapsedString } from "../src/utils/StringHelperFunctions"; describe("StringHelperFunctions Tests", function () { diff --git a/test/Terminal/Directory.test.js b/test/Terminal/Directory.test.js index df5333dfc..a054be567 100644 --- a/test/Terminal/Directory.test.js +++ b/test/Terminal/Directory.test.js @@ -1,3 +1,5 @@ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { jest, describe, expect, test } from '@jest/globals' import * as dirHelpers from "../../src/Terminal/DirectoryHelpers"; describe("Terminal Directory Tests", function () { diff --git a/test/Terminal/determineAllPossibilitiesForTabCompletion.test.ts b/test/Terminal/determineAllPossibilitiesForTabCompletion.test.ts index 5fdc8bc12..ab2a370ee 100644 --- a/test/Terminal/determineAllPossibilitiesForTabCompletion.test.ts +++ b/test/Terminal/determineAllPossibilitiesForTabCompletion.test.ts @@ -1,4 +1,7 @@ /* eslint-disable no-await-in-loop */ +// eslint-disable-next-line @typescript-eslint/no-unused-vars +import { jest, describe, expect, test } from '@jest/globals' + import { Player } from "../../src/Player"; import { determineAllPossibilitiesForTabCompletion } from "../../src/Terminal/determineAllPossibilitiesForTabCompletion"; import { Server } from "../../src/Server/Server";