/**
 * npm-pkgs-count <https://github.com/tunnckoCore/npm-pkgs-count>
 *
 * Copyright (c) 2015 Charlike Mike Reagent, contributors.
 * Released under the MIT license.
 */

'use strict';

var is = require('assert-kindof');
var assert = require('assert');
var npmPkgsCount = require('./index');

describe('npm-pkgs-count:', function() {
  it('should throw TypeError when `username` is not a string', function(done) {
    assert.throws(function fixture() {
      npmPkgsCount({one: 'two'});
    }, /to be string, but object given/);

    try {
      npmPkgsCount({one: 'two'});
    } catch(e) {
      is.number(e.line);
      assert.strictEqual(e.actual, 'object');
      assert.strictEqual(e.expected, 'string');
      assert.strictEqual(e.problem, 'actual !== expected');
      assert.strictEqual(/to be string, but object given/.test(e.message), true);

      assert.throws(function fixture() {
        npmPkgsCount({one: 'two'});
      }, TypeError);
      done();
    }
  });


  it('should throw Error when `username` is an empty string or array', function(done) {
    assert.throws(function fixture() {
      npmPkgsCount('');
    }, /expect `username` to be non empty string/);

    assert.throws(function fixture() {
      npmPkgsCount('');
    }, Error);

    done();
  });

  it('should throw TypeError when `callback` is not a function', function(done) {
    assert.throws(function fixture() {
      npmPkgsCount('tunnckocore', [1, 2, 3]);
    }, /to be function, but array given/);

    try {
      npmPkgsCount('tunnckocore', [1, 2, 3]);
    } catch(e) {
      is.number(e.line);
      assert.strictEqual(e.actual, 'array');
      assert.strictEqual(e.expected, 'function');
      assert.strictEqual(e.problem, 'actual !== expected');
      assert.strictEqual(/to be function, but array given/.test(e.message), true);


      assert.throws(function fixture() {
        npmPkgsCount('tunnckocore', [1, 2, 3]);
      }, TypeError);
      done();
    }
  });

  it('should work properly when existing user given and callback', function(done) {
    this.timeout(30000);

    npmPkgsCount('tunnckocore', function _cb(err, cnt) {
      assert.ifError(err);
      is.number(cnt);
      assert.strictEqual(cnt > 90, true);
      done();
    });
  });

  it('should error when non existing user given', function(done) {
    this.timeout(30000);

    npmPkgsCount('fjk43hkjhhhhhhhhhhhhhhhkjgg3k4g234', function _cb(err, cnt) {
      is.number(err.code);
      is.undefined(cnt);
      assert.strictEqual(err instanceof Error, true);
      assert.strictEqual(err.code, 404);
      done();
    });
  });
});

@@ -408,38 +408,24 @@
 done) %7B%0A    
-assert.throws(
 function fix
@@ -476,87 +476,34 @@
    %7D
-, /to be string, but object given/);%0A%0A    try %7B%0A      npmPkgsCount(%7Bone: 'two'%7D
+%0A%0A    try %7B%0A      fixture(
 );%0A 
@@ -779,17 +779,16 @@
  true);%0A
-%0A
       as
@@ -804,71 +804,78 @@
 ws(f
-unction fixture() %7B%0A        npmPkgsCount(%7Bone: 'two'%7D);%0A      %7D
+ixture, /to be string, but object given/);%0A      assert.throws(fixture
 , Ty
@@ -910,18 +910,16 @@
 %7D%0A  %7D);%0A
-%0A%0A
   it('sh
@@ -998,38 +998,24 @@
 done) %7B%0A    
-assert.throws(
 function fix
@@ -1052,16 +1052,42 @@
 );%0A    %7D
+%0A    assert.throws(fixture
 , /expec
@@ -1121,25 +1121,24 @@
 y string/);%0A
-%0A
     assert.t
@@ -1148,57 +1148,14 @@
 ws(f
-unction fixture() %7B%0A      npmPkgsCount('');%0A    %7D
+ixture
 , Er
@@ -1160,17 +1160,16 @@
 Error);%0A
-%0A
     done
@@ -1170,33 +1170,32 @@
   done();%0A  %7D);%0A
-%0A
   it('should thr
@@ -1260,38 +1260,24 @@
 done) %7B%0A    
-assert.throws(
 function fix
@@ -1340,100 +1340,34 @@
    %7D
-, /to be function, but array given/);%0A%0A    try %7B%0A      npmPkgsCount('tunnckocore', %5B1, 2, 3%5D
+%0A%0A    try %7B%0A      fixture(
 );%0A 
@@ -1645,18 +1645,16 @@
  true);%0A
-%0A%0A
       as
@@ -1670,83 +1670,79 @@
 ws(f
-unction fixture() %7B%0A        npmPkgsCount('tunnckocore', %5B1, 2, 3%5D);%0A      %7D
+ixture, /to be function, but array given/);%0A      assert.throws(fixture
 , Ty
@@ -1773,25 +1773,24 @@
     %7D%0A  %7D);%0A
-%0A
   it('should
@@ -2063,17 +2063,16 @@
 ;%0A  %7D);%0A
-%0A
   it('sh

update tests