Skip to content

Commit 6e1f678

Browse files
author
Cmdv
committed
Testing home component
1 parent f84e155 commit 6e1f678

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
node_modules
22
build
33
.idea
4-
.DS_Store
4+
.DS_Store
5+
jsconfig.json

src/__test__/index.spec.js

+28-7
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,31 @@
1-
var test = require('tape');
1+
import test from 'tape';
2+
import React from 'react/addons';
3+
import Home from '../routes/Home.js';
24

3-
test('basic arithmetic', function(t) {
4-
t.plan(4);
5+
const TestUtils = React.addons.TestUtils;
56

6-
t.equal(2 + 3, 5);
7-
t.equal(7 * 8 + 9, 65);
8-
t.equal(1 + 2 , 3);
9-
t.equal(3 + 4 , 7);
7+
const createComponent = (component, props, ...children) => {
8+
const shallowRenderer = TestUtils.createRenderer();
9+
const reactElement = React.createElement(
10+
component,
11+
props,
12+
children.length > 1 ? children : children[0]
13+
);
14+
15+
shallowRenderer.render(reactElement);
16+
return shallowRenderer.getRenderOutput();
17+
};
18+
19+
test('Home component type', t => {
20+
21+
t.equal(createComponent(Home).type, 'div');
22+
t.end();
23+
});
24+
25+
test('Home title text', t => {
26+
27+
const postTitle = createComponent(Home).props.children[0];
28+
29+
t.equal(postTitle.props.children, 'Welcome to React + RxJS');
30+
t.end();
1031
});

0 commit comments

Comments
 (0)