Server/project/tests/services/ProfileFixerService.test.ts
DrakiaXYZ 316234e9ae Fix TradersInfo nextResupply if it is null in profile data (!305)
Add test covering fixNullTraderNextResupply

Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/305
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-04-24 07:13:31 +00:00

40 lines
1.2 KiB
TypeScript

import { ProfileFixerService } from "@spt-aki/services/ProfileFixerService";
import { container } from "tsyringe";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
describe("ProfileFixerService", () =>
{
let profileFixerService: any; // Using "any" to access private/protected methods without type errors.
beforeEach(() =>
{
profileFixerService = container.resolve<ProfileFixerService>("ProfileFixerService");
});
afterEach(() =>
{
vi.restoreAllMocks();
});
describe("FixPmcProfileIssues", () =>
{
it("should reset nextResupply to 0 when it is null", () =>
{
const pmcProfile = { TradersInfo: { traderId: { nextResupply: null } } };
profileFixerService.fixNullTraderNextResupply(pmcProfile);
expect(pmcProfile.TradersInfo.traderId.nextResupply).toBe(0);
});
it("should not reset nextResupply to 0 when it is not null", () =>
{
const pmcProfile = { TradersInfo: { traderId: { nextResupply: 1234 } } };
profileFixerService.fixNullTraderNextResupply(pmcProfile);
expect(pmcProfile.TradersInfo.traderId.nextResupply).toBe(1234);
});
});
});