[test]: ensure we are checking for less than as well

This commit is contained in:
Ryan LaForge 2022-09-20 16:32:50 -06:00
parent 0191197595
commit e7fbd54975

View File

@ -1,4 +1,4 @@
import { getVersionObject } from "../get-version";
import {getVersionObject} from "../get-version";
import * as semver from 'semver';
// The latest version since this test was last changed
@ -6,17 +6,24 @@ import * as semver from 'semver';
const latest = '0.6.23';
describe("get-version", () => {
describe('latest range versions', () => {
it.each(["latest", "^0", "0.*.*"] as const)("should match %s versions", async (ver) => {
const v = await getVersionObject(ver);
expect(semver.gte(v.tag_name, latest));
describe('latest range versions', () => {
it.each(["latest", "*", "^0", "0.*.*", "0.6.*"] as const)("should match %s versions", async (ver) => {
const v = await getVersionObject(ver);
expect(semver.gte(v.tag_name, latest));
});
});
});
describe("range versions", () => {
it.each([{spec: "0.4.*", gte: "0.4.0"}, {spec: "v0.4.*", gte: "0.4.0"}, {spec: "0.6.1", eq: '0.6.1'}, {spec: "v0.6.0", eq: "0.6.1"}] as const)("should match %s versions", async (test) => {
const v = await getVersionObject(test.spec);
if (test.gte) expect(semver.gte(v.tag_name, test.gte));
if (test.eq) expect(semver.eq(v.tag_name, test.eq));
describe("range versions", () => {
it.each([
{spec: "0.4.*", gte: "0.4.0", lt: "0.5.0"},
{spec: "v0.4.*", gte: "0.4.0", lt: "0.5.0"},
{spec: "0.6.1", eq: '0.6.1'},
{spec: "v0.6.0", eq: "0.6.0"},
] as const)("should match %s versions", async (test) => {
console.log(JSON.stringify(test));
const v = await getVersionObject(test.spec);
if (test.gte) expect(semver.gte(v.tag_name, test.gte));
if (test.lt) expect(semver.lt(v.tag_name, test.lt));
if (test.eq) expect(semver.eq(v.tag_name, test.eq));
});
});
});
});