Skip to content
This repository has been archived by the owner on Oct 20, 2022. It is now read-only.

Commit

Permalink
test(SegmentedControl): Added test (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
Myoxocephalus authored and JacobBlomgren committed Dec 21, 2018
1 parent a091572 commit 0b98933
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/components/segmented-control/segmented-control.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('<SegmentedControl />', () => {
expect(actual).to.have.length(expected);
});

it('should call user supplied onChange when an input is changed to checked', () => {
it('should call user supplied onChange when an input with type radio is changed to checked', () => {
const spy = sinon.spy();
const wrapper = renderComponent({ onChange: spy, children: [<span value={1}>1</span>, <span value={2}>2</span>] });
const actual = wrapper.find('input[type="radio"][value=2]');
Expand All @@ -42,6 +42,21 @@ describe('<SegmentedControl />', () => {
expect(spy.calledOnce).to.equal(expected);
});

it('should call user supplied onChange when an input with type checkbox is changed to checked', () => {
const spy = sinon.spy();
const wrapper = renderComponent({ onChange: spy, type: 'checkbox', children: [<span value={1}>1</span>, <span value={2}>2</span>] });
const actual = wrapper.find('input[type="checkbox"][value=2]');
actual.simulate('change', { target: { checked: true }, currentTarget: { checked: true } });
expect(spy.calledOnce).to.equal(true);
});

it('should set state to true when an input with type checkbox is changed to checked', () => {
const wrapper = renderComponent({ type: 'checkbox', children: [<span value={1}>1</span>, <span value={2}>2</span>] });
const actual = wrapper.find('input[type="checkbox"][value=2]');
actual.simulate('change', { target: { checked: true }, currentTarget: { value: 2 } });
expect(wrapper.state()[2]).to.equal(true);
});

it('should set focus to child index when element get focus', () => {
const wrapper = renderComponent({ children: [<span value={1}>1</span>, <span value={2}>2</span>] });
const actual = wrapper.find('input[type="radio"][value=1]');
Expand Down

0 comments on commit 0b98933

Please sign in to comment.