Update BotLevelGenerator tests after refactor (!399)

Fixes the failing test due to method under test being merged.

Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/399
Co-authored-by: Alex McAuliffe <alex@romanx.co.uk>
Co-committed-by: Alex McAuliffe <alex@romanx.co.uk>
This commit is contained in:
Alex McAuliffe 2024-08-19 14:10:00 +00:00 committed by chomp
parent 18d39224a9
commit e8d8e7670b
2 changed files with 12 additions and 13 deletions

View File

@ -66,9 +66,9 @@ export class BotLevelGenerator {
const minPossibleLevel =
botGenerationDetails.isPmc && botGenerationDetails.locationSpecificPmcLevelOverride
? Math.min(
Math.max(levelDetails.min, botGenerationDetails.locationSpecificPmcLevelOverride.min), // Biggest between json min and the botgen min
maxAvailableLevel, // Fallback if value above is crazy (default is 79)
)
Math.max(levelDetails.min, botGenerationDetails.locationSpecificPmcLevelOverride.min), // Biggest between json min and the botgen min
maxAvailableLevel, // Fallback if value above is crazy (default is 79)
)
: Math.min(levelDetails.min, maxAvailableLevel); // Not pmc with override or non-pmc
const maxPossibleLevel =
@ -86,6 +86,6 @@ export class BotLevelGenerator {
return {
min: minLevel,
max: maxLevel,
}
};
}
}

View File

@ -3,17 +3,14 @@ import "reflect-metadata";
import { BotLevelGenerator } from "@spt/generators/BotLevelGenerator";
import { MinMax } from "@spt/models/common/MinMax";
import { BotGenerationDetails } from "@spt/models/spt/bots/BotGenerationDetails";
import { DatabaseServer } from "@spt/servers/DatabaseServer";
import { container } from "tsyringe";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
describe("BotLevelGenerator", () => {
let botLevelGenerator: any;
let databaseServer: DatabaseServer;
let botLevelGenerator: BotLevelGenerator;
beforeEach(() => {
botLevelGenerator = container.resolve<BotLevelGenerator>("BotLevelGenerator");
databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
});
afterEach(() => {
@ -42,7 +39,7 @@ describe("BotLevelGenerator", () => {
});
});
describe("getHighestRelativeBotLevel", () => {
describe("getRelativeBotLevelRange", () => {
it("should return 10 when player level is 5 and delta is 5", () => {
const levelDetails: MinMax = { min: 5, max: 10 };
const botGenDetails: BotGenerationDetails = {
@ -57,9 +54,10 @@ describe("BotLevelGenerator", () => {
isPlayerScav: false,
};
const result = botLevelGenerator.getHighestRelativeBotLevel(botGenDetails, levelDetails, 79);
// @ts-expect-error
const result = botLevelGenerator.getRelativeBotLevelRange(botGenDetails, levelDetails, 79);
expect(result).toBe(10);
expect(result.max).toBe(10);
});
it("should return 79 when player level is above possible max (100), desired max is 100 and delta is 5", () => {
@ -76,9 +74,10 @@ describe("BotLevelGenerator", () => {
isPlayerScav: false,
};
const result = botLevelGenerator.getHighestRelativeBotLevel(botGenDetails, levelDetails, 79);
// @ts-expect-error
const result = botLevelGenerator.getRelativeBotLevelRange(botGenDetails, levelDetails, 79);
expect(result).toBe(79);
expect(result.max).toBe(79);
});
});
});