diff --git a/project/tests/helpers/BotHelper.test.ts b/project/tests/helpers/BotHelper.test.ts new file mode 100644 index 00000000..05d89a92 --- /dev/null +++ b/project/tests/helpers/BotHelper.test.ts @@ -0,0 +1,136 @@ +import "reflect-metadata"; +import { container } from "tsyringe"; +import { vi, beforeAll, afterEach, describe, expect, it } from "vitest"; + +import { BotHelper } from "@spt-aki/helpers/BotHelper"; + +describe("BotHelper", () => +{ + let botHelper: any; + + beforeAll(() => + { + botHelper = container.resolve("BotHelper"); + }); + + afterEach(() => + { + vi.restoreAllMocks(); + }); + + describe("isBotPmc", () => + { + it("should return true when lowercase PMC role is provided", () => + { + const result = botHelper.isBotPmc("usec"); + expect(result).toBe(true); + }); + + it("should return true when uppercase PMC role is provided", () => + { + const result = botHelper.isBotPmc("SPTBEAR"); + expect(result).toBe(true); + }); + + it("should return false when legitimate non-PMC role is provided", () => + { + const result = botHelper.isBotPmc("assault"); + expect(result).toBe(false); + }); + + it("should return false when legitimate non-PMC role is provided", () => + { + const result = botHelper.isBotPmc("FLUBBUB"); + expect(result).toBe(false); + }); + + it("should return false when undefined role is provided", () => + { + const result = botHelper.isBotPmc(undefined); + expect(result).toBe(false); + }); + + it("should return false when empty string role is provided", () => + { + const result = botHelper.isBotPmc(""); + expect(result).toBe(false); + }); + }); + + describe("isBotBoss", () => + { + it("should return true when lowercase boss role is provided", () => + { + const result = botHelper.isBotBoss("bossboar"); + expect(result).toBe(true); + }); + + it("should return true when uppercase boss role is provided", () => + { + const result = botHelper.isBotBoss("BOSSBOAR"); + expect(result).toBe(true); + }); + + it("should return false when legitimate non-boss role is provided", () => + { + const result = botHelper.isBotBoss("assault"); + expect(result).toBe(false); + }); + + it("should return false when undefined role is provided", () => + { + const result = botHelper.isBotBoss(undefined); + expect(result).toBe(false); + }); + + it("should return false when empty string role is provided", () => + { + const result = botHelper.isBotBoss(""); + expect(result).toBe(false); + }); + }); + + describe("getPmcSideByRole", () => + { + it("should return `Bear` when sptBear role is provided", () => + { + const result = botHelper.getPmcSideByRole("sptBear"); + expect(result).toBe("Bear"); + }); + + it("should return `Usec` when sptBear role is provided", () => + { + const result = botHelper.getPmcSideByRole("sptUsec"); + expect(result).toBe("Usec"); + }); + + it("should return `Usec` or `Bear` when non-PMC role is provided", () => + { + const result = botHelper.getPmcSideByRole("assault"); + expect(["Usec", "Bear"]).toContain(result); + }); + + it("should return `Usec` or `Bear` when empty string role is provided", () => + { + const result = botHelper.getPmcSideByRole(""); + expect(["Usec", "Bear"]).toContain(result); + }); + }); + + describe("getRandomizedPmcSide", () => + { + it("should return `Bear` when isUsec config set to 0", () => + { + botHelper.pmcConfig.isUsec = 0; + const result = botHelper.getRandomizedPmcSide(); + expect(result).toBe("Bear"); + }); + + it("should return `Bear` when isUsec config set to 100", () => + { + botHelper.pmcConfig.isUsec = 100; + const result = botHelper.getRandomizedPmcSide(); + expect(result).toBe("Usec"); + }); + }); +}); diff --git a/project/tests/services/PlayerService.test.ts b/project/tests/services/PlayerService.test.ts index f4c93e56..dc0f9955 100644 --- a/project/tests/services/PlayerService.test.ts +++ b/project/tests/services/PlayerService.test.ts @@ -7,7 +7,7 @@ import { PlayerService } from "@spt-aki/services/PlayerService"; describe("PlayerService", () => { - let playerService: PlayerService; // Using "any" to access private/protected methods without type errors. + let playerService: PlayerService; beforeAll(() => {