Skip to content

Commit bf89823

Browse files
committed
Merge pull request ericelliott#174 from andresgallego/master
Replace all references to enzyme with Cheerio
2 parents 1144ed9 + 2fc17e1 commit bf89823

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

source/test/components/hello/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,27 @@
11
import React from 'react';
2+
import reactDom from 'react-dom/server';
23
import test from 'tape';
3-
import { shallow } from 'enzyme';
4+
import dom from 'cheerio';
45

56
import hello from 'components/hello';
67
import createActions from 'test-fixtures/components/hello/create-actions';
78

89
const Hello = hello(React);
10+
const render = reactDom.renderToStaticMarkup;
911

1012
test('Hello', nest => {
1113
nest.test('...with no parameters', assert => {
1214
const msg = 'should render our hello greeting!';
1315

1416
const text = '<p>Hello, World!</p>';
1517
const re = new RegExp(text, 'g');
18+
1619
const props = {
1720
actions: createActions()
1821
};
1922

20-
const $ = shallow(<Hello { ... props } />);
23+
const el = <Hello { ...props } />;
24+
const $ = dom.load(render(el));
2125
const output = $.html();
2226

2327
const actual = re.test(output);
@@ -38,7 +42,9 @@ test('Hello', nest => {
3842
subject: 'React',
3943
actions: createActions()
4044
};
41-
const $ = shallow(<Hello { ...props }/>);
45+
46+
const el = <Hello { ...props } />;
47+
const $ = dom.load(render(el));
4248
const output = $.html();
4349

4450
const actual = re.test(output);

source/test/components/title/index.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import React from 'react';
2+
import reactDom from 'react-dom/server';
23
import test from 'tape';
3-
import { shallow } from 'enzyme';
4+
import dom from 'cheerio';
45

56
import createTitle from 'components/title';
67

78
const Title = createTitle(React);
9+
const render = reactDom.renderToStaticMarkup;
810

911
test('Title', assert => {
1012
const titleText = 'Hello!';
@@ -13,9 +15,10 @@ test('Title', assert => {
1315
titleClass: 'title'
1416
};
1517
const re = new RegExp(titleText, 'g');
16-
const $ = shallow(<Title { ...props } />);
17-
const output = $.find('.title').html();
1818

19+
const el = <Title { ...props } />;
20+
const $ = dom.load(render(el));
21+
const output = $('.title').html();
1922
const actual = re.test(output);
2023
const expected = true;
2124

0 commit comments

Comments
 (0)