Skip to content

Commit

Permalink
refactor: Run tests on node 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Aug 25, 2017
1 parent 366813b commit 94d539c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: node_js
node_js:
- '4'
- '8'
15 changes: 9 additions & 6 deletions test/lint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
const assert = require('assert');
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');

const globby = require('globby');
const CLIEngine = require('eslint').CLIEngine;

const readFile = promisify(fs.readFile);

const GROUPS = [
{ type: 'coffee' },
{ type: 'css' },
{
type: 'js',
validate(filename, content) {
async validate(filename, content) {
const cliEngine = new CLIEngine({
cwd: path.dirname(path.resolve(filename)),
fix: true,
Expand All @@ -22,7 +25,7 @@ const GROUPS = [

let expected = { errorCount: 0 };
try {
expected = JSON.parse(fs.readFileSync(filename + '.json', 'utf8'));
expected = JSON.parse(await readFile(`${filename}.json`, 'utf8'));
} catch (e) {
if (e.code !== 'ENOENT') throw e;
}
Expand All @@ -36,7 +39,7 @@ const GROUPS = [

let expectedSource;
try {
expectedSource = fs.readFileSync(filename.replace(/(\.\w+$)/, '.out$1'), 'utf8');
expectedSource = await readFile(filename.replace(/(\.\w+$)/, '.out$1'), 'utf8');
} catch (e) {
if (e.code !== 'ENOENT') throw e;
expectedSource = content;
Expand All @@ -62,9 +65,9 @@ GROUPS.forEach((group) => {
return;
}

it('matches the expectations', () => {
const content = fs.readFileSync(testFile, 'utf8');
validate(testFile, content);
it('matches the expectations', async () => {
const content = await readFile(testFile, 'utf8');
return validate(testFile, content);
});
});
});
Expand Down

0 comments on commit 94d539c

Please sign in to comment.