2023-11-04 12:43:04 +01:00
|
|
|
/* eslint-disable @typescript-eslint/naming-convention */
|
|
|
|
import "reflect-metadata";
|
|
|
|
import { container } from "tsyringe";
|
2023-11-06 20:39:12 +01:00
|
|
|
import { vi, beforeEach, afterEach, describe, expect, it } from "vitest";
|
|
|
|
|
2023-11-04 12:43:04 +01:00
|
|
|
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
|
|
|
import { PlayerService } from "@spt-aki/services/PlayerService";
|
|
|
|
|
|
|
|
describe("PlayerService", () =>
|
|
|
|
{
|
2023-11-04 14:34:09 +01:00
|
|
|
let playerService: PlayerService;
|
2023-11-04 12:43:04 +01:00
|
|
|
|
2023-11-06 20:39:12 +01:00
|
|
|
beforeEach(() =>
|
2023-11-04 12:43:04 +01:00
|
|
|
{
|
|
|
|
playerService = container.resolve<PlayerService>("PlayerService");
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(() =>
|
|
|
|
{
|
|
|
|
vi.restoreAllMocks();
|
|
|
|
});
|
|
|
|
|
|
|
|
describe("calculateLevel", () =>
|
|
|
|
{
|
2023-11-04 15:53:08 +01:00
|
|
|
it("should return 1 when player xp is 0", () =>
|
|
|
|
{
|
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
|
|
|
Experience: 0 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(1);
|
|
|
|
});
|
|
|
|
|
2023-11-04 12:43:04 +01:00
|
|
|
it("should return 1 when player xp is 999", () =>
|
|
|
|
{
|
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
|
|
|
Experience: 999 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(1);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return 25 when player xp is 609,066", () =>
|
|
|
|
{
|
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
|
|
|
Experience: 609066 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(25);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should return 79 when player xp is 68,206,066", () =>
|
|
|
|
{
|
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
|
|
|
Experience: 68206066 // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(79);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|