Skip to content

Commit

Permalink
add generic test generation support for ember-cli applications
Browse files Browse the repository at this point in the history
  • Loading branch information
billybonks committed Jul 11, 2016
1 parent 938af8a commit b7c4f5a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
25 changes: 24 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
'use strict';

var StyleLinter = require('broccoli-stylelint');
var Funnel = require('broccoli-funnel');

module.exports = {
name: 'ember-cli-stylelint',
Expand All @@ -17,7 +16,31 @@ module.exports = {
},

lintTree: function(type, tree) {
let project = this.project;

if (type === 'app') {
this.styleLintOptions.testGenerator = function(relativePath, errors) {
let passed = null;
let name = `${relativePath} should pass style lint`;
if (errors) {
passed = false;
let assertions = [name];
for(var i = 0; i < errors.warnings.length; i++){
var warning = errors.warnings[i];
assertions.push(this.escapeErrorString(`line: ${warning.line}, col: ${warning.column}, ${warning.text}.`));
}
errors = assertions.join('\\n');
} else {
passed = true;
errors = "";
}

return project.generateTestFile(' Style Lint ', [{
name: name,
passed: !!passed,
errorMessage: errors
}]);
};
return new StyleLinter(this.app.trees.styles, this.styleLintOptions);
} else {
return tree;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
],
"dependencies": {
"broccoli-funnel": "^1.0.1",
"broccoli-stylelint": "^0.3.0"
"broccoli-stylelint": "^0.4.1"
},
"ember-addon": {
"configPath": "tests/dummy/config"
Expand Down

0 comments on commit b7c4f5a

Please sign in to comment.