import { formatCurrency } from '../shared/utils/currency'; describe( 'formatCurrency', () => { // ---- Positive tests ---- it( 'formats a GBP amount', () => { const result = formatCurrency( 9.99, 'GBP' ); expect( result ).toContain( '9.99' ); } ); it( 'formats an EUR amount', () => { const result = formatCurrency( 12.5, 'EUR' ); expect( result ).toContain( '12' ); } ); it( 'formats a USD amount', () => { const result = formatCurrency( 100, 'USD' ); expect( result ).toContain( '100' ); } ); it( 'defaults to GBP when currency is omitted', () => { const result = formatCurrency( 5 ); expect( result ).toContain( '5' ); } ); it( 'formats zero correctly', () => { const result = formatCurrency( 0, 'GBP' ); expect( result ).toContain( '0' ); } ); // ---- Negative tests ---- it( 'does not throw for an invalid currency code — falls back gracefully', () => { expect( () => formatCurrency( 5, 'NOTACURRENCY' ) ).not.toThrow(); } ); it( 'fallback result still contains the numeric amount', () => { const result = formatCurrency( 42.5, 'NOTACURRENCY' ); expect( result ).toContain( '42' ); } ); } );