BlueGit

timfa questward

Files

questward / server / tests / marketplace.test.js

marketplace.test.js

marketplace.test.js 1.0 KiB Download Raw
1import test from "node:test";
2import assert from "node:assert/strict";
3import { ItemId } from "../../shared/definitions/items.js";
4import { canSellOnMarketplace, assertMarketplaceSellable } from "../../shared/items/marketplace.js";
5
6test("blank cheques cannot be listed on the marketplace", () =>
7{
8 const stack = { itemId: ItemId.blankCheque, quantity: 1 };
9 assert.equal(canSellOnMarketplace(stack), false);
10 assert.throws(
11 () => assertMarketplaceSellable(stack),
12 (err) => err.message === "Blank cheques cannot be sold on the marketplace."
13 );
14});
15
16test("written cheques can be listed on the marketplace", () =>
17{
18 const stack = {
19 itemId: ItemId.filledCheque,
20 quantity: 1,
21 instance: { kind: "filled-cheque", chequeId: "x", issuerCharacterId: 1, itemId: ItemId.apple, quantity: 2 }
22 };
23 assert.equal(canSellOnMarketplace(stack), true);
24 assert.doesNotThrow(() => assertMarketplaceSellable(stack));
25});
26
27test("normal items are marketplace sellable by default", () =>
28{
29 assert.equal(canSellOnMarketplace({ itemId: ItemId.apple, quantity: 3 }), true);
30});