-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Updates tests. #946
Updates tests. #946
Conversation
components/form-toggle/test/index.js
Outdated
const formToggle = shallow( <FormToggle checked /> ); | ||
expect( formToggle.hasClass( 'is-checked' ) ).to.be.true(); | ||
expect( formToggle.find( '.components-form-toggle__input' ).prop( 'value' ) ).to.be.true(); | ||
expect( formToggle.find( '.components-form-toggle__hint' ).text() ).to.equal( 'On' ); | ||
} ); | ||
|
||
it( 'with additonal className', () => { | ||
it( 'shouuld render with an additional className', () => { |
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.
Typo: shouuld
&rarr: should
components/button/test/index.js
Outdated
it( 'should render and additional WordPress prop of value awesome', () => { | ||
const button = <Button WordPress="awesome" />; | ||
|
||
expect( button.props.WordPress ).to.equal( 'awesome' ); |
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.
Should this be button.prop( 'WordPress' )
?
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.
I don't think so. I admit it is probably confusing. This is just pure React, I don't believe Enzyme is touching this in anyway. I believe it would need to be wrapped in shallow
for the API to be available. I should probably just wrap it in shallow and do what you said.
components/form-toggle/test/index.js
Outdated
const formToggle = shallow( <FormToggle id="test" /> ); | ||
expect( formToggle.find( '.components-form-toggle__input' ).prop( 'id' ) ).to.equal( 'test' ); | ||
} ); | ||
|
||
it( 'with onChange handler', () => { | ||
it( 'should render a checkbox with a noop on change and if an onChange function is provided override the noop', () => { |
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.
I think this should be two separate tests:
should render a checkbox with a noop onChange
should render a checkbox with a user-provided onChange
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.
Sounds good.
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.
Feel free to merge after addressing inline notes. 👍
I can probably be partly to blame for perpetuating the "should" convention for starting test case descriptions. I don't feel so strongly about it these days. I think a more reasonable convention, especially with the method name, is to simply form it as a complete sentence, which could be Two cents. Dunno how others feel. |
My preference is simply that the test names form a complete and readable sentence as well. I usually write |
Closes #938. The other PRs have been updated for better conventions. Here is an update to the tests already existing in the repo. Updates FormToggle, Dashicon, and Button. **Testing Instructions** Verify tests still pass.
Adding revisions to the tests. Cleaning up Enzyme API usage, and breaking larger tests into more test cases. Spelling corrections added.
0075194
to
c56aa87
Compare
I blame Mocha's docs 😛 https://mochajs.org/#getting-started |
Closes #938. The other PRs have been updated for better conventions.
Here is an update to the tests already existing in the repo. Updates
FormToggle, Dashicon, and Button.
Testing Instructions
Verify tests still pass.