feat(interests): CM-2 Part B — interest_berths price override (data + resolver)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
32
tests/unit/services/interest-berths-price.test.ts
Normal file
32
tests/unit/services/interest-berths-price.test.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
import { resolveBerthPriceForInterest } from '@/lib/services/interest-berths.service';
|
||||
|
||||
describe('resolveBerthPriceForInterest', () => {
|
||||
it('uses the override when present', () => {
|
||||
expect(
|
||||
resolveBerthPriceForInterest(
|
||||
{ priceOverride: '1000000', priceOverrideCurrency: 'EUR' },
|
||||
{ price: '3880800', priceCurrency: 'USD' },
|
||||
),
|
||||
).toEqual({ price: '1000000', currency: 'EUR' });
|
||||
});
|
||||
|
||||
it('falls back to the base list price when no override', () => {
|
||||
expect(
|
||||
resolveBerthPriceForInterest(
|
||||
{ priceOverride: null, priceOverrideCurrency: null },
|
||||
{ price: '3880800', priceCurrency: 'USD' },
|
||||
),
|
||||
).toEqual({ price: '3880800', currency: 'USD' });
|
||||
});
|
||||
|
||||
it('uses the base currency when the override currency is null', () => {
|
||||
expect(
|
||||
resolveBerthPriceForInterest(
|
||||
{ priceOverride: '900000', priceOverrideCurrency: null },
|
||||
{ price: '3880800', priceCurrency: 'USD' },
|
||||
),
|
||||
).toEqual({ price: '900000', currency: 'USD' });
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user