Skip to content

Commit

Permalink
Add ES2015 test.
Browse files Browse the repository at this point in the history
  • Loading branch information
izaakschroeder committed Jan 9, 2017
1 parent 2307346 commit f22168f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .babelrc
@@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}
3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -40,6 +40,9 @@
"parse-json": "^2.2.0"
},
"devDependencies": {
"babel-core": "^6.21.0",
"babel-preset-es2015": "^6.18.0",
"babel-register": "^6.18.0",
"eslint": "^3.13.0",
"eslint-config-davidtheclark-node": "^0.2.0",
"eslint-plugin-node": "^3.0.5",
Expand Down
2 changes: 1 addition & 1 deletion test/failed-directories.test.js
Expand Up @@ -226,7 +226,7 @@ test('find invalid JS in .config.js file', function (assert) {
callback({ code: 'ENOENT' });
break;
case absolutePath('a/b/foo.config.js'):
callback(null, 'module.exports = { found: true: false,');
callback(null, '/* woot */');
break;
default:
callback(new Error('irrelevant path ' + searchPath));
Expand Down
2 changes: 2 additions & 0 deletions test/fixtures/foo.babel.js
@@ -0,0 +1,2 @@
const foo = true;
export default {foo};
17 changes: 17 additions & 0 deletions test/successful-files.test.js
Expand Up @@ -4,6 +4,10 @@ var test = require('tape');
var path = require('path');
var cosmiconfig = require('..');

require('babel-register')({
only: /\.babel\.js$/,
});

function absolutePath(str) {
return path.join(__dirname, str);
}
Expand Down Expand Up @@ -47,6 +51,19 @@ test('defined JS config path', function (assert) {
});
});

test('defined ES6 config path', function (assert) {
var loadConfig = cosmiconfig().load;
loadConfig(null, absolutePath('fixtures/foo.babel.js')).then(function (result) {
assert.deepEqual(result.config, {
foo: true,
});
assert.equal(result.filepath, absolutePath('fixtures/foo.babel.js'));
assert.end();
}).catch(function (err) {
assert.end(err);
});
});

test('defined modulized JS config path', function (assert) {
var loadConfig = cosmiconfig().load;
loadConfig(null, absolutePath('fixtures/foo-module.js')).then(function (result) {
Expand Down

0 comments on commit f22168f

Please sign in to comment.