Files
pokemon-inventory/apps/api/tests/application/acquisition-service.test.js
T
fragginwagon b8f089a5d9 feat: reconcile application vertical slices
Backfill the completed acquisitions, sales, dashboard, pricing, search, public detail, worker, migration, contracts, validation, tests, and implementation-status changes into one verified application slice.
2026-09-09 22:12:53 -04:00

55 lines
1.4 KiB
JavaScript

import assert from "node:assert/strict";
import test from "node:test";
import { createAcquisitionService } from "../../src/modules/acquisitions/services/acquisition-service.js";
test("creates an owned acquisition and calculates cost basis", async () => {
let received;
const service = createAcquisitionService({
acquisitionRepository: {
async createForSeller(input) {
received = input;
return {
status: "CREATED",
acquisition: { id: "acquisition-1", ...input.acquisition },
};
},
},
});
const result = await service.create({
sellerId: "seller-1",
inventoryItemId: "inventory-1",
method: "PURCHASE",
costMinor: 1000,
shippingMinor: 150,
taxMinor: 75,
otherFeesMinor: 50,
estimatedTradeValueMinor: 200,
});
assert.equal(received.sellerId, "seller-1");
assert.equal(result.costBasisMinor, 1075);
});
test("rejects acquisition for an inventory item outside the seller account", async () => {
const service = createAcquisitionService({
acquisitionRepository: {
async createForSeller() {
return { status: "NOT_FOUND" };
},
},
});
await assert.rejects(
() =>
service.create({
sellerId: "seller-1",
inventoryItemId: "inventory-1",
method: "PURCHASE",
costMinor: 100,
}),
(error) => error.code === "INVENTORY_NOT_FOUND" && error.statusCode === 404,
);
});