Skip to content

Commit 5773580

Browse files
committed
Add initial tests
1 parent c4b8ee2 commit 5773580

File tree

4 files changed

+40
-37
lines changed

4 files changed

+40
-37
lines changed

gulpfile.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
const gulp = require('gulp');
22
const eslint = require('gulp-eslint');
3-
const mocha = require('gulp-mocha-phantomjs');
3+
const mocha = require('gulp-mocha');
44
const header = require('gulp-header');
55
const webpack = require('webpack-stream');
66
const scsslint = require('gulp-scss-lint');
77
const sass = require('gulp-sass');
88
const autoprefixer = require('gulp-autoprefixer');
9+
const babel = require('babel-core/register');
910
const pkg = require('./package.json');
1011
const browserSync = require('browser-sync').create();
1112
const webpackConfig = require('./webpack.config');
@@ -20,21 +21,18 @@ gulp.task('test-script-format', () =>
2021
.pipe(eslint.failOnError())
2122
);
2223

23-
gulp.task('compile-test-script', () =>
24-
gulp.src(['./test/index.js'])
25-
.pipe(webpack(webpackConfig))
26-
.pipe(gulp.dest('./test/compiled/'))
27-
);
28-
29-
// Disabled for now
30-
gulp.task('test-mocha', ['script-compile-test'], () =>
31-
gulp.src(['test/test.html'])
32-
.pipe(mocha({ reporter: 'spec' }))
24+
gulp.task('test-mocha', ['test-script-format'], () =>
25+
gulp.src(['./test/**/*.js'])
26+
.pipe(mocha({
27+
compilers: {
28+
js: babel,
29+
},
30+
}))
3331
);
3432

35-
gulp.task('test-script', ['test-script-format']);
33+
gulp.task('test', ['test-script-format', 'test-mocha']);
3634

37-
gulp.task('build-script', ['test-script'], () =>
35+
gulp.task('build-script', ['test'], () =>
3836
gulp.src(['./src/index.js'])
3937
.pipe(webpack(webpackConfig))
4038
.pipe(header(banner, { pkg }))

package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"babel-preset-stage-0": "^6.5.0",
3232
"browser-sync": "^2.18.6",
3333
"chai": "^3.5.0",
34+
"enzyme": "^2.7.1",
3435
"eslint": "^3.13.0",
3536
"eslint-config-airbnb": "^14.0.0",
3637
"eslint-plugin-import": "^2.2.0",
@@ -40,12 +41,14 @@
4041
"gulp-autoprefixer": "^3.1.1",
4142
"gulp-eslint": "^3.0.1",
4243
"gulp-header": "^1.8.8",
44+
"gulp-mocha": "^3.0.1",
4345
"gulp-mocha-phantomjs": "^0.12.0",
4446
"gulp-sass": "^3.0.0",
4547
"gulp-scss-lint": "^0.4.0",
4648
"mocha": "^3.0.2",
47-
"react": "^15.3.0",
48-
"react-dom": "^15.3.0",
49+
"react": "^15.4.2",
50+
"react-addons-test-utils": "^15.4.2",
51+
"react-dom": "^15.4.2",
4952
"webpack": "^1.13.1",
5053
"webpack-stream": "^3.2.0"
5154
}

test/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import { shallow } from 'enzyme';
3+
import { assert } from 'chai';
4+
5+
import CheckboxTree from '../src/js/Tree';
6+
7+
describe('<CheckboxTree />', () => {
8+
describe('component', () => {
9+
it('should render the react-checkbox-tree container', () => {
10+
const wrapper = shallow(
11+
<CheckboxTree
12+
checked={[]}
13+
expanded={[]}
14+
nodes={[]}
15+
onCheck={() => {}}
16+
onExpand={() => {}}
17+
/>,
18+
);
19+
20+
assert.isTrue(wrapper.find('.react-checkbox-tree').exists());
21+
});
22+
});
23+
});
24+

test/test.html

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)