-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cbbebee
commit 608da11
Showing
1 changed file
with
40 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { mount } from 'enzyme'; | ||
import React from 'react'; | ||
|
||
import ElementsRenderer from '../src/ElementsRenderer'; | ||
|
||
describe('<ElementsRenderer>', () => { | ||
it('should render null when no item in elements', () => { | ||
const elements = []; | ||
const wrapper = mount( | ||
<ElementsRenderer elements={elements} /> | ||
); | ||
expect(wrapper.html()).toBe(null); | ||
}); | ||
|
||
it('should render element', () => { | ||
const elements = [<div />]; | ||
const wrapper = mount( | ||
<ElementsRenderer elements={elements} /> | ||
); | ||
expect(wrapper.find('div')).toHaveLength(1); | ||
}); | ||
|
||
it('should render elements with nested structure', () => { | ||
const Parent = ({ children }) => <div className="parent">{children}</div>; | ||
Parent.propTypes = { children: React.PropTypes.element }; | ||
const Child = () => <div className="child" />; | ||
|
||
const elements = [<Parent />, <Child />]; | ||
|
||
const wrapper = mount( | ||
<ElementsRenderer elements={elements} /> | ||
); | ||
|
||
const parent = wrapper.find(Parent); | ||
expect(parent).toHaveLength(1); | ||
|
||
const child = parent.find(Child); | ||
expect(child).toHaveLength(1); | ||
}); | ||
}); |