UNPKG

yoda-common-boilerplate

Version:

Repository of all JCP reusable atoms, molecules and organisms

33 lines (26 loc) 1.07 kB
import React from 'react'; import sinon from 'sinon'; import {mount,shallow} from 'enzyme'; import { expect } from 'chai'; import 'ignore-styles'; import Image from '../Image'; describe('<Image />', () => { it('should have a div ', () => { const wrapper = shallow(<Image />); expect(wrapper.find('div')).to.have.length(1); expect(wrapper.find('img')).to.have.length(1); }); it('should have deafult props passed', () => { const wrapper = mount(<Image /> ); expect(wrapper.find('img').props().alt).to.equal(''); expect(wrapper.find('img').props().src).to.equal('../images/placeholder.png'); expect(wrapper.props().imageRatio).to.equal(100); }); it('should have able to pass props', () => { const wrapper = mount(<Image /> ); wrapper.setProps({ src: '../images/placeholder2.png', alt: 'Hello', imageRatio: 0 }); expect(wrapper.find('img').props().alt).to.equal('Hello'); expect(wrapper.find('img').props().src).to.equal('../images/placeholder2.png'); expect(wrapper.props().imageRatio).to.equal(0); }); });