"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

function _chai() {
  const data = require("chai");

  _chai = function () {
    return data;
  };

  return data;
}

function _version() {
  const data = _interopRequireDefault(require("../version"));

  _version = function () {
    return data;
  };

  return data;
}

describe('Version', () => {
  describe('toString()', () => {
    it('should return a latest tested version', () => {
      const version = new (_version().default)(10, true);
      (0, _chai().expect)(version.toString()).to.equal('*10');
    });
    it('should return latest', () => {
      const version = new (_version().default)(null, true);
      (0, _chai().expect)(version.toString()).to.equal('latest');
    });
    it('should return concrete version number', () => {
      const version = new (_version().default)(12, false);
      (0, _chai().expect)(version.toString()).to.equal('12');
    });
    it('should throw an invalid version exception', () => {
      const version = new (_version().default)(null, false);
      (0, _chai().expect)(() => {
        version.toString();
      }).to.throw();
    });
  });
  describe('increase()', () => {
    it('should increase patch version by one by default', () => {
      const version = new (_version().default)('0.0.1', false);
      version.increase();
      (0, _chai().expect)(version.versionNum).to.equal('0.0.2');
    });
    it('should increase patch version by one', () => {
      const version = new (_version().default)('0.0.1', false);
      version.increase('patch');
      (0, _chai().expect)(version.versionNum).to.equal('0.0.2');
    });
    it('should increase minor version by one', () => {
      const version = new (_version().default)('0.0.1', false);
      version.increase('minor');
      (0, _chai().expect)(version.versionNum).to.equal('0.1.0');
    });
    it('should increase major version by one', () => {
      const version = new (_version().default)('0.0.1', false);
      version.increase('major');
      (0, _chai().expect)(version.versionNum).to.equal('1.0.0');
    });
    it('should increase latest tested version by one', () => {
      const version = new (_version().default)('0.0.1', true);
      version.increase();
      (0, _chai().expect)(version.versionNum).to.equal('0.0.2');
    });
    it('should throw an InvalidVersionChange error when trying to increase or decrease latest', () => {
      const version = new (_version().default)(null, true);
      (0, _chai().expect)(() => {
        version.increase();
      }).to.throw();
    });
  });
});