import { describe, expect, it } from 'vitest'
import { presentBrand } from './site.presenter'

describe('site.presenter', () => {
  it('exposes only public brand and company fields for anonymous site clients', () => {
    const result = presentBrand({
      id: 'company_1',
      slug: 'atlas-cars',
      name: 'Atlas Cars',
      phone: '+212600000000',
      brand: {
        displayName: 'Atlas Cars',
        tagline: 'Premium rentals',
        logoUrl: 'https://cdn.test/logo.png',
        amanpaySecretKey: 'must-not-leak',
        amanpayMerchantId: 'must-not-leak',
        paypalEmail: 'billing@example.com',
        paymentMethodsEnabled: ['PAYPAL'],
        defaultLocale: 'fr',
        defaultCurrency: 'MAD',
        isListedOnCarplace: true,
      },
    })

    expect(result).toMatchObject({
      company: { id: 'company_1', slug: 'atlas-cars', name: 'Atlas Cars', phone: '+212600000000' },
      brand: {
        displayName: 'Atlas Cars',
        tagline: 'Premium rentals',
        logoUrl: 'https://cdn.test/logo.png',
        paypalEmail: 'billing@example.com',
        paymentMethodsEnabled: ['PAYPAL'],
        defaultLocale: 'fr',
        defaultCurrency: 'MAD',
        isListedOnCarplace: true,
      },
    })
    expect(result.brand).not.toHaveProperty('amanpaySecretKey')
    expect(result.brand).not.toHaveProperty('amanpayMerchantId')
  })

  it('returns a null brand when company branding has not been configured', () => {
    expect(presentBrand({ id: 'company_1', slug: 'atlas-cars', name: 'Atlas Cars', phone: null, brand: null })).toEqual({
      company: { id: 'company_1', slug: 'atlas-cars', name: 'Atlas Cars', phone: null },
      brand: null,
    })
  })
})
