Skip to content

Commit

Permalink
fix: pass checked prop to Input
Browse files Browse the repository at this point in the history
  • Loading branch information
P0lip committed Jan 6, 2019
1 parent 9164cb7 commit 22522fc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const Checkbox: FunctionComponent<ICheckbox> = props => {
as="input"
type="checkbox"
id={id}
checked={checked}
onChange={handleChange}
position="absolute"
css={{ clip: 'rect(1px, 1px, 1px, 1px)' }}
Expand Down
1 change: 1 addition & 0 deletions src/Toggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export const Toggle: FunctionComponent<IToggle> = props => {
as="input"
type="checkbox"
id={id}
checked={checked}
onChange={handleChange}
position="absolute"
css={{ clip: 'rect(1px, 1px, 1px, 1px)' }}
Expand Down
10 changes: 10 additions & 0 deletions src/__tests__/Checkbox.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,14 @@ describe('Checkbox component', () => {
expect(onChange).toHaveBeenLastCalledWith(false);
wrapper.unmount();
});

it('passes checked prop to inner Input', () => {
let wrapper = mount(<Checkbox id="4" checked={true} />);
expect(wrapper.find('input')).toHaveProp('checked', true);
wrapper.unmount();

wrapper = mount(<Checkbox id="4" checked={false} />);
expect(wrapper.find('input')).toHaveProp('checked', false);
wrapper.unmount();
});
});
10 changes: 10 additions & 0 deletions src/__tests__/Toggle.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,14 @@ describe('Toggle component', () => {
expect(onChange).toHaveBeenLastCalledWith(false);
wrapper.unmount();
});

it('passes checked prop to inner Input', () => {
let wrapper = mount(<Toggle id="4" checked={true} />);
expect(wrapper.find('input')).toHaveProp('checked', true);
wrapper.unmount();

wrapper = mount(<Toggle id="4" checked={false} />);
expect(wrapper.find('input')).toHaveProp('checked', false);
wrapper.unmount();
});
});

0 comments on commit 22522fc

Please sign in to comment.