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' });
  });
});
