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.
This commit is contained in:
@@ -1,23 +1,26 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { createAcquisitionService } from '../../src/modules/acquisitions/services/acquisition-service.js';
|
||||
import { createAcquisitionService } from "../../src/modules/acquisitions/services/acquisition-service.js";
|
||||
|
||||
test('creates an owned acquisition and calculates cost basis', async () => {
|
||||
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 } };
|
||||
return {
|
||||
status: "CREATED",
|
||||
acquisition: { id: "acquisition-1", ...input.acquisition },
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const result = await service.create({
|
||||
sellerId: 'seller-1',
|
||||
inventoryItemId: 'inventory-1',
|
||||
method: 'PURCHASE',
|
||||
sellerId: "seller-1",
|
||||
inventoryItemId: "inventory-1",
|
||||
method: "PURCHASE",
|
||||
costMinor: 1000,
|
||||
shippingMinor: 150,
|
||||
taxMinor: 75,
|
||||
@@ -25,17 +28,27 @@ test('creates an owned acquisition and calculates cost basis', async () => {
|
||||
estimatedTradeValueMinor: 200,
|
||||
});
|
||||
|
||||
assert.equal(received.sellerId, 'seller-1');
|
||||
assert.equal(received.sellerId, "seller-1");
|
||||
assert.equal(result.costBasisMinor, 1075);
|
||||
});
|
||||
|
||||
test('rejects acquisition for an inventory item outside the seller account', async () => {
|
||||
test("rejects acquisition for an inventory item outside the seller account", async () => {
|
||||
const service = createAcquisitionService({
|
||||
acquisitionRepository: { async createForSeller() { return { status: 'NOT_FOUND' }; } },
|
||||
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,
|
||||
() =>
|
||||
service.create({
|
||||
sellerId: "seller-1",
|
||||
inventoryItemId: "inventory-1",
|
||||
method: "PURCHASE",
|
||||
costMinor: 100,
|
||||
}),
|
||||
(error) => error.code === "INVENTORY_NOT_FOUND" && error.statusCode === 404,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user