Skip to content

Commit

Permalink
add test for custom formatters
Browse files Browse the repository at this point in the history
  • Loading branch information
sonicoder86 committed Nov 30, 2016
1 parent ce5a114 commit 0a74d57
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"lint": "eslint --ext .js .",
"deploy": "np --skip-cleanup",
"test": "mocha ./test/loader.spec.js"
"test": "mocha ./test/loader.spec.js --timeout 3000"
},
"repository": {
"type": "git",
Expand Down
12 changes: 12 additions & 0 deletions test/formatters/simpleFormatter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

function SimpleFormatter() {}

SimpleFormatter.prototype.format = function (failures) {
var outputLines = failures.map(function (failure) {
return failure.getFailure();
});
return outputLines.join("\n") + "\n";
};

module.exports.Formatter = SimpleFormatter;
19 changes: 19 additions & 0 deletions test/loader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,23 @@ describe('TslintLoader', function() {
done();
});
});

it('should use custom formatter with custom directory', function(done) {
var localConfig = assign({}, webpackConfig, {
tslint: {
formattersDirectory: 'test/formatters/',
formatter: 'simple',
}
});

webpack(localConfig, function(err, stats) {
if (err) return done(err);

var result = stats.toJson();
expect(result.warnings).to.eql([
'./test/app/engine.ts\nCalls to \'console.log\' are not allowed.\n'
]);
done();
});
});
});

0 comments on commit 0a74d57

Please sign in to comment.