Add seller-owned pricing observation persistence, median market valuation calculation, admin routes, contracts, validation, migration, and focused tests.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user