mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 01:23:49 +01:00
Fix renamed functions from 1.0 release in tests
This commit is contained in:
parent
d1696148c4
commit
92e8b42d18
@ -4,6 +4,8 @@ module.exports = {
|
||||
transform: {
|
||||
"^.+\\.(js|jsx|ts|tsx)$": "babel-jest",
|
||||
},
|
||||
// testMatch: ["**/?(*.)+(test).[jt]s?(x)"],
|
||||
testPathIgnorePatterns: [
|
||||
'.cypress', 'node_modules', 'dist',
|
||||
],
|
||||
testEnvironment: "jsdom",
|
||||
};
|
||||
|
@ -9,6 +9,11 @@ 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 () {
|
||||
@ -158,7 +163,7 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
||||
runPotentiallyAsyncFunction(curr);
|
||||
} catch (e) {}
|
||||
} else {
|
||||
throw new Error(`Invalid function specified: [${fndesc}]`);
|
||||
throw new Error(`Invalid function specified: [${fnDesc}]`);
|
||||
}
|
||||
|
||||
testEquality(workerScript.dynamicRamUsage, ScriptBaseCost);
|
||||
@ -192,13 +197,13 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("hackAnalyzePercent()", async function () {
|
||||
const f = ["hackAnalyzePercent"];
|
||||
it("hackAnalyze()", async function () {
|
||||
const f = ["hackAnalyze"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("hackChance()", async function () {
|
||||
const f = ["hackChance"];
|
||||
it("hackAnalyzeChance()", async function () {
|
||||
const f = ["hackAnalyzeChance"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
@ -289,6 +294,7 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
||||
|
||||
it("exec()", async function () {
|
||||
const f = ["exec"];
|
||||
jest.spyOn(console, 'log').mockImplementation(() => {}); // eslint-disable-line
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
@ -454,32 +460,32 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
||||
|
||||
it("write()", async function () {
|
||||
const f = ["write"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
await testZeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("tryWrite()", async function () {
|
||||
const f = ["tryWrite"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
it("tryWritePort()", async function () {
|
||||
const f = ["tryWritePort"];
|
||||
await testZeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("read()", async function () {
|
||||
const f = ["read"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
await testZeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("peek()", async function () {
|
||||
const f = ["peek"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
await testZeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("clear()", async function () {
|
||||
const f = ["clear"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
await testZeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getPortHandle()", async function () {
|
||||
const f = ["getPortHandle"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
await testZeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("rm()", async function () {
|
||||
@ -581,88 +587,88 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
||||
});
|
||||
|
||||
describe("TIX API", function () {
|
||||
it("getStockSymbols()", async function () {
|
||||
const f = ["getStockSymbols"];
|
||||
it("stock.getSymbols()", async function () {
|
||||
const f = ["stock", "getSymbols"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockPrice()", async function () {
|
||||
const f = ["getStockPrice"];
|
||||
it("stock.getPrice()", async function () {
|
||||
const f = ["stock", "getPrice"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockAskPrice()", async function () {
|
||||
const f = ["getStockAskPrice"];
|
||||
it("stock.getBidPrice()", async function () {
|
||||
const f = ["stock", "getBidPrice"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockBidPrice()", async function () {
|
||||
const f = ["getStockBidPrice"];
|
||||
it("stock.getBidPrice()", async function () {
|
||||
const f = ["stock", "getBidPrice"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockPosition()", async function () {
|
||||
const f = ["getStockPosition"];
|
||||
it("stock.getPosition()", async function () {
|
||||
const f = ["stock", "getPosition"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockMaxShares()", async function () {
|
||||
const f = ["getStockMaxShares"];
|
||||
it("stock.getMaxShares()", async function () {
|
||||
const f = ["stock", "getMaxShares"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("buyStock()", async function () {
|
||||
const f = ["buyStock"];
|
||||
it("stock.buy()", async function () {
|
||||
const f = ["stock", "buy"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("sellStock()", async function () {
|
||||
const f = ["sellStock"];
|
||||
it("stock.sell()", async function () {
|
||||
const f = ["stock", "sell"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("shortStock()", async function () {
|
||||
const f = ["shortStock"];
|
||||
it("stock.short()", async function () {
|
||||
const f = ["stock", "short"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("sellShort()", async function () {
|
||||
const f = ["sellShort"];
|
||||
it("stock.sellShort()", async function () {
|
||||
const f = ["stock", "sellShort"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("placeOrder()", async function () {
|
||||
const f = ["placeOrder"];
|
||||
it("stock.placeOrder()", async function () {
|
||||
const f = ["stock", "placeOrder"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("cancelOrder()", async function () {
|
||||
const f = ["cancelOrder"];
|
||||
it("stock.cancelOrder()", async function () {
|
||||
const f = ["stock", "cancelOrder"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getOrders()", async function () {
|
||||
const f = ["getOrders"];
|
||||
it("stock.getOrders()", async function () {
|
||||
const f = ["stock", "getOrders"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockVolatility()", async function () {
|
||||
const f = ["getStockVolatility"];
|
||||
it("stock.getVolatility()", async function () {
|
||||
const f = ["stock", "getVolatility"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockForecast()", async function () {
|
||||
const f = ["getStockForecast"];
|
||||
it("stock.getForecast()", async function () {
|
||||
const f = ["stock", "getForecast"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("purchase4SMarketData()", async function () {
|
||||
const f = ["purchase4SMarketData"];
|
||||
it("stock.purchase4SMarketData()", async function () {
|
||||
const f = ["stock", "purchase4SMarketData"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("purchase4SMarketDataTixApi()", async function () {
|
||||
const f = ["purchase4SMarketDataTixApi"];
|
||||
it("stock.purchase4SMarketDataTixApi()", async function () {
|
||||
const f = ["stock", "purchase4SMarketDataTixApi"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
});
|
||||
@ -975,11 +981,6 @@ describe("Netscript Dynamic RAM Calculation/Generation Tests", function () {
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getCityEstimatedCommunities()", async function () {
|
||||
const f = ["bladeburner", "getCityEstimatedCommunities"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
});
|
||||
|
||||
it("getCityChaos()", async function () {
|
||||
const f = ["bladeburner", "getCityChaos"];
|
||||
await testNonzeroDynamicRamCost(f);
|
||||
|
@ -4,6 +4,11 @@ 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) {
|
||||
@ -81,13 +86,13 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("hackAnalyzePercent()", async function () {
|
||||
const f = ["hackAnalyzePercent"];
|
||||
it("hackAnalyze()", async function () {
|
||||
const f = ["hackAnalyze"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("hackChance()", async function () {
|
||||
const f = ["hackChance"];
|
||||
it("hackAnalyzeChance()", async function () {
|
||||
const f = ["hackAnalyzeChance"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
@ -343,32 +348,32 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
|
||||
|
||||
it("write()", async function () {
|
||||
const f = ["write"];
|
||||
await expectNonZeroRamCost(f);
|
||||
await expectZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("tryWrite()", async function () {
|
||||
const f = ["tryWrite"];
|
||||
await expectNonZeroRamCost(f);
|
||||
it("tryWritePort()", async function () {
|
||||
const f = ["tryWritePort"];
|
||||
await expectZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("read()", async function () {
|
||||
const f = ["read"];
|
||||
await expectNonZeroRamCost(f);
|
||||
await expectZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("peek()", async function () {
|
||||
const f = ["peek"];
|
||||
await expectNonZeroRamCost(f);
|
||||
await expectZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("clear()", async function () {
|
||||
const f = ["clear"];
|
||||
await expectNonZeroRamCost(f);
|
||||
await expectZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getPortHandle()", async function () {
|
||||
const f = ["getPortHandle"];
|
||||
await expectNonZeroRamCost(f);
|
||||
await expectZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("rm()", async function () {
|
||||
@ -508,98 +513,98 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
|
||||
});
|
||||
|
||||
describe("TIX API", function () {
|
||||
it("getStockSymbols()", async function () {
|
||||
const f = ["getStockSymbols"];
|
||||
it("stock.getSymbols()", async function () {
|
||||
const f = ["stock", "getSymbols"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockPrice()", async function () {
|
||||
const f = ["getStockPrice"];
|
||||
it("stock.getPrice()", async function () {
|
||||
const f = ["stock", "getPrice"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockAskPrice()", async function () {
|
||||
const f = ["getStockAskPrice"];
|
||||
it("stock.getAskPrice()", async function () {
|
||||
const f = ["stock", "getAskPrice"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockBidPrice()", async function () {
|
||||
const f = ["getStockBidPrice"];
|
||||
it("stock.getBidPrice()", async function () {
|
||||
const f = ["stock", "getBidPrice"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockPosition()", async function () {
|
||||
const f = ["getStockPosition"];
|
||||
it("stock.getPosition()", async function () {
|
||||
const f = ["stock", "getPosition"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockMaxShares()", async function () {
|
||||
const f = ["getStockMaxShares"];
|
||||
it("stock.getMaxShares()", async function () {
|
||||
const f = ["stock", "getMaxShares"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockPurchaseCost()", async function () {
|
||||
const f = ["getStockPurchaseCost"];
|
||||
it("stock.getPurchaseCost()", async function () {
|
||||
const f = ["stock", "getPurchaseCost"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockSaleGain()", async function () {
|
||||
const f = ["getStockSaleGain"];
|
||||
it("stock.getSaleGain()", async function () {
|
||||
const f = ["stock", "getSaleGain"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("buyStock()", async function () {
|
||||
const f = ["buyStock"];
|
||||
it("stock.buy()", async function () {
|
||||
const f = ["stock", "buy"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("sellStock()", async function () {
|
||||
const f = ["sellStock"];
|
||||
it("stock.sell()", async function () {
|
||||
const f = ["stock", "sell"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("shortStock()", async function () {
|
||||
const f = ["shortStock"];
|
||||
it("stock.short()", async function () {
|
||||
const f = ["stock", "short"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("sellShort()", async function () {
|
||||
const f = ["sellShort"];
|
||||
it("stock.sellShort()", async function () {
|
||||
const f = ["stock", "sell"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("placeOrder()", async function () {
|
||||
const f = ["placeOrder"];
|
||||
it("stock.placeOrder()", async function () {
|
||||
const f = ["stock", "placeOrder"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("cancelOrder()", async function () {
|
||||
const f = ["cancelOrder"];
|
||||
it("stock.cancelOrder()", async function () {
|
||||
const f = ["stock", "cancelOrder"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getOrders()", async function () {
|
||||
const f = ["getOrders"];
|
||||
it("stock.getOrders()", async function () {
|
||||
const f = ["stock", "getOrders"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockVolatility()", async function () {
|
||||
const f = ["getStockVolatility"];
|
||||
it("stock.getVolatility()", async function () {
|
||||
const f = ["stock", "getVolatility"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getStockForecast()", async function () {
|
||||
const f = ["getStockForecast"];
|
||||
it("stock.getForecast()", async function () {
|
||||
const f = ["stock", "getForecast"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("purchase4SMarketData()", async function () {
|
||||
const f = ["purchase4SMarketData"];
|
||||
it("stock.purchase4SMarketData()", async function () {
|
||||
const f = ["stock", "purchase4SMarketData"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("purchase4SMarketDataTixApi()", async function () {
|
||||
const f = ["purchase4SMarketDataTixApi"];
|
||||
it("stock.purchase4SMarketDataTixApi()", async function () {
|
||||
const f = ["stock", "purchase4SMarketDataTixApi"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
});
|
||||
@ -912,11 +917,6 @@ describe("Netscript Static RAM Calculation/Generation Tests", function () {
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getCityEstimatedCommunities()", async function () {
|
||||
const f = ["bladeburner", "getCityEstimatedCommunities"];
|
||||
await expectNonZeroRamCost(f);
|
||||
});
|
||||
|
||||
it("getCityChaos()", async function () {
|
||||
const f = ["bladeburner", "getCityChaos"];
|
||||
await expectNonZeroRamCost(f);
|
||||
|
Loading…
Reference in New Issue
Block a user