This commit is contained in:
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { createPricingProvider, createPricingProviderRegistry } from '../../src/modules/pricing/providers/pricing-provider.js';
|
||||
import { createFixturePricingProvider } from '../../src/modules/pricing/providers/fixture-pricing-provider.js';
|
||||
|
||||
test('registers pricing providers behind a validated adapter contract', async () => {
|
||||
const provider = createPricingProvider({
|
||||
@@ -19,4 +20,19 @@ test('rejects malformed provider adapters and responses', async () => {
|
||||
assert.throws(() => createPricingProvider({ id: 'broken' }), /observe function is required/);
|
||||
const provider = createPricingProvider({ id: 'broken', async observe() { return null; } });
|
||||
await assert.rejects(() => provider.observe({}), /must return an observation array/);
|
||||
});
|
||||
|
||||
test('fixture provider returns deterministic normalized observations', async () => {
|
||||
const [observation] = await createFixturePricingProvider().observe({
|
||||
productId: 'product-1', inventoryItemId: 'item-1', conditionId: 'condition-1',
|
||||
});
|
||||
assert.deepEqual(observation, {
|
||||
productId: 'product-1',
|
||||
inventoryItemId: 'item-1',
|
||||
conditionId: 'condition-1',
|
||||
priceMinor: 2500,
|
||||
currency: 'USD',
|
||||
sourceIdentifier: 'fixture-item-1',
|
||||
qualityScore: 50,
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user