yoda-common-boilerplate
Version:
Repository of all JCP reusable atoms, molecules and organisms
54 lines (43 loc) • 1.26 kB
JavaScript
import React from 'react';
import { shallow } from 'enzyme';
import { expect } from 'chai';
import 'ignore-styles';
import ProductList from '../ProductList.jsx';
const listArr = [
{
text: 'Item 1',
id: 1
},
{
text: 'Item 2',
originalPrice: '44',
id: 2
},
{
text: 'Item 3',
originalPrice: '44',
id: 3
}
];
const productCardRenderer = dataItem => (
<ProductCard image={dataItem.image} price={dataItem.price} originalPrice={dataItem.originalPrice} key={dataItem.id} />
);
describe('<ProductList />', () => {
let wrapper;
beforeEach(() => {
//Shallow Rendering component in before each to eliminate duplication
wrapper = shallow(<ProductList datasource={listArr} childRenderer={productCardRenderer} > </ProductList>);
});
it('ProductList component should exist ', () => {
expect(wrapper).to.exist;
});
it('ProductList component should exist ', () => {
expect(wrapper.type()).to.equal('section');
});
it('ProductList component should contain an List component', () => {
expect(wrapper.find('List')).to.exist;
});
it('List component should contain an ProductCard component', () => {
expect(wrapper.children('List').find('ProductCard')).to.exist;
});
});