Add botController test

This commit is contained in:
Dev 2023-11-05 20:11:52 +00:00
parent de83dee158
commit 54223f3848
2 changed files with 58 additions and 1 deletions

View File

@ -3,6 +3,7 @@ import "@tests/controllers/InsuranceController.test";
//Generators //Generators
import "@tests/generators/BotLevelGenerator.test"; import "@tests/generators/BotLevelGenerator.test";
import "@tests/generators/BotGenerator.test";
//Helpers //Helpers
import "@tests/helpers/BotHelper.test"; import "@tests/helpers/BotHelper.test";

View File

@ -0,0 +1,56 @@
/* eslint-disable @typescript-eslint/naming-convention */
import "reflect-metadata";
import { container } from "tsyringe";
import { vi, beforeAll, afterEach, describe, expect, it } from "vitest";
import { BotGenerator } from "@spt-aki/generators/BotGenerator";
import { BotGenerationDetails } from "@spt-aki/models/spt/bots/BotGenerationDetails";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
describe("BotGenerator", () =>
{
let botGenerator: any;
beforeAll(() =>
{
botGenerator = container.resolve<BotGenerator>("BotGenerator");
});
afterEach(() =>
{
vi.restoreAllMocks();
});
describe("prepareAndGenerateBots", () =>
{
it("should return a single generated assault bot", () =>
{
const mockPlayerProfile = {
Info: {
Nickname: "Player Nickname",
Level: 1
}
};
vi.spyOn(botGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
vi.spyOn(botGenerator.botEquipmentFilterService.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
vi.spyOn(botGenerator.botInventoryGenerator.botWeaponGenerator.botEquipmentModGenerator.profileHelper, "getPmcProfile").mockReturnValue(<IPmcData>mockPlayerProfile);
const sessionId = "12345";
const generationDetails: BotGenerationDetails = {
isPmc: false,
role: "assault",
side: "Savage",
playerLevel: 1,
botRelativeLevelDeltaMax: 10,
botCountToGenerate: 1,
botDifficulty: "easy",
isPlayerScav: false
};
const result = botGenerator.prepareAndGenerateBots(sessionId, generationDetails);
expect(result.length).toBe(1);
expect(result[0].Info.Side).toBe("Savage");
});
});
});