Skip to content
This repository was archived by the owner on Jul 15, 2021. It is now read-only.

Commit e2a8526

Browse files
committed
Upgrade tests to ES2015. Refs #15
1 parent c8ec132 commit e2a8526

3 files changed

Lines changed: 35 additions & 17 deletions

File tree

Gruntfile.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = function(grunt) {
66
' * @author Nick Wronski <nick@javascript.com>\n' +
77
' */';
88
}
9+
const mochaCmd = './node_modules/.bin/mocha --compilers js:babel-core/register';
910
grunt.initConfig({
1011
pkg: grunt.file.readJSON('package.json'),
1112
browserify: {
@@ -103,27 +104,27 @@ module.exports = function(grunt) {
103104
options: {
104105
failOnError: true
105106
},
106-
command: './node_modules/.bin/pegjs --optimize speed src/grammar.pegjs lib/parser.js'
107+
command: './node_modules/.bin/pegjs -e parser --optimize speed src/grammar.pegjs .tmp/parser.js'
107108
},
108109
test: {
109110
options: {
110111
failOnError: true
111112
},
112-
command: './node_modules/.bin/mocha --reporter=nyan'
113+
command: `${mochaCmd} --reporter=nyan`
113114
},
114115
debug: {
115116
options: {
116117
failOnError: false,
117118
debounceDelay: 500,
118119
forever: true
119120
},
120-
command: 'DEBUG=true ./node_modules/.bin/mocha'
121+
command: `DEBUG=true ${mochaCmd}`
121122
},
122123
rewrite: {
123124
options: {
124125
failOnError: true
125126
},
126-
command: 'REWRITE=true ./node_modules/.bin/mocha'
127+
command: `REWRITE=true ${mochaCmd}`
127128
}
128129
},
129130
connect: {
@@ -136,6 +137,17 @@ module.exports = function(grunt) {
136137
}
137138
},
138139
watch: {
140+
test: {
141+
options: {
142+
debounceDelay: 250,
143+
livereload: false
144+
},
145+
files: [
146+
'index.js', 'test/**/*.js', 'src/*.js', 'src/*.pegjs',
147+
'test/sql/**/*.sql', 'test/json/**/*.json', 'Gruntfile.js'
148+
],
149+
tasks: ['build', 'shell:test']
150+
},
139151
debug: {
140152
options: {
141153
debounceDelay: 250,
@@ -252,6 +264,9 @@ module.exports = function(grunt) {
252264
grunt.registerTask('test', [
253265
'build', 'shell:test'
254266
]);
267+
grunt.registerTask('test-watch', [
268+
'test', 'watch:test'
269+
]);
255270
grunt.registerTask('debug', [
256271
'build', 'shell:debug', 'watch:debug'
257272
]);

test/helpers.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
var expect = require('chai').expect,
2-
fs = require('fs'),
3-
Promise = require('promise'),
4-
read = Promise.denodeify(fs.readFile),
5-
write = Promise.denodeify(fs.writeFile),
6-
_ = require('lodash'),
7-
parser = require('../index'),
8-
sqliteParser = Promise.denodeify(parser),
9-
prettyjson = require('prettyjson'),
10-
format, broadcast,
1+
import {expect} from 'chai';
2+
import {readFile, writeFile} from 'fs';
3+
import {all, promisify} from 'bluebird';
4+
import _ from 'lodash';
5+
import parser from '../index';
6+
import prettyjson from 'prettyjson';
7+
8+
const read = promisify(readFile);
9+
const write = promisify(writeFile);
10+
const sqliteParser = promisify(parser);
11+
12+
let format, broadcast,
1113
filePath,
1214
getTree, getTestJson, getTestFiles,
13-
assertOkTree, assertErrorTree,
15+
assertOkTree, assertErrorTree, assertEqualsTree,
1416
isDefined = function (arg) { return arg != null; };
1517

1618
broadcast = function broadcast(args) {
@@ -65,7 +67,7 @@ getTestJson = function (that) {
6567

6668
getTestFiles = function (that) {
6769
var getFiles = function () {
68-
return Promise.all([getTree(that), getTestJson(that)]);
70+
return all([getTree(that), getTestJson(that)]);
6971
};
7072
if (_.has(process.env, 'REWRITE')) {
7173
// REWRITE MODE: Save a new JSON file using parser tree result

test/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
global.tree = require('./helpers');
1+
import * as tree from './helpers';
2+
global.tree = tree;

0 commit comments

Comments
 (0)