'use strict';

var _chai;

function _load_chai() {
  return _chai = require('chai');
}

var _version;

function _load_version() {
  return _version = _interopRequireDefault(require('../../src/version'));
}

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

describe('Version', function () {
  describe('toString()', function () {
    it('should return a latest tested version', function () {
      var version = new (_version || _load_version()).default(10, true);
      (0, (_chai || _load_chai()).expect)(version.toString()).to.equal('*10');
    });

    it('should return latest', function () {
      var version = new (_version || _load_version()).default(null, true);
      (0, (_chai || _load_chai()).expect)(version.toString()).to.equal('latest');
    });

    it('should return concrete version number', function () {
      var version = new (_version || _load_version()).default(12, false);
      (0, (_chai || _load_chai()).expect)(version.toString()).to.equal('12');
    });

    it('should throw an invalid version exception', function () {
      var version = new (_version || _load_version()).default(null, false);
      (0, (_chai || _load_chai()).expect)(function () {
        version.toString();
      }).to.throw();
    });
  });

  describe('increase()', function () {
    it('should increase patch version by one by default', function () {
      var version = new (_version || _load_version()).default('0.0.1', false);
      version.increase();
      (0, (_chai || _load_chai()).expect)(version.versionNum).to.equal('0.0.2');
    });

    it('should increase patch version by one', function () {
      var version = new (_version || _load_version()).default('0.0.1', false);
      version.increase('patch');
      (0, (_chai || _load_chai()).expect)(version.versionNum).to.equal('0.0.2');
    });

    it('should increase minor version by one', function () {
      var version = new (_version || _load_version()).default('0.0.1', false);
      version.increase('minor');
      (0, (_chai || _load_chai()).expect)(version.versionNum).to.equal('0.1.0');
    });

    it('should increase major version by one', function () {
      var version = new (_version || _load_version()).default('0.0.1', false);
      version.increase('major');
      (0, (_chai || _load_chai()).expect)(version.versionNum).to.equal('1.0.0');
    });

    it('should increase latest tested version by one', function () {
      var version = new (_version || _load_version()).default('0.0.1', true);
      version.increase();
      (0, (_chai || _load_chai()).expect)(version.versionNum).to.equal('0.0.2');
    });

    it('should throw an InvalidVersionChange error when trying to increase or decrease latest', function () {
      var version = new (_version || _load_version()).default(null, true);
      (0, (_chai || _load_chai()).expect)(function () {
        version.increase();
      }).to.throw();
    });
  });

  describe('parse()', function () {
    it('should parse given version as latest', function () {
      var version = (_version || _load_version()).default.parse('latest');
      (0, (_chai || _load_chai()).expect)(version.versionNum).to.equal(null);
      (0, (_chai || _load_chai()).expect)(version.latest).to.equal(true);
    });
  });
});