Server/project/tests/services/PlayerService.test.ts
chomp 687436ab8b update 3.9.0 with 3.8.1 changes (!289)
Co-authored-by: Refringe <me@refringe.com>
Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Co-authored-by: Terkoiz <terkoiz@spt.dev>
Co-authored-by: Refringe <refringe@noreply.dev.sp-tarkov.com>
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/289
2024-04-15 07:59:33 +00:00

78 lines
2.2 KiB
TypeScript

/* eslint-disable @typescript-eslint/naming-convention */
import "reflect-metadata";
import { container } from "tsyringe";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { PlayerService } from "@spt-aki/services/PlayerService";
describe("PlayerService", () =>
{
let playerService: PlayerService;
beforeEach(() =>
{
playerService = container.resolve<PlayerService>("PlayerService");
});
afterEach(() =>
{
vi.restoreAllMocks();
});
describe("calculateLevel", () =>
{
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);
});
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 81,126,895", () =>
{
const playerProfile = {
Info: {
Experience: 81126895, // Via wiki: https://escapefromtarkov.fandom.com/wiki/Character_skills#Levels
},
};
const result = playerService.calculateLevel(playerProfile as IPmcData);
expect(result).toBe(79);
});
});
});