mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 14:59:16 +02:00
DARKNET: Darkweb Expansion Project & Bitnode (#2139)
This is BN15. It is a really big change; see the PR for all the details.
This commit is contained in:
committed by
GitHub
parent
a674633f6c
commit
6073964768
@@ -1,9 +1,9 @@
|
||||
import { installAugmentations } from "../../../src/Augmentation/AugmentationHelpers";
|
||||
import { blackOpsArray } from "../../../src/Bladeburner/data/BlackOperations";
|
||||
import { AugmentationName, CompanyName, FactionName, JobField, JobName } from "@enums";
|
||||
import { AugmentationName, CompanyName, CompletedProgramName, FactionName, JobField, JobName } from "@enums";
|
||||
import { Player } from "@player";
|
||||
import { prestigeSourceFile } from "../../../src/Prestige";
|
||||
import { GetServerOrThrow } from "../../../src/Server/AllServers";
|
||||
import { disconnectServers, GetServerOrThrow } from "../../../src/Server/AllServers";
|
||||
import { SpecialServers } from "../../../src/Server/data/SpecialServers";
|
||||
import { Factions } from "../../../src/Faction/Factions";
|
||||
import { PlayerOwnedAugmentation } from "../../../src/Augmentation/PlayerOwnedAugmentation";
|
||||
@@ -12,6 +12,8 @@ import { Terminal } from "../../../src/Terminal";
|
||||
import type { NSFull } from "../../../src/NetscriptFunctions";
|
||||
import { Companies } from "../../../src/Company/Companies";
|
||||
import { CompanyPositions } from "../../../src/Company/CompanyPositions";
|
||||
import { getTorRouter } from "../../../src/Server/ServerHelpers";
|
||||
import * as exceptionAlertModule from "../../../src/utils/helpers/exceptionAlert";
|
||||
|
||||
const nextBN = 3;
|
||||
|
||||
@@ -446,3 +448,73 @@ describe("applyToCompany", () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("purchaseProgram", () => {
|
||||
beforeEach(() => {
|
||||
setupBasicTestingEnvironment();
|
||||
prestigeSourceFile(true);
|
||||
Player.money = 1e15;
|
||||
getTorRouter();
|
||||
});
|
||||
|
||||
describe("Success", () => {
|
||||
beforeEach(() => {
|
||||
const ns = getNS();
|
||||
expect(ns.singularity.purchaseTor()).toStrictEqual(true);
|
||||
});
|
||||
test("return true if already bought", () => {
|
||||
const ns = getNS();
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
Player.getHomeComputer().pushProgram(CompletedProgramName.bruteSsh);
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(true);
|
||||
expect(ns.singularity.purchaseProgram(CompletedProgramName.bruteSsh)).toStrictEqual(true);
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(true);
|
||||
});
|
||||
test("bruteSsh", () => {
|
||||
const ns = getNS();
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
expect(ns.singularity.purchaseProgram(CompletedProgramName.bruteSsh)).toStrictEqual(true);
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(true);
|
||||
});
|
||||
test("darkscape", () => {
|
||||
const spiedExceptionAlert = jest.spyOn(exceptionAlertModule, "exceptionAlert");
|
||||
const ns = getNS();
|
||||
expect(Player.hasProgram(CompletedProgramName.darkscape)).toStrictEqual(false);
|
||||
expect(ns.singularity.purchaseProgram(CompletedProgramName.darkscape)).toStrictEqual(true);
|
||||
expect(Player.hasProgram(CompletedProgramName.darkscape)).toStrictEqual(true);
|
||||
expect(spiedExceptionAlert).not.toHaveBeenCalled();
|
||||
});
|
||||
test("darkscape with lowercase program name", () => {
|
||||
const spiedExceptionAlert = jest.spyOn(exceptionAlertModule, "exceptionAlert");
|
||||
const ns = getNS();
|
||||
expect(Player.hasProgram(CompletedProgramName.darkscape)).toStrictEqual(false);
|
||||
expect(ns.singularity.purchaseProgram(CompletedProgramName.darkscape.toLowerCase())).toStrictEqual(true);
|
||||
expect(Player.hasProgram(CompletedProgramName.darkscape)).toStrictEqual(true);
|
||||
expect(spiedExceptionAlert).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("Failure", () => {
|
||||
test("No TOR", () => {
|
||||
// Remove TOR router
|
||||
disconnectServers(Player.getHomeComputer(), GetServerOrThrow(SpecialServers.DarkWeb));
|
||||
|
||||
const ns = getNS();
|
||||
expect(Player.hasTorRouter()).toStrictEqual(false);
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
expect(ns.singularity.purchaseProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
});
|
||||
test("Invalid program name", () => {
|
||||
const ns = getNS();
|
||||
expect(ns.singularity.purchaseProgram("InvalidProgram.exe")).toStrictEqual(false);
|
||||
});
|
||||
test("Not enough money", () => {
|
||||
const ns = getNS();
|
||||
Player.money = 0;
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
expect(ns.singularity.purchaseProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
expect(Player.hasProgram(CompletedProgramName.bruteSsh)).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user