/**
* External dependencies
*/
import { render, screen } from '@testing-library/react';
/**
* Internal dependencies
*/
import FormattedMonetaryAmount from '../index';
describe( 'FormattedMonetaryAmount', () => {
describe( 'separators', () => {
test( 'should add the thousand separator', () => {
render(
);
expect( screen.getByText( '1.563,45 €' ) ).toBeInTheDocument();
} );
test( 'should not add thousand separator', () => {
render(
);
expect( screen.getByText( '1563,45 €' ) ).toBeInTheDocument();
} );
test( 'should remove the thousand separator when identical to the decimal one', () => {
render(
);
expect( console ).toHaveWarned();
expect( screen.getByText( '1563,45 €' ) ).toBeInTheDocument();
} );
} );
describe( 'suffix/prefix', () => {
test( 'should add the currency suffix', () => {
render(
);
expect( screen.getByText( '0,15 €' ) ).toBeInTheDocument();
} );
test( 'should add the currency prefix', () => {
render(
);
expect( screen.getByText( '€ 0,15' ) ).toBeInTheDocument();
} );
} );
describe( 'supports different value types', () => {
test( 'should support numbers', () => {
render(
);
expect( screen.getByText( '15 €' ) ).toBeInTheDocument();
} );
test( 'should support strings', () => {
render(
);
expect( screen.getByText( '€ 15' ) ).toBeInTheDocument();
} );
} );
} );