File tree 2 files changed +30
-8
lines changed
2 files changed +30
-8
lines changed Original file line number Diff line number Diff line change 1
1
node_modules
2
2
build
3
3
.idea
4
- .DS_Store
4
+ .DS_Store
5
+ jsconfig.json
Original file line number Diff line number Diff line change 1
- var test = require ( 'tape' ) ;
1
+ import test from 'tape' ;
2
+ import React from 'react/addons' ;
3
+ import Home from '../routes/Home.js' ;
2
4
3
- test ( 'basic arithmetic' , function ( t ) {
4
- t . plan ( 4 ) ;
5
+ const TestUtils = React . addons . TestUtils ;
5
6
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 ( ) ;
10
31
} ) ;
You can’t perform that action at this time.
0 commit comments