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
Reorganize and improve render unit tests #1199
Conversation
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 found this PR to be slightly easier to review with the "No Whitespace" option turned on since some of these changes are just indentation changes.
@@ -151,12 +151,6 @@ describe('Components', () => { | |||
expect(scratch.innerHTML).to.equal(''); | |||
}); | |||
|
|||
// Test for #651 | |||
it('should set enumerable boolean attribute', () => { |
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 just moved this into the render.js UT file since this test doesn't actually use an components
}); | ||
}); | ||
|
||
describe('event handling', () => { |
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 grouped all event handling under a common describe
block
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 also broke up the event handling tests to better specify the various concerns they were testing
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.
Yay, meaningful failure messages!
.that.matches(/top\s*:\s*5px\s*/) | ||
.and.matches(/position\s*:\s*relative\s*/); | ||
}); | ||
describe('style attribute', () => { |
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.
Moved all style tests under a common describe
block
} | ||
render(props, { html }) { | ||
return html ? <div dangerouslySetInnerHTML={{ __html: html }} /> : <div />; | ||
describe('dangerouslySetInnerHTML', () => { |
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.
Group all dangerouslySetInnerHTML
tests under a common describe
block
{ todos.map( todo => (<div>{todo.text}</div> )) } | ||
<div onKeyDown={this.addTodo}> | ||
{ todos.map( todo => ([ | ||
<span>{todo.text}</span>, |
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.
The original issue called out this example as a better test for this test case so I updated the test to cover this.
it('should only register on* functions as handlers', () => { | ||
let click = () => {}, | ||
onclick = () => {}; | ||
it('should properly switch from string styles to object styles and back', () => { |
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.
we'll want to revisit this if we decide to remove string style support (it's a preact-only feature)
}); | ||
}); | ||
|
||
describe('event handling', () => { |
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.
Yay, meaningful failure messages!
@@ -588,44 +699,69 @@ describe('render()', () => { | |||
expect(sortAttributes(html)).to.equal(sortAttributes('<input type="range" min="0" max="100" list="steplist">')); | |||
}); | |||
|
|||
it('should not execute append operation when child is at last', (done) => { | |||
it('should not execute append operation when child is at last', () => { | |||
// See developit/preact#717 for discussion about the issue this addresses |
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 wish I'd left more of these issue references around.
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.
side note: we should totally look into reusing this component + plumbing for a bunch of different tests.
Approved x1000 |
Reorganize render unit tests to better represent the expectations that the test are validating. Also, improved a couple tests to better cover their scenario.