File tree Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Expand file tree Collapse file tree 3 files changed +51
-1
lines changed Original file line number Diff line number Diff line change 57
57
"classnames" : " ~2.2.5" ,
58
58
"coveralls" : " ~3.0.0" ,
59
59
"css-loader" : " ~0.28.7" ,
60
+ "enzyme" : " ~3.2.0" ,
61
+ "enzyme-adapter-react-16" : " ~1.1.1" ,
60
62
"eslint" : " ~4.13.1" ,
61
63
"eslint-config-trendmicro" : " ~1.1.0" ,
62
64
"eslint-loader" : " ~1.9.0" ,
63
65
"eslint-plugin-import" : " ~2.8.0" ,
64
66
"eslint-plugin-jsx-a11y" : " ~6.0.2" ,
65
67
"eslint-plugin-react" : " ~7.5.1" ,
68
+ "jsdom" : " ~11.5.1" ,
66
69
"lodash.debounce" : " ~4.0.8" ,
67
70
"nib" : " ~1.1.2" ,
68
71
"react" : " ^0.14.0 || >=15.0.0" ,
Original file line number Diff line number Diff line change
1
+ import Enzyme from 'enzyme' ;
2
+ import Adapter from 'enzyme-adapter-react-16' ;
3
+ import { JSDOM } from 'jsdom' ;
4
+
5
+ // React 16 Enzyme adapter
6
+ Enzyme . configure ( { adapter : new Adapter ( ) } ) ;
7
+
8
+ // Ignore `.styl` files
9
+ require . extensions [ '.styl' ] = ( ) => {
10
+ return ;
11
+ } ;
12
+
13
+ // JSDOM
14
+ const jsdom = new JSDOM ( '<!doctype html><html><body></body></html>' ) ;
15
+ const { window } = jsdom ;
16
+
17
+ const copyProps = ( src , target ) => {
18
+ const props = Object . getOwnPropertyNames ( src )
19
+ . filter ( prop => typeof target [ prop ] === 'undefined' )
20
+ . reduce ( ( result , prop ) => ( {
21
+ ...result ,
22
+ [ prop ] : Object . getOwnPropertyDescriptor ( src , prop ) ,
23
+ } ) , { } ) ;
24
+ Object . defineProperties ( target , props ) ;
25
+ } ;
26
+
27
+ global . window = window ;
28
+ global . document = window . document ;
29
+ global . navigator = {
30
+ userAgent : 'node.js' ,
31
+ } ;
32
+
33
+ copyProps ( window , global ) ;
Original file line number Diff line number Diff line change
1
+ import React from 'react' ;
2
+ import { mount } from 'enzyme' ;
1
3
import { test } from 'tap' ;
4
+ import '../setupTests' ;
5
+ import InfiniteTree from '../src' ;
6
+ import Tree from '../examples/Tree' ;
2
7
3
- test ( 'noop' , ( t ) => {
8
+ test ( '<InfiniteTree />' , ( t ) => {
9
+ const onUpdate = ( node ) => {
10
+ t . equal ( node . id , '<root>.0' ) ;
11
+ } ;
12
+
13
+ const wrapper = mount ( (
14
+ < Tree onUpdate = { onUpdate } />
15
+ ) ) ;
16
+
17
+ t . equal ( wrapper . find ( InfiniteTree ) . length , 1 , 'should render <InfiniteTree /> component' ) ;
4
18
t . end ( ) ;
5
19
} ) ;
You can’t perform that action at this time.
0 commit comments