Skip to content

Commit

Permalink
Add tests for the error generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Tusch committed Sep 4, 2015
1 parent 1a93a41 commit 8929e90
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ exports.init = function(options, callback) {
colorize = options.color,
sorted = {},
filtered = {},
exclude = options.exclude && options.exclude.replace(/^\s+|\s+$/g, '').split(/\s*,\s*/);
exclude = options.exclude && options.exclude.replace(/^\s+|\s+$/g, '').split(/\s*,\s*/),
inputError = null;
Object.keys(data).sort().forEach(function(item) {
if (options.unknown) {
if (data[item].licenses && data[item].licenses !== UNKNOWN) {
Expand All @@ -159,8 +160,6 @@ exports.init = function(options, callback) {
filtered = sorted;
}

var inputError = null;

if (err) {
inputError = err;
}
Expand Down
29 changes: 29 additions & 0 deletions tests/test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var vows = require('vows'),
assert = require('assert'),
path = require('path'),
util = require('util');
checker = require('../lib/index');

var tests = {
Expand Down Expand Up @@ -85,6 +86,34 @@ var tests = {
'on undefined': function (d) {
assert.equal(d, 'Undefined');
}
},
'should init without errors': {
topic: function () {
var self = this;

checker.init({
start: path.join(__dirname, '../')
}, function (sorted, err) {
self.callback(sorted, err);
});
},
'errors should not exist': function (d, err) {
assert.equal(err, null);
}
},
'should init with errors (npm packages not found)': {
topic: function () {
var self = this;

checker.init({
start: 'C:\\'
}, function (sorted, err) {
self.callback(sorted, err);
});
},
'errors should exist': function (d, err) {
assert.isTrue(util.isError(err));
}
}
};

Expand Down

0 comments on commit 8929e90

Please sign in to comment.