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

'use strict';

var assert = require('assert');
var stringify = require('./index');

describe('stringify-github-short-url:', function() {
  describe('should throw', function() {
    it('Error when no arguments', function(done) {
      assert.throws(stringify, Error);
      done()
    });

    it('TypeError when first argument not Object given', function(done) {
      function fixture() {
        stringify('some string')
      }
      assert.throws(fixture, TypeError);
      done();
    });

    it('TypeError when Array given', function(done) {
      function fixture() {
        stringify(['some string'])
      }
      assert.throws(fixture, TypeError);
      done();
    });
  });

  describe('should return empty string', function(done) {
    it('when object not contain `user` property', function(done) {
      var actual = stringify({
        user: '',
        username: '',
        org: '',
        organization: '',
        repo: '',
        repository: '',
        branch: ''
      });
      var expected = '';

      assert.strictEqual(typeof actual, typeof expected);
      assert.strictEqual(actual, expected);
      done();
    });

    it('when empty object given', function(done) {
      var actual = stringify({});
      var expected = '';

      assert.strictEqual(typeof actual, typeof expected);
      assert.strictEqual(actual, expected);
      done();
    });
  });

  describe('should return', function() {
    it('string for given `user`, `repo` and `branch`', function(done) {
      var actual = stringify({
        user: 'tunnckoCore',
        username: 'tunnckoCore',
        org: 'tunnckoCore',
        organization: 'tunnckoCore',
        repo: 'glob2fp',
        repository: 'glob2fp',
        branch: 'feature'
      });
      var expected = 'tunnckoCore/glob2fp#feature';

      assert.strictEqual(actual, expected);
      done();
    });

    it('string for given `user` and `repo` properties only', function(done) {
      var actual = stringify({
        user: 'jonschlinkert',
        username: 'jonschlinkert',
        org: 'jonschlinkert',
        organization: 'jonschlinkert',
        repo: 'kind-of',
        repository: 'kind-of',
        branch: ''
      });
      var expected = 'jonschlinkert/kind-of';

      assert.strictEqual(actual, expected);
      done();
    });
  });
});

@@ -1565,32 +1565,372 @@
  done();%0A    %7D);
+%0A%0A    it('and handle it with callback', function(done) %7B%0A      stringify(%7B%0A        beta: false,%0A        nick: 'test'%0A      %7D, function(err, res) %7B%0A        var actual = res;%0A        var expected = '';%0A%0A        assert.strictEqual(typeof actual, typeof expected);%0A        assert.strictEqual(actual, expected);%0A        done();%0A      %7D);%0A    %7D);
 %0A  %7D);%0A%0A  descri
@@ -2333,24 +2333,82 @@
 #feature';%0A%0A
+      assert.strictEqual(typeof actual, typeof expected);%0A
       assert
@@ -2867,38 +2867,1104 @@
 ual(
-actual, expected);%0A      done(
+typeof actual, typeof expected);%0A      assert.strictEqual(actual, expected);%0A      done();%0A    %7D);%0A%0A    it('and handle them with callback', function(done) %7B%0A      stringify(%7B%0A        user: 'jonschlinkert',%0A        username: 'jonschlinkert',%0A        org: 'jonschlinkert',%0A        organization: 'jonschlinkert',%0A        repo: 'kind-of',%0A        repository: 'kind-of',%0A        branch: ''%0A      %7D, function(err, res) %7B%0A        var actual = res;%0A        var expected = 'jonschlinkert/kind-of';%0A%0A        assert.strictEqual(typeof actual, typeof expected);%0A        assert.strictEqual(actual, expected);%0A%0A        stringify(%7B%0A          user: 'tunnckoCore',%0A          username: 'tunnckoCore',%0A          org: 'tunnckoCore',%0A          organization: 'tunnckoCore',%0A          repo: 'glob2fp',%0A          repository: 'glob2fp',%0A          branch: 'feature'%0A        %7D, function(err, res) %7B%0A          actual = res;%0A          expected = 'tunnckoCore/glob2fp#feature';%0A%0A          assert.strictEqual(typeof actual, typeof expected);%0A          assert.strictEqual(actual, expected);%0A          done();%0A        %7D);%0A      %7D
 );%0A 

update tests for refactored code