UNPKG

react-cms

Version:

For personal use. Not production.

63 lines (57 loc) 1.46 kB
/* @flow */ import React from 'react'; import { expect } from 'chai'; import { spy } from 'sinon'; import { shallow, mount } from 'enzyme'; import Option from '..'; describe('Option test suite', () => { it('should have a div when rendered', () => { expect(shallow( <Option value="b" onClick={() => {}} > <span>testing</span> </Option> ).node.type).to.equal('div'); }); it('should have child element passed after mount', () => { const option = mount( <Option value="b" onClick={() => {}} > <span>testing</span> </Option> ); expect(option.children().length).to.equal(1); expect(option.children().type()).to.equal('span'); }); it('should execute funcion passed in onClick props when clicked', () => { const onClick = spy(); const option = mount( <Option value="b" onClick={onClick} > <span>testing</span> </Option> ); option.children().simulate('click'); expect(onClick.calledOnce).to.equal(true); }); it('should not execute funcion passed in onClick props when clicked if disabled', () => { const onClick = spy(); const option = mount( <Option value="b" onClick={onClick} disabled > <span>testing</span> </Option> ); option.children().simulate('click'); expect(onClick.called).to.equal(false); }); });