From b303849ad124a8d51efc97725e0b970992fa4e72 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 4 Nov 2023 10:21:56 +0000 Subject: [PATCH] Add 3 test for `getItemStackSize()` --- project/tests/helpers/ItemHelper.test.ts | 40 ++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/project/tests/helpers/ItemHelper.test.ts b/project/tests/helpers/ItemHelper.test.ts index e928d538..e6e91076 100644 --- a/project/tests/helpers/ItemHelper.test.ts +++ b/project/tests/helpers/ItemHelper.test.ts @@ -775,4 +775,44 @@ describe("ItemHelper", () => expect(result).toEqual(["3"]); }); }); + + describe("getItemStackSize", () => + { + it("should return 1 when item has no existing stack size", () => + { + const itemId = container.resolve("HashUtil").generate(); + const item: Item = { + _id: itemId, + _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" + upd: {} + }; + const result = itemHelper.getItemStackSize(item); + expect(result).toBe(1); + }); + + it("should return 1 when item has no upd property", () => + { + const itemId = container.resolve("HashUtil").generate(); + const item: Item = { + _id: itemId, + _tpl: "591094e086f7747caa7bb2ef" // "Body armor repair kit" + }; + const result = itemHelper.getItemStackSize(item); + expect(result).toBe(1); + }); + + it("should return 5 when item has existing stack size of 5", () => + { + const itemId = container.resolve("HashUtil").generate(); + const item: Item = { + _id: itemId, + _tpl: "591094e086f7747caa7bb2ef", // "Body armor repair kit" + upd: { + StackObjectsCount: 5 + } + }; + const result = itemHelper.getItemStackSize(item); + expect(result).toBe(5); + }); + }); });