Mocks some logger methods to prevent actual execution.
This commit is contained in:
parent
4e33befaa0
commit
f5c379e189
@ -312,12 +312,18 @@ describe("ItemHelper", () =>
|
|||||||
|
|
||||||
const parentId = container.resolve<HashUtil>("HashUtil").generate();
|
const parentId = container.resolve<HashUtil>("HashUtil").generate();
|
||||||
|
|
||||||
const loggerWarningSpy = vi.spyOn((itemHelper as any).logger, "warning");
|
// Spy on the logger's warning method and mock its implementation to prevent it from being actually called.
|
||||||
|
const loggerWarningSpy = vi.spyOn((itemHelper as any).logger, "warning").mockImplementation(() =>
|
||||||
|
{});
|
||||||
|
|
||||||
itemHelper.generateItemsFromStackSlot(ammoBox[1], parentId);
|
itemHelper.generateItemsFromStackSlot(ammoBox[1], parentId);
|
||||||
|
|
||||||
expect(loggerWarningSpy).toHaveBeenCalled();
|
expect(loggerWarningSpy).toHaveBeenCalled();
|
||||||
|
|
||||||
|
// Restore the original behavior
|
||||||
|
loggerWarningSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("getItems", () =>
|
describe("getItems", () =>
|
||||||
@ -671,9 +677,14 @@ describe("ItemHelper", () =>
|
|||||||
_tpl: ""
|
_tpl: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Mock the logger's error method to prevent it from being actually called.
|
||||||
|
const loggerErrorSpy = vi.spyOn((itemHelper as any).logger, "error").mockImplementation(() =>
|
||||||
|
{});
|
||||||
|
|
||||||
// Cast the method to any to allow access to private/protected method.
|
// Cast the method to any to allow access to private/protected method.
|
||||||
const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item);
|
const result = (itemHelper as any).getRepairableItemQualityValue(weapon, repairable, item);
|
||||||
|
|
||||||
|
expect(loggerErrorSpy).toHaveBeenCalled();
|
||||||
expect(result).toBe(1);
|
expect(result).toBe(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user