-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add test #1
Add test #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
justify-content: space-between; | ||
align-items: center; | ||
|
||
width: 300px; | ||
/*width: 300px;*/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same. You can remove it given that the with in defaulProps are still there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same. You can remove it given that the width in defaulProps are still there |
||
border: 1px solid #ccc; | ||
background-color: white; | ||
box-sizing: border-box; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,74 @@ import MDSearchBox from 'src/MDSearchBox'; | |
expect.extend(expectJSX); | ||
|
||
describe('MDSearchBox', () => { | ||
it('should work', () => { | ||
describe('default case', () => { | ||
let wrapper; | ||
|
||
before(() => { | ||
wrapper = shallow(<MDSearchBox />); | ||
}); | ||
|
||
it('should have no input value', () => { | ||
const input = wrapper.find('input'); | ||
expect(input.props().value).toBe(undefined); | ||
}); | ||
|
||
}); | ||
|
||
describe('with text', () => { | ||
let wrapper; | ||
|
||
before(() => { | ||
wrapper = shallow( | ||
<MDSearchBox | ||
text="haha" | ||
/> | ||
); | ||
}); | ||
|
||
it('should have corresponding text', () => { | ||
const input = wrapper.find('input'); | ||
expect(input.props().value).toBe('haha'); | ||
|
||
}); | ||
}) | ||
|
||
// describe('with onChange method', () => { | ||
// let wrapper; | ||
// | ||
// before(() => { | ||
// wrapper = shallow( | ||
// <MDSearchBox | ||
// onChange={() => { | ||
// return 'xixi'; | ||
// }} | ||
// /> | ||
// ); | ||
// }); | ||
// | ||
// it('should trigger the onChange', () => { | ||
// const input = wrapper.find('input'); | ||
// // const event = { preventDefault: () => 'a' } | ||
// input.simulate('change'); | ||
// expect(input.props().onChange()).toBe('xixi'); | ||
// }) | ||
// }) | ||
|
||
describe('with size changed', () => { | ||
let wrapper; | ||
|
||
before(() => { | ||
wrapper = shallow( | ||
<MDSearchBox | ||
width={500} | ||
height={300} | ||
/> ); | ||
}); | ||
|
||
it('size should change', () => { | ||
expect(wrapper.props().style).toEqual({width:500, height:300}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. better split that assertion into two assertions. or you can use |
||
|
||
}); | ||
}) | ||
|
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
如果default props里面有width,那么这里是可以把width删除的。如果你把default props里面的width删了,那么这里就不能删。我觉得前者比较合理和直观