Skip to content

Commit 156f92d

Browse files
authored
Fix codecov (#178)
* fix ci * fix ci * fix codecov * test cov to 100% * fit => it * fix lint
1 parent b44752d commit 156f92d

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

.travis.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,7 @@ env:
1212
matrix:
1313
- TEST_TYPE=lint
1414
- TEST_TYPE=test
15-
- TEST_TYPE=coverage
15+
- TEST_TYPE=coverage
16+
17+
after_success:
18+
- bash <(curl -s https://codecov.io/bash) -e TRAVIS_NODE_VERSION

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"pub": "rc-tools run pub --babel-runtime",
3838
"lint": "rc-tools run lint",
3939
"test": "jest",
40-
"coverage": "jest --coverage && curl -s https://codecov.io/bash",
40+
"coverage": "jest --coverage",
4141
"prepublish": "rc-tools run guard"
4242
},
4343
"jest": {

tests/index.spec.jsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ describe('rc-checkbox', () => {
2121
expect(wrapper.state('checked')).toBe(true);
2222
});
2323

24+
it('control mode', () => {
25+
const wrapper = mount(<Checkbox checked />);
26+
expect(wrapper.state('checked')).toBe(true);
27+
wrapper.find('input').simulate('change', { target: { checked: true } });
28+
expect(wrapper.state('checked')).toBe(true);
29+
wrapper.find('input').simulate('change', { target: { checked: false } });
30+
expect(wrapper.state('checked')).toBe(true);
31+
});
32+
33+
it('stopPropagation and preventDefault', () => {
34+
const onChange = jest.fn();
35+
const wrapper = mount(
36+
<div onChange={onChange}>
37+
<Checkbox onChange={e => { e.stopPropagation(); e.preventDefault(); }} />
38+
</div>
39+
);
40+
wrapper.find('input').simulate('change', { target: { checked: true } });
41+
expect(onChange).not.toHaveBeenCalled();
42+
});
43+
2444
it('passes data-* props to input', () => {
2545
const wrapper = mount(<Checkbox data-type="my-data-type" />);
2646
const renderedInput = wrapper.find('input').instance();

0 commit comments

Comments
 (0)