2023-11-04 12:43:04 +01:00
|
|
|
import "reflect-metadata";
|
2024-05-21 19:59:04 +02:00
|
|
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
|
|
|
import { PlayerService } from "@spt/services/PlayerService";
|
2024-07-23 17:12:53 +02:00
|
|
|
import { container } from "tsyringe";
|
|
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
2023-11-04 12:43:04 +01:00
|
|
|
|
2024-07-23 17:12:53 +02:00
|
|
|
describe("PlayerService", () => {
|
2023-11-04 14:34:09 +01:00
|
|
|
let playerService: PlayerService;
|
2023-11-04 12:43:04 +01:00
|
|
|
|
2024-07-23 17:12:53 +02:00
|
|
|
beforeEach(() => {
|
2023-11-04 12:43:04 +01:00
|
|
|
playerService = container.resolve<PlayerService>("PlayerService");
|
|
|
|
});
|
|
|
|
|
2024-07-23 17:12:53 +02:00
|
|
|
afterEach(() => {
|
2023-11-04 12:43:04 +01:00
|
|
|
vi.restoreAllMocks();
|
|
|
|
});
|
|
|
|
|
2024-07-23 17:12:53 +02:00
|
|
|
describe("calculateLevel", () => {
|
|
|
|
it("should return 1 when player xp is 0", () => {
|
2023-11-04 15:53:08 +01:00
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
2023-11-10 23:21:20 +01:00
|
|
|
Experience: 0, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
|
|
|
},
|
2023-11-04 15:53:08 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(1);
|
|
|
|
});
|
|
|
|
|
2024-07-23 17:12:53 +02:00
|
|
|
it("should return 1 when player xp is 999", () => {
|
2023-11-04 12:43:04 +01:00
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
2023-11-10 23:21:20 +01:00
|
|
|
Experience: 999, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
|
|
|
},
|
2023-11-04 12:43:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(1);
|
|
|
|
});
|
|
|
|
|
2024-07-23 17:12:53 +02:00
|
|
|
it("should return 25 when player xp is 609,066", () => {
|
2023-11-04 12:43:04 +01:00
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
2023-11-10 23:21:20 +01:00
|
|
|
Experience: 609066, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
|
|
|
},
|
2023-11-04 12:43:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(25);
|
|
|
|
});
|
|
|
|
|
2024-07-23 17:12:53 +02:00
|
|
|
it("should return 79 when player xp is 81,126,895", () => {
|
2023-11-04 12:43:04 +01:00
|
|
|
const playerProfile = {
|
|
|
|
Info: {
|
2024-04-11 05:06:40 +02:00
|
|
|
Experience: 81126895, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
|
2023-11-10 23:21:20 +01:00
|
|
|
},
|
2023-11-04 12:43:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
const result = playerService.calculateLevel(playerProfile as IPmcData);
|
|
|
|
|
|
|
|
expect(result).toBe(79);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|