File "price.js"

Full Path: /home/vantageo/public_html/cache/cache/cache/cache/cache/cache/cache/cache/cache/.wp-cli/wp-content/plugins/woocommerce/packages/woocommerce-blocks/packages/prices/utils/test/price.js
File size: 902 bytes
MIME-type: text/x-java
Charset: utf-8

/**
 * Internal dependencies
 */
import { formatPrice, getCurrency } from '../price';

describe( 'formatPrice', () => {
	test.each`
		value          | prefix   | suffix   | expected
		${ 1000 }      | ${ '€' } | ${ '' }  | ${ '€10' }
		${ 1000 }      | ${ '' }  | ${ '€' } | ${ '10€' }
		${ 1000 }      | ${ '' }  | ${ '$' } | ${ '10$' }
		${ '1000' }    | ${ '€' } | ${ '' }  | ${ '€10' }
		${ 0 }         | ${ '€' } | ${ '' }  | ${ '€0' }
		${ '' }        | ${ '€' } | ${ '' }  | ${ '' }
		${ null }      | ${ '€' } | ${ '' }  | ${ '' }
		${ undefined } | ${ '€' } | ${ '' }  | ${ '' }
	`(
		'correctly formats price given "$value", "$prefix" prefix, and "$suffix" suffix',
		( { value, prefix, suffix, expected } ) => {
			const formattedPrice = formatPrice(
				value,
				getCurrency( { prefix, suffix } )
			);

			expect( formattedPrice ).toEqual( expected );
		}
	);
} );