Add botController test
This commit is contained in:
parent
de83dee158
commit
54223f3848
@ -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";
|
||||||
@ -13,4 +14,4 @@ import "@tests/helpers/ItemHelper.test";
|
|||||||
//Services
|
//Services
|
||||||
import "@tests/services/ItemBaseClassService.test";
|
import "@tests/services/ItemBaseClassService.test";
|
||||||
import "@tests/services/PaymentService.test";
|
import "@tests/services/PaymentService.test";
|
||||||
import "@tests/services/PlayerService.test";
|
import "@tests/services/PlayerService.test";
|
56
project/tests/generators/BotGenerator.test.ts
Normal file
56
project/tests/generators/BotGenerator.test.ts
Normal 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");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user