import { test, expect, cel, describe } from './setup.js';
import { PricingService } from '../src/service.js';
describe('pricing', () => {
test('bulk discount applies at 10+', async ({ varianz }) => {
await varianz.insert(cel(
'pricing/calculate',
'args.input.quantity >= 10 ' +
'? PricingResult { totalPrice: args.input.basePrice * args.input.quantity * 0.9, discountApplied: true } ' +
': invoke()',
));
await varianz.awaitSyncOrFail(5_000);
// The fixture has already entered the session scope for the test body —
// in-process calls match session stages without extra wiring.
const out = new PricingService().calculate(input);
expect(out.totalPrice).toBeCloseTo(108);
await expect(varianz).toEventuallyHaveSample('price-result', { within: 5_000 });
});
});