-
-
Notifications
You must be signed in to change notification settings - Fork 447
Allow other components inside TabList #123
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
Merged
danez
merged 7 commits into
reactjs:master
from
patrick91:feature/allow-other-components
Sep 14, 2016
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
800e3a9
Allow other child types inside TabList
patrick91 af03fd9
Updated tests
patrick91 70c5b35
Fix lint issue
patrick91 d76292a
Don't clone non Tabs elements
patrick91 f559020
Test that non tab elements are not cloned
patrick91 4c6dbd6
Don't compare element type by display name
patrick91 b1e4545
Disable multiple components lint inside Tabs tests
patrick91 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
/* eslint-disable react/no-multi-comp */ | ||
/* global jest, describe, it, expect */ | ||
import React from 'react'; | ||
import { shallow, mount } from 'enzyme'; | ||
|
@@ -185,6 +186,27 @@ describe('react-tabs', () => { | |
expect(wrapper.childAt(2).text()).toBe('Hello Bar'); | ||
expect(wrapper.childAt(3).text()).toBe('Hello Baz'); | ||
}); | ||
|
||
it('should not clone non tabs element', () => { | ||
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. Nice to figure out how to test this 👍 |
||
class Demo extends React.Component { | ||
render() { | ||
const plus = <div ref="yolo">+</div>; | ||
|
||
return (<Tabs> | ||
<TabList> | ||
<Tab>Foo</Tab> | ||
{plus} | ||
</TabList> | ||
|
||
<TabPanel>Hello Baz</TabPanel> | ||
</Tabs>); | ||
} | ||
} | ||
|
||
const wrapper = mount(<Demo />); | ||
|
||
expect(wrapper.ref('yolo').text()).toBe('+'); | ||
}); | ||
}); | ||
|
||
describe('validation', () => { | ||
|
@@ -201,7 +223,25 @@ describe('react-tabs', () => { | |
expect(result instanceof Error).toBe(true); | ||
}); | ||
|
||
it('should result with a warning when wrong element is found', () => { | ||
it(`should result with warning when tabs/panels are imbalanced and | ||
it should ignore non tab children`, () => { | ||
const wrapper = shallow( | ||
<Tabs> | ||
<TabList> | ||
<Tab>Foo</Tab> | ||
<div>+</div> | ||
</TabList> | ||
|
||
<TabPanel>Hello Foo</TabPanel> | ||
<TabPanel>Hello Bar</TabPanel> | ||
</Tabs> | ||
); | ||
|
||
const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs'); | ||
expect(result instanceof Error).toBe(true); | ||
}); | ||
|
||
it('should not throw a warning when wrong element is found', () => { | ||
const wrapper = shallow( | ||
<Tabs> | ||
<TabList> | ||
|
@@ -213,7 +253,7 @@ describe('react-tabs', () => { | |
); | ||
|
||
const result = Tabs.propTypes.children(wrapper.props(), 'children', 'Tabs'); | ||
expect(result instanceof Error).toBe(true); | ||
expect(result instanceof Error).toBe(false); | ||
}); | ||
|
||
it('should be okay with rendering without any children', () => { | ||
|
This file contains hidden or 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.
Uh oh!
There was an error while loading. Please reload this page.
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.
This would still clone everytime.