Skip to content

Commit

Permalink
Added tests for ElementsRenderer.js
Browse files Browse the repository at this point in the history
  • Loading branch information
chentsulin committed Dec 4, 2016
1 parent cbbebee commit 608da11
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/ElementsRenderer.test.js
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);
});
});

0 comments on commit 608da11

Please sign in to comment.