40 lines
1.1 KiB
JavaScript
40 lines
1.1 KiB
JavaScript
|
/**
|
||
|
* External dependencies
|
||
|
*/
|
||
|
import renderer from 'react-test-renderer';
|
||
|
|
||
|
/**
|
||
|
* Internal dependencies
|
||
|
*/
|
||
|
import { ProductPreview } from '../products-block';
|
||
|
|
||
|
describe( 'ProductPreview', () => {
|
||
|
test( 'should render a single product preview with an image', () => {
|
||
|
const product = {
|
||
|
id: 1,
|
||
|
name: 'Winter Jacket',
|
||
|
price_html:
|
||
|
'<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>65.00</span>',
|
||
|
images: [
|
||
|
{
|
||
|
src: 'https://example.local/product.jpg',
|
||
|
},
|
||
|
],
|
||
|
};
|
||
|
const component = renderer.create( <ProductPreview product={ product } /> );
|
||
|
expect( component.toJSON() ).toMatchSnapshot();
|
||
|
} );
|
||
|
|
||
|
test( 'should render a single product preview without an image', () => {
|
||
|
const product = {
|
||
|
id: 1,
|
||
|
name: 'Winter Jacket',
|
||
|
price_html:
|
||
|
'<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>65.00</span>',
|
||
|
images: [],
|
||
|
};
|
||
|
const component = renderer.create( <ProductPreview product={ product } /> );
|
||
|
expect( component.toJSON() ).toMatchSnapshot();
|
||
|
} );
|
||
|
} );
|