mirror of
https://gh.wpcy.net/https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-04-27 01:22:18 +08:00
Some checks failed
CI / PHP 7.4 (push) Has been cancelled
CI / PHP 8.0 (push) Has been cancelled
CI / PHP 8.1 (push) Has been cancelled
CI / PHP 8.2 (push) Has been cancelled
CI / PHP 8.3 (push) Has been cancelled
CI / PHP 8.4 (push) Has been cancelled
PR Playground Demo / prepare_version (push) Has been cancelled
PR Playground Demo / build_plugin (push) Has been cancelled
PR Playground Demo / create_archive (push) Has been cancelled
PR Playground Demo / Comment on PR with Playground details (push) Has been cancelled
27 lines
864 B
JavaScript
27 lines
864 B
JavaScript
import { formatPrice } from './formatPrice';
|
|
|
|
describe( 'formatPrice', () => {
|
|
|
|
const cases = [
|
|
[ 100, 'USD', '$100.00 USD' ],
|
|
[ 100, 'CAD', '$100.00 CAD' ],
|
|
[ 100, 'AUD', '$100.00 AUD' ],
|
|
[ 100, 'EUR', '€100.00' ],
|
|
[ 100, 'GBP', '£100.00' ],
|
|
[ 100.999, 'GBP', '£101.00' ],
|
|
[ 100.4, 'GBP', '£100.40' ],
|
|
];
|
|
|
|
it.each(cases)('%d %s should be formatted as %s', (amount, currency, expectation) => {
|
|
expect(formatPrice(amount, currency)).toBe(expectation);
|
|
});
|
|
|
|
it( 'should handle when currency is not supported', () => {
|
|
const spy = jest.spyOn( console, 'error').mockImplementation(() => {});
|
|
expect( formatPrice( 100.00, 'XYZ' ) ).toBe( '100.00' );
|
|
|
|
expect(spy).toHaveBeenCalledWith( 'Unsupported currency: XYZ' );
|
|
spy.mockRestore();
|
|
} );
|
|
|
|
});
|