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