mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-22 17:23:00 +02:00
CODEBASE: Validate AllGangs and StockMarket after loading with JSON.parse (#1783)
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
import { getDefaultAllGangs } from "../../../src/Gang/AllGangs";
|
||||
import { JsonSchemaValidator } from "../../../src/JsonSchema/JsonSchemaValidator";
|
||||
|
||||
describe("Success", () => {
|
||||
test("Default AllGangs", () => {
|
||||
const defaultAllGangs = getDefaultAllGangs();
|
||||
expect(JsonSchemaValidator.AllGangs(defaultAllGangs)).toStrictEqual(true);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Failure", () => {
|
||||
test("Do not have all gangs", () => {
|
||||
const defaultAllGangs = getDefaultAllGangs() as Record<string, unknown>;
|
||||
delete defaultAllGangs["Slum Snakes"];
|
||||
expect(JsonSchemaValidator.AllGangs(defaultAllGangs)).toStrictEqual(false);
|
||||
});
|
||||
test("Have an unexpected gang", () => {
|
||||
const defaultAllGangs = getDefaultAllGangs() as Record<string, unknown>;
|
||||
defaultAllGangs["CyberSec"] = {
|
||||
power: 1,
|
||||
territory: 1 / 7,
|
||||
};
|
||||
expect(JsonSchemaValidator.AllGangs(defaultAllGangs)).toStrictEqual(false);
|
||||
});
|
||||
test("Have invalid power", () => {
|
||||
const defaultAllGangs = getDefaultAllGangs() as Record<string, unknown>;
|
||||
defaultAllGangs["Slum Snakes"] = {
|
||||
power: "1",
|
||||
territory: 1 / 7,
|
||||
};
|
||||
expect(JsonSchemaValidator.AllGangs(defaultAllGangs)).toStrictEqual(false);
|
||||
});
|
||||
test("Have invalid territory", () => {
|
||||
const defaultAllGangs = getDefaultAllGangs() as Record<string, unknown>;
|
||||
defaultAllGangs["Slum Snakes"] = {
|
||||
power: 1,
|
||||
territory: "1 / 7",
|
||||
};
|
||||
expect(JsonSchemaValidator.AllGangs(defaultAllGangs)).toStrictEqual(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user