UNPKG

bit-bin

Version:

<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b

66 lines (54 loc) 1.98 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); function _chai() { const data = require("chai"); _chai = function () { return data; }; return data; } function _versionParser() { const data = _interopRequireDefault(require("../version/version-parser")); _versionParser = function () { return data; }; return data; } function _exceptions() { const data = require("./exceptions"); _exceptions = function () { return data; }; return data; } describe('versionParser()', () => { it('should return latest version representation', () => { const version = (0, _versionParser().default)('latest'); (0, _chai().expect)(version.latest).to.equal(true); (0, _chai().expect)(version.versionNum).to.equal(null); }); it('should throw invalid version', () => { const version = () => (0, _versionParser().default)('$1'); (0, _chai().expect)(version).to.throw(_exceptions().InvalidVersion); }); it('should return a concrete version', () => { const version = (0, _versionParser().default)('0.0.1'); (0, _chai().expect)(version.latest).to.equal(false); (0, _chai().expect)(version.versionNum).to.equal('0.0.1'); }); it('should return a latest tested version', () => { const version = (0, _versionParser().default)('*0.0.1'); (0, _chai().expect)(version.latest).to.equal(true); (0, _chai().expect)(version.versionNum).to.equal('0.0.1'); }); it('should return a latest tested version with double digits', () => { const version = (0, _versionParser().default)('*0.0.11'); (0, _chai().expect)(version.latest).to.equal(true); (0, _chai().expect)(version.versionNum).to.equal('0.0.11'); }); it('should parse given version as latest', () => { const version = (0, _versionParser().default)('latest'); (0, _chai().expect)(version.versionNum).to.equal(null); (0, _chai().expect)(version.latest).to.equal(true); }); });