0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 05:30:43 -05:00

Updated bot tests

This commit is contained in:
Alex McAuliffe 2024-08-19 14:10:00 +00:00 committed by Dev
parent 9e9baf49b3
commit 79f0949610
2 changed files with 34 additions and 14 deletions

View File

@ -86,6 +86,6 @@ export class BotLevelGenerator {
return { return {
min: minLevel, min: minLevel,
max: maxLevel, max: maxLevel,
} };
} }
} }

View File

@ -3,17 +3,14 @@ import "reflect-metadata";
import { BotLevelGenerator } from "@spt/generators/BotLevelGenerator"; import { BotLevelGenerator } from "@spt/generators/BotLevelGenerator";
import { MinMax } from "@spt/models/common/MinMax"; import { MinMax } from "@spt/models/common/MinMax";
import { BotGenerationDetails } from "@spt/models/spt/bots/BotGenerationDetails"; import { BotGenerationDetails } from "@spt/models/spt/bots/BotGenerationDetails";
import { DatabaseServer } from "@spt/servers/DatabaseServer";
import { container } from "tsyringe"; import { container } from "tsyringe";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
describe("BotLevelGenerator", () => { describe("BotLevelGenerator", () => {
let botLevelGenerator: any; let botLevelGenerator: BotLevelGenerator;
let databaseServer: DatabaseServer;
beforeEach(() => { beforeEach(() => {
botLevelGenerator = container.resolve<BotLevelGenerator>("BotLevelGenerator"); botLevelGenerator = container.resolve<BotLevelGenerator>("BotLevelGenerator");
databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
}); });
afterEach(() => { afterEach(() => {
@ -42,22 +39,45 @@ describe("BotLevelGenerator", () => {
}); });
}); });
describe("chooseBotLevel", () => { describe("getRelativeBotLevelRange", () => {
it("should return 10 when player level is 5 and delta is 5", () => { it("should return 10 when player level is 5 and delta is 5", () => {
const levelDetails: MinMax = { min: 5, max: 10 }; const levelDetails: MinMax = { min: 5, max: 10 };
const botGenDetails: BotGenerationDetails = {
isPmc: false,
role: "",
side: "",
botRelativeLevelDeltaMax: 5,
botRelativeLevelDeltaMin: 5,
playerLevel: 5,
botCountToGenerate: 0,
botDifficulty: "",
isPlayerScav: false,
};
const result = botLevelGenerator.chooseBotLevel(levelDetails.min, levelDetails.max, 1, 1.15); // @ts-expect-error
const result = botLevelGenerator.getRelativeBotLevelRange(botGenDetails, levelDetails, 79);
expect(result).greaterThanOrEqual(5); expect(result.max).toBe(10);
expect(result).lessThanOrEqual(10);
}); });
it("should return 79 when player level is above possible max (100), desired max is 100 and delta is 5", () => { it("should return 79 when player level is above possible max (100), desired max is 100 and delta is 5", () => {
const levelDetails: MinMax = { min: 100, max: 100 }; const levelDetails: MinMax = { min: 100, max: 100 };
const botGenDetails: BotGenerationDetails = {
isPmc: false,
role: "",
side: "",
botRelativeLevelDeltaMax: 5,
botRelativeLevelDeltaMin: 5,
playerLevel: 100,
botCountToGenerate: 0,
botDifficulty: "",
isPlayerScav: false,
};
const result = botLevelGenerator.chooseBotLevel(levelDetails.min, levelDetails.max, 1, 1.15); // @ts-expect-error
const result = botLevelGenerator.getRelativeBotLevelRange(botGenDetails, levelDetails, 79);
expect(result).toBe(100); expect(result.max).toBe(79);
}); });
}); });
}); });