JEST: Refactor tests that add home server manually (#2358)

This commit is contained in:
catloversg
2025-10-22 07:57:14 +07:00
committed by GitHub
parent c6684431b5
commit a703e8753b
2 changed files with 85 additions and 53 deletions
+7 -20
View File
@@ -1,4 +1,4 @@
import { Player, setPlayer } from "@player";
import { Player } from "@player";
import { AugmentationName, GoColor, GoOpponent, GoPlayType } from "@enums";
import { Go } from "../../../src/Go/Go";
import {
@@ -22,33 +22,21 @@ import {
resetBoardState,
validateMove,
} from "../../../src/Go/effects/netscriptGoImplementation";
import { PlayerObject } from "../../../src/PersonObjects/Player/PlayerObject";
import "../../../src/Faction/Factions";
import { getNewBoardState, getNewBoardStateFromSimpleBoard } from "../../../src/Go/boardState/boardState";
import { installAugmentations } from "../../../src/Augmentation/AugmentationHelpers";
import { AddToAllServers } from "../../../src/Server/AllServers";
import { Server } from "../../../src/Server/Server";
import { initSourceFiles } from "../../../src/SourceFile/SourceFiles";
import { getMockedNetscriptContext } from "../Utilities";
import { getMockedNetscriptContext, initGameEnvironment, setupBasicTestingEnvironment } from "../Utilities";
jest.mock("../../../src/Faction/Factions", () => ({
Factions: {},
}));
initGameEnvironment();
beforeEach(() => {
setupBasicTestingEnvironment();
});
jest.mock("../../../src/ui/GameRoot", () => ({
Router: {
page: () => ({}),
toPage: () => ({}),
},
}));
const mockLogger: (s: string) => void = jest.fn();
const mockCtx = getMockedNetscriptContext((_: string, txt: () => string) => {
mockLogger(txt());
});
setPlayer(new PlayerObject());
AddToAllServers(new Server({ hostname: "home" }));
describe("Netscript Go API unit tests", () => {
describe("makeMove() tests", () => {
it("should handle invalid moves", () => {
@@ -365,7 +353,6 @@ describe("Netscript Go API unit tests", () => {
it("should have a scaled chance based on layer cheat success level", () => {
Player.setBitNodeNumber(13);
initSourceFiles();
Player.queueAugmentation(AugmentationName.BrachiBlades);
Player.queueAugmentation(AugmentationName.GrapheneBrachiBlades);
Player.queueAugmentation(AugmentationName.INFRARet);