Add isInStash()
tests to PaymentService.tests
This commit is contained in:
parent
b303849ad1
commit
ebe7dc68c3
@ -14,7 +14,7 @@ import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
|
||||
describe("PaymentService", () =>
|
||||
{
|
||||
let paymentService: PaymentService;
|
||||
let paymentService: any; // Using "any" to access private/protected methods without type errors.
|
||||
|
||||
beforeAll(() =>
|
||||
{
|
||||
@ -143,4 +143,97 @@ describe("PaymentService", () =>
|
||||
expect(traderHelperLvlUpSpy).toBeCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe("isInStash", () =>
|
||||
{
|
||||
it("should return true when item is direct parent of stash", () =>
|
||||
{
|
||||
const hashUtil = container.resolve<HashUtil>("HashUtil");
|
||||
const stashItem: Item = {
|
||||
_id: "stashid",
|
||||
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id
|
||||
};
|
||||
|
||||
const inventoryItemToFind: Item = {
|
||||
_id: hashUtil.generate(),
|
||||
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
|
||||
parentId: stashItem._id,
|
||||
slotId: "hideout"
|
||||
};
|
||||
const playerInventory = [stashItem, inventoryItemToFind];
|
||||
|
||||
const result = paymentService.isInStash(inventoryItemToFind._id, playerInventory, stashItem._id);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("should return true when item is indirect parent of inventory", () =>
|
||||
{
|
||||
const hashUtil = container.resolve<HashUtil>("HashUtil");
|
||||
const stashItem: Item = {
|
||||
_id: "stashId",
|
||||
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id
|
||||
};
|
||||
|
||||
const foodBagToHoldItemToFind: Item = {
|
||||
_id: hashUtil.generate(),
|
||||
_tpl: "5c093db286f7740a1b2617e3",
|
||||
parentId: stashItem._id,
|
||||
slotId: "hideout"
|
||||
};
|
||||
|
||||
const inventoryItemToFind: Item = {
|
||||
_id: hashUtil.generate(),
|
||||
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
|
||||
parentId: foodBagToHoldItemToFind._id
|
||||
};
|
||||
const playerInventory = [stashItem, foodBagToHoldItemToFind, inventoryItemToFind];
|
||||
|
||||
const result = paymentService.isInStash(inventoryItemToFind._id, playerInventory, stashItem._id);
|
||||
|
||||
expect(result).toBe(true);
|
||||
});
|
||||
|
||||
it("should return false when desired item is not in inventory", () =>
|
||||
{
|
||||
const hashUtil = container.resolve<HashUtil>("HashUtil");
|
||||
const stashItem: Item = {
|
||||
_id: "stashId",
|
||||
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id
|
||||
};
|
||||
|
||||
const inventoryItemToFind: Item = {
|
||||
_id: hashUtil.generate(),
|
||||
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
|
||||
parentId: stashItem._id,
|
||||
slotId: "hideout"
|
||||
};
|
||||
const playerInventory = [stashItem, inventoryItemToFind];
|
||||
|
||||
const result = paymentService.isInStash("notCorrectId", playerInventory, stashItem._id);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
|
||||
it("should return false when player inventory array has no inventory item", () =>
|
||||
{
|
||||
const hashUtil = container.resolve<HashUtil>("HashUtil");
|
||||
const stashItem: Item = {
|
||||
_id: "stashId",
|
||||
_tpl: "55d7217a4bdc2d86028b456d" // standard stash id
|
||||
};
|
||||
|
||||
const inventoryItemToFind: Item = {
|
||||
_id: hashUtil.generate(),
|
||||
_tpl: "544fb6cc4bdc2d34748b456e", // Slickers chocolate bar
|
||||
parentId: stashItem._id,
|
||||
slotId: "hideout"
|
||||
};
|
||||
const playerInventory = [ inventoryItemToFind];
|
||||
|
||||
const result = paymentService.isInStash("notCorrectId", playerInventory, stashItem._id);
|
||||
|
||||
expect(result).toBe(false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user