Skip to content

Commit

Permalink
chore: Add tests to Checkbox for indeterminate and defaultChecked (#851)
Browse files Browse the repository at this point in the history
* test(checkbox): Add tests for indeterminate and defaultChecked

* Update .eslintignore

remove duplicated lib
  • Loading branch information
sam-kvale-sap authored Jan 17, 2020
1 parent b47360f commit b0c48b0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
!/.storybook
build
lib
!/.storybook
28 changes: 26 additions & 2 deletions src/Forms/Checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,39 @@ describe('<Checkbox />', () => {
onChange: () => {}
});

expect(element.props().checked).toBe(true);
expect(element.find('input').props().checked).toBe(true);
expect(element.find('input').props()['aria-checked']).toBe('true');
});

test('should add checked attribute if defaultChecked is true', () => {
let element = setup({
defaultChecked: true,
onChange: () => {}
});

expect(element.find('input').props().checked).toBe(true);

// TODO: The aria-checked does not reflect the current state of the checkbox if it is uncontrolled
// expect(element.find('input').props()['aria-checked']).toBe('true');
});

test('should add aria-checked attribute of "mixed" if indeterminate is true', () => {
let element = setup({
indeterminate: true,
defaultChecked: true,
onChange: () => {}
});

expect(element.find('input').props().checked).toBe(true);
expect(element.find('input').props()['aria-checked']).toBe('mixed');
});

test('should set disabled to true when passed', () => {
let element = setup({
disabled: true
});

expect(element.props().disabled).toBe(true);
expect(element.find('input').props().disabled).toBe(true);
});

test('should add inline class when inline is passed', () => {
Expand Down

0 comments on commit b0c48b0

Please sign in to comment.