58 lines
No EOL
3.1 KiB
JavaScript
58 lines
No EOL
3.1 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const tslib_1 = require("tslib");
|
|
const assert_1 = tslib_1.__importDefault(require("assert"));
|
|
const versions_1 = require("./versions");
|
|
const v0 = [0, 0, 0];
|
|
const v1 = [1, 0, 0];
|
|
const v1_2 = [1, 2, 0];
|
|
const v1_2_3 = [1, 2, 3];
|
|
describe('isValidVersion()', () => {
|
|
it('should recognise valid versions', () => {
|
|
assert_1.default.ok(versions_1.isValidVersion('v1.0.0'));
|
|
assert_1.default.ok(versions_1.isValidVersion('1.0.0'));
|
|
assert_1.default.ok(versions_1.isValidVersion('0.1.0'));
|
|
assert_1.default.ok(versions_1.isValidVersion('0.0.1'));
|
|
assert_1.default.ok(versions_1.isValidVersion('0.0.0'));
|
|
assert_1.default.ok(versions_1.isValidVersion('v0.0.0'));
|
|
});
|
|
it('should recognise invalid versions', () => {
|
|
assert_1.default.ok(!versions_1.isValidVersion('v 1.0.0'));
|
|
assert_1.default.ok(!versions_1.isValidVersion('1'));
|
|
assert_1.default.ok(!versions_1.isValidVersion('1.1'));
|
|
});
|
|
});
|
|
describe("parseVersion()", () => {
|
|
it("should parse simple versions", () => {
|
|
assert_1.default.deepStrictEqual(versions_1.parseVersion('v0.0.0'), v0);
|
|
assert_1.default.deepStrictEqual(versions_1.parseVersion('v1.0.0'), v1);
|
|
assert_1.default.deepStrictEqual(versions_1.parseVersion('v1.2.0'), v1_2);
|
|
assert_1.default.deepStrictEqual(versions_1.parseVersion('v1.2.3'), v1_2_3);
|
|
});
|
|
});
|
|
describe('compareVersions()', () => {
|
|
it('should compare equal version', () => {
|
|
assert_1.default.throws(() => versions_1.compareVersions('', ''));
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.0.0', '1.0.0'), 0);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.2.0', '1.2.0'), 0);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.2.3', '1.2.3'), 0);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('v1.0.0', '1.0.0'), 0);
|
|
});
|
|
it('should compare greater version', () => {
|
|
assert_1.default.throws(() => versions_1.compareVersions('', ''));
|
|
assert_1.default.strictEqual(versions_1.compareVersions('2.0.0', '1.0.0'), 1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.1.0', '1.0.0'), 1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.0.4', '1.0.0'), 1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('v1.1.0', '1.0.0'), 1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.1.0', 'v1.0.0'), 1);
|
|
});
|
|
it('should compare smaller version', () => {
|
|
assert_1.default.throws(() => versions_1.compareVersions('', ''));
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.0.0', '2.0.0'), -1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.0.0', '1.1.0'), -1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.0.0', '1.0.4'), -1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('1.0.0', 'v1.1.0'), -1);
|
|
assert_1.default.strictEqual(versions_1.compareVersions('v1.0.0', '1.1.0'), -1);
|
|
});
|
|
});
|
|
//# sourceMappingURL=versions.test.js.map
|