mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 06:48:42 +02:00
MISC: Refactor BLADEBURNER Identifier Lookup (#1646)
This commit is contained in:
38
test/jest/Netscript/Bladeburner/TerminalMatching.test.ts
Normal file
38
test/jest/Netscript/Bladeburner/TerminalMatching.test.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { autoCompleteTypeShorthand, TerminalShorthands } from "../../../../src/Bladeburner/utils/terminalShorthands";
|
||||
import {
|
||||
BladeburnerActionType,
|
||||
BladeburnerBlackOpName,
|
||||
BladeburnerContractName,
|
||||
BladeburnerGeneralActionName,
|
||||
BladeburnerOperationName,
|
||||
} from "@enums";
|
||||
|
||||
const ShorthandCases = (type: keyof typeof TerminalShorthands) => <string[][]>TerminalShorthands[type].map(Array);
|
||||
|
||||
describe("Bladeburner Actions", () => {
|
||||
const EXAMPLES = [
|
||||
[BladeburnerActionType.General, BladeburnerGeneralActionName.Diplomacy],
|
||||
[BladeburnerActionType.BlackOp, BladeburnerBlackOpName.OperationTyphoon],
|
||||
[BladeburnerActionType.Contract, BladeburnerContractName.BountyHunter],
|
||||
[BladeburnerActionType.Operation, BladeburnerOperationName.Assassination],
|
||||
] as const;
|
||||
|
||||
describe("May be described with shorthands", () => {
|
||||
describe.each(EXAMPLES)("Type: %s", (type, name) => {
|
||||
it.each(ShorthandCases(type))("%s", (shorthand) => {
|
||||
const action = autoCompleteTypeShorthand(shorthand, name);
|
||||
expect(action).toMatchObject({ type, name });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it("Does not match for existing action where type differs", () => {
|
||||
const action = autoCompleteTypeShorthand(BladeburnerActionType.Contract, BladeburnerOperationName.Assassination);
|
||||
expect(action).toBeNull();
|
||||
});
|
||||
|
||||
it("Does not match for undocumented shorthands", () => {
|
||||
const action = autoCompleteTypeShorthand("blackoperations", BladeburnerOperationName.Assassination);
|
||||
expect(action).toBeNull();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user