Skip to content

Commit 4ae858f

Browse files
author
Philipp Alferov
committed
Set up testing environment
1 parent 7f5b9cc commit 4ae858f

File tree

7 files changed

+46
-4
lines changed

7 files changed

+46
-4
lines changed

.eslintrc

+4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@ root: true
33
env:
44
node: true
55
es6: true
6+
mocha: true
67

78
ecmaFeatures:
89
modules: true
910

1011
extends:
1112
"eslint:recommended"
13+
14+
globals:
15+
should: true

gulpfile.babel.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
import gulp from 'gulp';
22
import mocha from 'gulp-mocha';
33

4-
const src = './index.js';
4+
const config = {
5+
src: './index.js',
6+
test: './test/**/*.js'
7+
};
58

69
gulp.task('test', () => {
7-
return gulp.src('test.js', { read: false })
10+
return gulp.src(config.test, { read: false })
811
.pipe(mocha({ reporter: 'nyan' }));
912
});
1013

1114
gulp.task('watch', () => {
12-
gulp.watch(src, ['test']);
15+
gulp.watch([config.src, config.test], ['test']);
1316
});
1417

1518
gulp.task('default', ['watch']);

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
"eslint": "^1.4.1",
1919
"gulp": "^3.9.0",
2020
"gulp-mocha": "^2.1.3",
21-
"mocha": "^2.3.0"
21+
"mocha": "^2.3.0",
22+
"should": "^7.1.0"
2223
},
2324
"author": "Philipp Alferov <philipp.alferov@gmail.com>",
2425
"license": "MIT"

test.js

Whitespace-only changes.

test/fixtures/expected.fixture.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = [{
2+
id: 1,
3+
children: [{
4+
id: 2,
5+
children: [{
6+
id: 3
7+
}]
8+
}]
9+
}, {
10+
id: 4
11+
}];

test/fixtures/initial.fixture.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
module.exports = [{
2+
id: 1,
3+
parent_id: null
4+
}, {
5+
id: 2,
6+
parent_id: 1
7+
}, {
8+
id: 3,
9+
parent_id: 2
10+
}, {
11+
id: 4,
12+
parent_id: null
13+
}];

test/test.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var assert = require('assert');
2+
var should = require('should');
3+
var toTree = require('../index.js');
4+
var expected = require('./fixtures/expected.fixture.js');
5+
var initial = require('./fixtures/initial.fixture.js');
6+
var current;
7+
8+
describe('parent pointer array to tree', function() {
9+
10+
});

0 commit comments

Comments
 (0)