Skip to content

Commit

Permalink
Use new "group" option by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Turbo87 committed May 1, 2017
1 parent 80d820a commit 4abd4c1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 5 deletions.
12 changes: 9 additions & 3 deletions ember-cli-build.js
Expand Up @@ -6,9 +6,15 @@ var path = require('path');
var EmberAddon = require('ember-cli/lib/broccoli/ember-addon');

module.exports = function (defaults) {
var app = new EmberAddon(defaults, {
// Add options here
});
let options = {
eslint: {},
};

if (process.env['NO_GROUPING']) {
options.eslint.group = false;
}

var app = new EmberAddon(defaults, options);

// Use `app.import` to add additional libraries to the generated
// output files.
Expand Down
1 change: 1 addition & 0 deletions index.js
Expand Up @@ -43,6 +43,7 @@ module.exports = {

return ESLint.create(tree, {
testGenerator: this.options.testGenerator || this._testGenerator,
group: (this.options.group !== false) ? type : undefined,

console: {
log: function(message) {
Expand Down
54 changes: 52 additions & 2 deletions node-tests/test.js
Expand Up @@ -14,6 +14,8 @@ describe('ember-cli-eslint', function() {
});

it('passes if ESLint tests pass', function() {
process.env['NO_GROUPING'] = true;

return emberTest().then(function(result) {
expect(result.error).to.not.exist;
expect(result.stdout.match(/[^\r\n]+/g))
Expand All @@ -32,9 +34,11 @@ describe('ember-cli-eslint', function() {
});

it('fails if a ESLint tests fails', function() {
process.env['NO_GROUPING'] = true;

fs.outputFileSync(FAILING_FILE, 'let unused = 6;\n');

return emberTest().then(function(result) {
return emberTest({ NO_GROUPING: true }).then(function(result) {
expect(result.error).to.exist;
expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 1 PhantomJS 2.1 - ESLint | app.js: should pass ESLint')
Expand All @@ -50,11 +54,57 @@ describe('ember-cli-eslint', function() {
.to.contain('not ok 11 PhantomJS 2.1 - ESLint | unused.js: should pass ESLint');
})
});

it('passes if ESLint tests pass (grouped)', function() {
delete process.env['NO_GROUPING'];

return emberTest().then(function(result) {
expect(result.error).to.not.exist;
expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 1 PhantomJS 2.1 - ESLint | app: app.js')
.to.contain('ok 2 PhantomJS 2.1 - ESLint | app: controllers/thing.js')
.to.contain('ok 3 PhantomJS 2.1 - ESLint | app: models/thing.js')
.to.contain('ok 4 PhantomJS 2.1 - ESLint | app: resolver.js')
.to.contain('ok 5 PhantomJS 2.1 - ESLint | app: router.js')
.to.not.contain('not ok 6 PhantomJS 2.1 - ESLint | app: unused.js');

expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 6 PhantomJS 2.1 - ESLint | tests: helpers/destroy-app.js')
.to.contain('ok 7 PhantomJS 2.1 - ESLint | tests: helpers/module-for-acceptance.js')
.to.contain('ok 8 PhantomJS 2.1 - ESLint | tests: helpers/resolver.js')
.to.contain('ok 9 PhantomJS 2.1 - ESLint | tests: helpers/start-app.js')
.to.contain('ok 10 PhantomJS 2.1 - ESLint | tests: test-helper.js');
})
});

it('fails if a ESLint tests fails (grouped)', function() {
delete process.env['NO_GROUPING'];

fs.outputFileSync(FAILING_FILE, 'let unused = 6;\n');

return emberTest().then(function(result) {
expect(result.error).to.exist;
expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 1 PhantomJS 2.1 - ESLint | app: app.js')
.to.contain('ok 2 PhantomJS 2.1 - ESLint | app: controllers/thing.js')
.to.contain('ok 3 PhantomJS 2.1 - ESLint | app: models/thing.js')
.to.contain('ok 4 PhantomJS 2.1 - ESLint | app: resolver.js')
.to.contain('ok 5 PhantomJS 2.1 - ESLint | app: router.js')
.to.contain('not ok 6 PhantomJS 2.1 - ESLint | app: unused.js');

expect(result.stdout.match(/[^\r\n]+/g))
.to.contain('ok 7 PhantomJS 2.1 - ESLint | tests: helpers/destroy-app.js')
.to.contain('ok 8 PhantomJS 2.1 - ESLint | tests: helpers/module-for-acceptance.js')
.to.contain('ok 9 PhantomJS 2.1 - ESLint | tests: helpers/resolver.js')
.to.contain('ok 10 PhantomJS 2.1 - ESLint | tests: helpers/start-app.js')
.to.contain('ok 11 PhantomJS 2.1 - ESLint | tests: test-helper.js');
})
});
});

function emberTest() {
return new Promise(function(resolve) {
exec('node_modules/.bin/ember test', { cwd: __dirname + '/..' }, function (error, stdout, stderr) {
exec('node_modules/.bin/ember test', { cwd: __dirname + '/..', env: process.env }, function (error, stdout, stderr) {
resolve({
error: error,
stdout: stdout,
Expand Down

0 comments on commit 4abd4c1

Please sign in to comment.