-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add test for switch, ref #1274 * add issue url * fix: test
- Loading branch information
1 parent
e54cdc1
commit 3f2fab7
Showing
7 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
components/switch/__tests__/__snapshots__/index.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Switch renders correctly 1`] = ` | ||
<RCTSwitch | ||
disabled={false} | ||
onChange={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
onValueChange={[Function]} | ||
style={ | ||
Array [ | ||
Object { | ||
"height": 31, | ||
"width": 51, | ||
}, | ||
undefined, | ||
] | ||
} | ||
value={true} | ||
/> | ||
`; |
18 changes: 18 additions & 0 deletions
18
components/switch/__tests__/__snapshots__/index.test.web.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`SegmentedControl renders correctly 1`] = ` | ||
<label | ||
class="am-switch" | ||
> | ||
<input | ||
checked="" | ||
class="am-switch-checkbox" | ||
name="" | ||
type="checkbox" | ||
value="on" | ||
/> | ||
<div | ||
class="checkbox" | ||
/> | ||
</label> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import Switch from '../index'; | ||
|
||
describe('Switch', () => { | ||
it('renders correctly', () => { | ||
const tree = renderer.create(<Switch checked />).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { render, shallow } from 'enzyme'; | ||
import { renderToJson } from 'enzyme-to-json'; | ||
import Switch from '../index.web'; | ||
|
||
describe('SegmentedControl', () => { | ||
it('renders correctly', () => { | ||
const wrapper = render(<Switch checked />); | ||
expect(renderToJson(wrapper)).toMatchSnapshot(); | ||
}); | ||
|
||
it('check api', () => { | ||
const onChange = jest.fn(); | ||
const wrapper = shallow(<Switch checked onChange={onChange} />); | ||
wrapper.find('input').simulate('change', { target: { checked: false } }); | ||
expect(onChange).toHaveBeenCalledWith(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters