This repository was archived by the owner on Oct 18, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 12 files changed +230
-23
lines changed
Expand file tree Collapse file tree 12 files changed +230
-23
lines changed Original file line number Diff line number Diff line change @@ -6,4 +6,7 @@ node_modules
66npm-debug.log *
77
88# compiled files
9- dist
9+ lib
10+
11+ # coverage directory used by tools like istanbul
12+ coverage
Original file line number Diff line number Diff line change 1+ # dependencies
2+ node_modules
3+
4+ # logs
5+ * .log
6+ npm-debug.log *
7+
8+ # coverage directory used by tools like istanbul
9+ coverage
10+
11+ # tests
12+ __tests__
13+
14+ # settings
15+ .vscode
16+ .babelrc
17+ .gitignore
18+ .npmignore
19+ .travis.yml
20+ gulpfile.js
21+ jsconfig.json
22+ webpack.config.js
23+
24+ # misc
25+ example
26+ src
Original file line number Diff line number Diff line change 1+ language : node_js
2+ node_js :
3+ - " node"
4+
5+ sudo : false
6+
7+ cache :
8+ directories :
9+ - node_modules
10+
11+ before_install :
12+ - npm config set spin false
13+
14+ install :
15+ - npm install
16+
17+ script :
18+ - npm test
19+
20+ before_deploy :
21+ - npm run build
22+
23+ deploy :
24+ provider : npm
25+ api_key : $NPM_API_KEY
26+ on :
27+ tags : true
Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import ReactDOM from 'react-dom' ;
3+ import TestUtils from 'react-addons-test-utils' ;
4+ import ReactTree from '../src/react-tree' ;
5+ import { PROJECT_TREE } from '../example/project-tree'
6+
7+ describe ( 'ReactTree' , ( ) => {
8+ it ( 'should run be rendered' , ( ) => {
9+ const reactTree = TestUtils . renderIntoDocument (
10+ < ReactTree tree = { PROJECT_TREE } />
11+ ) ;
12+
13+ const reactTreeNode = ReactDOM . findDOMNode ( reactTree ) ;
14+
15+ expect ( reactTreeNode . textContent ) . not . toBeNull ( ) ;
16+
17+ } ) ;
18+
19+ it ( 'should run the handle function of onChanged event' , ( ) => {
20+ const handleOnChanged = jest . fn ( ) ;
21+
22+ const reactTree = TestUtils . renderIntoDocument (
23+ < ReactTree tree = { PROJECT_TREE } onChanged = { handleOnChanged } />
24+ ) ;
25+
26+ expect ( handleOnChanged ) . toBeCalled ( ) ;
27+ } ) ;
28+ } ) ;
Original file line number Diff line number Diff line change 1- import ReactTree from '../lib/react-tree' ;
1+ import 'jstree/dist/themes/default/style.min.css' ;
2+ import 'jstree/dist/themes/default-dark/style.min.css' ;
3+
24import ReactDOM from 'react-dom' ;
5+ import ReactTree from '../src/react-tree' ;
6+ import { PROJECT_TREE } from './project-tree' ;
7+
8+ class ExampleApp extends React . Component {
9+ constructor ( props ) {
10+ super ( props ) ;
11+
12+ this . state = { items : [ ] } ;
13+
14+ this . handleOnChanged = this . handleOnChanged . bind ( this ) ;
15+ }
16+ handleOnChanged ( changedItems ) {
17+ this . setState ( {
18+ items : changedItems . map ( item => item . text ) . join ( ', ' )
19+ } ) ;
20+ }
21+
22+ render ( ) {
23+ return (
24+ < div >
25+ < ReactTree tree = { PROJECT_TREE } onChanged = { this . handleOnChanged } />
26+ < div > Selected items: { this . state . items } </ div >
27+ </ div >
28+ ) ;
29+ }
30+ }
331
4- ReactDOM . render ( < ReactTree /> , document . getElementById ( 'app' ) ) ;
32+ ReactDOM . render ( < ExampleApp /> , document . getElementById ( 'app' ) ) ;
Original file line number Diff line number Diff line change 22< html >
33
44< head >
5- < title > example react-tree</ title >
5+ < title > Example App</ title >
6+ < link rel ="stylesheet " type ="text/css " href ="assets/styles.css ">
67
78 < script src ="https://fb.me/react-15.3.0.js "> </ script >
89 < script src ="https://fb.me/react-dom-15.3.0.js "> </ script >
1112< body >
1213 < div id ="app "> </ div >
1314
14- < script src ="bundle.js "> </ script >
15+ < script src ="assets/ bundle.js "> </ script >
1516</ body >
1617
1718</ html >
Original file line number Diff line number Diff line change 1+ export const PROJECT_TREE = [
2+ {
3+ text : '.vscode' ,
4+ state : {
5+ opened : true ,
6+ selected : true
7+ } ,
8+ children : [
9+ { text : 'settings.json' , icon : 'jstree-file' }
10+ ]
11+ } ,
12+ {
13+ text : 'example' ,
14+ state : {
15+ opened : true ,
16+ } ,
17+ children : [
18+ { text : 'app.js' , icon : 'jstree-file' } ,
19+ { text : 'index.html' , icon : 'jstree-file' }
20+ ]
21+ } ,
22+ {
23+ text : 'lib' ,
24+ state : {
25+ opened : true ,
26+ } ,
27+ children : [
28+ { text : 'react-tree.js' , icon : 'jstree-file' }
29+ ]
30+ } ,
31+ {
32+ text : 'node_modules' ,
33+ children : [ ]
34+ } ,
35+ { text : '.babelrc' , icon : 'jstree-file' } ,
36+ { text : '.gitignore' , icon : 'jstree-file' } ,
37+ { text : 'jsconfig.json' , icon : 'jstree-file' } ,
38+ { text : 'LICENSE' , icon : 'jstree-file' } ,
39+ { text : 'package.json' , icon : 'jstree-file' } ,
40+ { text : 'webpack.config.js' , icon : 'jstree-file' }
41+ ] ;
Original file line number Diff line number Diff line change 1+ const gulp = require ( 'gulp' ) ;
2+ const babel = require ( 'gulp-babel' ) ;
3+
4+ gulp . task ( 'build' , ( ) => {
5+ return gulp . src ( 'src/react-tree.js' )
6+ . pipe ( babel ( {
7+ presets : [ 'es2015' , 'react' ]
8+ } ) )
9+ . pipe ( gulp . dest ( 'lib' ) ) ;
10+ } ) ;
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 22 "name" : " react-tree" ,
33 "version" : " 0.0.0" ,
44 "description" : " The react component to present data as a tree" ,
5- "main" : " ." ,
5+ "main" : " ./lib/react-tree.js " ,
66 "scripts" : {
77 "start" : " webpack-dev-server --port=3000" ,
8- "test" : " ."
8+ "test" : " jest" ,
9+ "build" : " gulp build"
910 },
1011 "repository" : {
1112 "type" : " git" ,
3334 "babel-loader" : " ^6.2.4" ,
3435 "babel-preset-es2015" : " ^6.13.2" ,
3536 "babel-preset-react" : " ^6.11.1" ,
36- "jstree" : " ^3.3.1" ,
37+ "css-loader" : " ^0.23.1" ,
38+ "gulp" : " ^3.9.1" ,
39+ "gulp-babel" : " ^6.1.2" ,
40+ "jest-cli" : " ^14.1.0" ,
41+ "react-addons-test-utils" : " ^15.3.0" ,
3742 "webpack" : " ^1.13.1" ,
3843 "webpack-dev-server" : " ^1.14.1"
3944 },
4045 "dependencies" : {
46+ "jstree" : " ^3.3.1" ,
4147 "react" : " ^15.3.0" ,
4248 "react-dom" : " ^15.3.0"
49+ },
50+ "jest" : {
51+ "automock" : false
4352 }
4453}
You can’t perform that action at this time.
0 commit comments