| 1 | import test from "node:test"; |
| 2 | import assert from "node:assert/strict"; |
| 3 | import { ItemId } from "../../shared/definitions/items.js"; |
| 4 | import { canSellOnMarketplace, assertMarketplaceSellable } from "../../shared/items/marketplace.js"; |
| 5 | |
| 6 | test("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 | |
| 16 | test("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 | |
| 27 | test("normal items are marketplace sellable by default", () => |
| 28 | { |
| 29 | assert.equal(canSellOnMarketplace({ itemId: ItemId.apple, quantity: 3 }), true); |
| 30 | }); |