-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
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
[Hidden] Change children type to allow many and add children tests #8082
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
367a0f3
[Hidden] change children type and add children tests
rosskevin a4b71d7
Fixes #8072
rosskevin 3ef97fc
use untilSelector for browser tests
rosskevin a7af0b5
Use strictEqual and ensure no additional unsupported props are passed
rosskevin 0fe1fbd
Add back ref check and switch message to keys only to avoid mismatch …
rosskevin 581c58e
remove ref, we don’t apply it.
rosskevin a9f4c32
ok, add back ref?
rosskevin cd7c014
codecov hanging, trigger another build
rosskevin 3d6017e
lint
rosskevin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,12 +5,14 @@ import { assert } from 'chai'; | |
import { createShallow, getClasses } from '../test-utils'; | ||
import HiddenCss from './HiddenCss'; | ||
|
||
const Foo = () => <div>bar</div>; | ||
|
||
describe('<HiddenCss />', () => { | ||
let shallow; | ||
let classes; | ||
|
||
before(() => { | ||
shallow = createShallow(); | ||
shallow = createShallow({ untilSelector: 'span' }); | ||
classes = getClasses( | ||
<HiddenCss> | ||
<div /> | ||
|
@@ -25,7 +27,11 @@ describe('<HiddenCss />', () => { | |
<div className="foo" /> | ||
</HiddenCss>, | ||
); | ||
assert.strictEqual(wrapper.props().className, `foo ${classes.onlySm}`); | ||
assert.strictEqual(wrapper.type(), 'span'); | ||
assert.isTrue(wrapper.hasClass(classes.onlySm)); | ||
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. What do you think of sticking to |
||
const div = wrapper.childAt(0); | ||
assert.strictEqual(div.type(), 'div'); | ||
assert.strictEqual(div.props().className, 'foo'); | ||
}); | ||
|
||
it('should be ok with mdDown', () => { | ||
|
@@ -34,7 +40,7 @@ describe('<HiddenCss />', () => { | |
<div className="foo" /> | ||
</HiddenCss>, | ||
); | ||
assert.strictEqual(wrapper.props().className, `foo ${classes.mdDown}`); | ||
assert.isTrue(wrapper.hasClass(classes.mdDown)); | ||
}); | ||
|
||
it('should be ok with mdUp', () => { | ||
|
@@ -43,13 +49,49 @@ describe('<HiddenCss />', () => { | |
<div className="foo" /> | ||
</HiddenCss>, | ||
); | ||
assert.strictEqual(wrapper.props().className, `foo ${classes.mdUp}`); | ||
assert.isTrue(wrapper.hasClass(classes.mdUp)); | ||
}); | ||
}); | ||
|
||
describe('prop: children', () => { | ||
it('should work when empty', () => { | ||
shallow(<HiddenCss mdUp />); | ||
const wrapper = shallow(<HiddenCss mdUp />); | ||
assert.strictEqual(wrapper.type(), 'span'); | ||
assert.isTrue(wrapper.hasClass(classes.mdUp)); | ||
assert.isNull(wrapper.childAt(0).type()); | ||
}); | ||
|
||
it('should work when text Node', () => { | ||
const wrapper = shallow(<HiddenCss mdUp>foo</HiddenCss>); | ||
assert.strictEqual(wrapper.type(), 'span'); | ||
assert.isTrue(wrapper.hasClass(classes.mdUp)); | ||
assert.strictEqual(wrapper.childAt(0).text(), 'foo'); | ||
}); | ||
|
||
it('should work when Element', () => { | ||
const wrapper = shallow( | ||
<HiddenCss mdUp> | ||
<Foo /> | ||
</HiddenCss>, | ||
); | ||
assert.strictEqual(wrapper.type(), 'span'); | ||
assert.isTrue(wrapper.hasClass(classes.mdUp)); | ||
assert.isTrue(wrapper.childAt(0).is(Foo)); | ||
}); | ||
|
||
it('should work when mixed ChildrenArray', () => { | ||
const wrapper = shallow( | ||
<HiddenCss mdUp> | ||
<Foo /> | ||
<Foo /> | ||
foo | ||
</HiddenCss>, | ||
); | ||
assert.strictEqual(wrapper.type(), 'span'); | ||
assert.isTrue(wrapper.hasClass(classes.mdUp)); | ||
assert.isTrue(wrapper.childAt(0).is(Foo)); | ||
assert.isTrue(wrapper.childAt(1).is(Foo)); | ||
assert.strictEqual(wrapper.childAt(2).text(), 'foo'); | ||
}); | ||
}); | ||
}); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What do you think of adding a warning if
...other
is non empty?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'll alter the current warning, since a ref is no longer valid there.