Skip to content

Commit

Permalink
add new test, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tunnckoCore committed Apr 15, 2015
1 parent 1af6cfb commit 2e82bc1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 1 addition & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
var is = require('assertit').is;
var matcher = require('is-match');
var npmPkgs = require('npm-pkgs');
// var fnName = require('fn-name');
// var handle = require('handle-arguments');

/**
* Filter packages of the given [npmjs.com](http://npm.im) user,
Expand Down Expand Up @@ -44,9 +42,8 @@ module.exports = function npmPkgsFilter(username, patterns, callback) {
if (!is.kindof.function(callback)) {
throw new TypeError('[npm-pkgs-filter] expect `callback` to be function')
}

npmPkgs(username, function __npmPkgsFilterCallback(err, res) {
if (err) {
if (!is.kindof.null(err)) {
callback(err);
return;
}
Expand Down
10 changes: 10 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,14 @@ test('npm-pkgs-filter:', function() {
done();
});
});
test('should error when non existing user and filter patterns given', function(done) {
npmPkgsFilter('fjk43hkjhhhhhhhhhhhhhhhkjgg3k4g234', ['*js*', 'npm-*'], function _cb(err, res) {
test.is.error(err);
test.is.number(err.code);
test.is.undefined(res);
test.equal(err instanceof Error, true);
test.equal(err.code, 404);
done();
});
});
});

0 comments on commit 2e82bc1

Please sign in to comment.