2024-04-24 09:13:31 +02:00
|
|
|
import { container } from "tsyringe";
|
|
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
2024-05-21 19:59:04 +02:00
|
|
|
import { ProfileFixerService } from "@spt/services/ProfileFixerService";
|
2024-04-24 09:13:31 +02:00
|
|
|
|
|
|
|
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", () =>
|
|
|
|
{
|
2024-05-28 20:52:21 +02:00
|
|
|
it("should reset nextResupply to 0 when it is undefined", () =>
|
2024-04-24 09:13:31 +02:00
|
|
|
{
|
2024-05-28 20:52:21 +02:00
|
|
|
const pmcProfile = { TradersInfo: { traderId: { nextResupply: undefined } } };
|
2024-04-24 09:13:31 +02:00
|
|
|
|
|
|
|
profileFixerService.fixNullTraderNextResupply(pmcProfile);
|
|
|
|
|
|
|
|
expect(pmcProfile.TradersInfo.traderId.nextResupply).toBe(0);
|
|
|
|
});
|
|
|
|
|
2024-05-28 20:52:21 +02:00
|
|
|
it("should not reset nextResupply to 0 when it is not undefined", () =>
|
2024-04-24 09:13:31 +02:00
|
|
|
{
|
|
|
|
const pmcProfile = { TradersInfo: { traderId: { nextResupply: 1234 } } };
|
|
|
|
|
|
|
|
profileFixerService.fixNullTraderNextResupply(pmcProfile);
|
|
|
|
|
|
|
|
expect(pmcProfile.TradersInfo.traderId.nextResupply).toBe(1234);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|