Files
pokemon-inventory/apps/api/tests/application/pricing-service.test.js
T
fragginwagon 721b590a89
Quality / test (push) Canceled after 0s
feat: add pricing observation API
Add seller-owned pricing observation persistence, median market valuation calculation, admin routes, contracts, validation, migration, and focused tests.
2026-09-09 01:05:41 -04:00

26 lines
1.1 KiB
JavaScript

import assert from 'node:assert/strict';
import test from 'node:test';
import { createPricingService } from '../../src/modules/pricing/services/pricing-service.js';
test('records an owned pricing observation and calculates a valuation', async () => {
const service = createPricingService({
pricingRepository: {
async addObservationForSeller({ observation, sellerId }) {
assert.equal(sellerId, 'seller-1');
return { status: 'CREATED', observation };
},
async calculateForSeller() {
return { status: 'CALCULATED', valuation: { valueMinor: 2500 }, observations: [] };
},
},
});
const observation = await service.addObservation({
sellerId: 'seller-1', productId: 'product-1', inventoryItemId: 'inventory-1',
providerId: 'manual', priceMinor: 2500, sourceIdentifier: 'source-1', conditionId: 'condition-1',
});
assert.equal(observation.priceMinor, 2500);
const valuation = await service.calculate({ sellerId: 'seller-1', inventoryItemId: 'inventory-1' });
assert.equal(valuation.valuation.valueMinor, 2500);
});