2024-05-14 16:45:56 +02:00
|
|
|
import "reflect-metadata";
|
|
|
|
import { container } from "tsyringe";
|
|
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
2024-05-21 19:59:04 +02:00
|
|
|
import { BotDifficultyHelper } from "@spt/helpers/BotDifficultyHelper";
|
2024-05-14 16:45:56 +02:00
|
|
|
|
|
|
|
describe("BotHelper", () =>
|
|
|
|
{
|
|
|
|
let botDifficultyHelper: any;
|
|
|
|
|
|
|
|
beforeEach(() =>
|
|
|
|
{
|
|
|
|
botDifficultyHelper = container.resolve<BotDifficultyHelper>("BotDifficultyHelper");
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() =>
|
|
|
|
{
|
|
|
|
vi.restoreAllMocks();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("convertBotDifficultyDropdownToBotDifficulty", () =>
|
|
|
|
{
|
|
|
|
it("should return 'normal' when medium passed in", () =>
|
|
|
|
{
|
|
|
|
expect(botDifficultyHelper.convertBotDifficultyDropdownToBotDifficulty("medium")).toBe("normal");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return 'normal' when randomly capitalized medium passed in", () =>
|
|
|
|
{
|
|
|
|
expect(botDifficultyHelper.convertBotDifficultyDropdownToBotDifficulty("mEdIuM")).toBe("normal");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return passed in value when its not medium or random", () =>
|
|
|
|
{
|
|
|
|
expect(botDifficultyHelper.convertBotDifficultyDropdownToBotDifficulty("test_value")).toBe("test_value");
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return randomised value when random passed in", () =>
|
|
|
|
{
|
|
|
|
vi.spyOn(botDifficultyHelper, "chooseRandomDifficulty").mockReturnValue(
|
2024-05-21 19:59:04 +02:00
|
|
|
"randomValue",
|
2024-05-14 16:45:56 +02:00
|
|
|
);
|
|
|
|
|
|
|
|
expect(botDifficultyHelper.convertBotDifficultyDropdownToBotDifficulty("random")).toBe("randomValue");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("getBotDifficultySettings", () =>
|
2024-05-21 19:59:04 +02:00
|
|
|
{
|
|
|
|
it("should return assault bot if invalid bot type provided", () =>
|
2024-05-14 16:45:56 +02:00
|
|
|
{
|
2024-05-21 19:59:04 +02:00
|
|
|
vi.spyOn(botDifficultyHelper, "convertBotDifficultyDropdownToBotDifficulty").mockReturnValue(
|
|
|
|
"normal",
|
|
|
|
);
|
|
|
|
vi.spyOn(botDifficultyHelper.botHelper, "getBotTemplate").mockReturnValue(
|
|
|
|
{ difficulty: { normal: "test" } },
|
|
|
|
);
|
|
|
|
const warningLogSpy = vi.spyOn(botDifficultyHelper.logger, "warning");
|
|
|
|
|
|
|
|
const result = botDifficultyHelper.getBotDifficultySettings("INVALID_TYPE", "normal");
|
|
|
|
expect(result).toBe("test");
|
|
|
|
expect(warningLogSpy).toHaveBeenCalledTimes(1);
|
2024-05-14 16:45:56 +02:00
|
|
|
});
|
2024-05-21 19:59:04 +02:00
|
|
|
});
|
2024-05-14 16:45:56 +02:00
|
|
|
});
|