2022-07-18 11:17:42 +00:00
|
|
|
// Copyright Isaac Z. Schlueter and Contributors. All rights reserved. ISC license.
|
2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-04-29 02:57:30 +00:00
|
|
|
import { assertEquals } from "@std/assert";
|
2023-06-12 03:47:03 +00:00
|
|
|
import { parse } from "./parse.ts";
|
2024-02-27 21:57:25 +00:00
|
|
|
import type { ReleaseType } from "./types.ts";
|
2023-06-12 03:47:03 +00:00
|
|
|
import { difference } from "./difference.ts";
|
2022-07-18 11:17:42 +00:00
|
|
|
|
2024-02-29 04:00:20 +00:00
|
|
|
Deno.test("difference()", async (t) => {
|
2023-06-12 03:47:03 +00:00
|
|
|
const versions: [string, string, ReleaseType | undefined][] = [
|
2022-07-18 11:17:42 +00:00
|
|
|
["1.2.3", "0.2.3", "major"],
|
|
|
|
["1.4.5", "0.2.3", "major"],
|
|
|
|
["1.2.3", "2.0.0-pre", "premajor"],
|
|
|
|
["1.2.3", "1.3.3", "minor"],
|
|
|
|
["1.0.1", "1.1.0-pre", "preminor"],
|
|
|
|
["1.2.3", "1.2.4", "patch"],
|
|
|
|
["1.2.3", "1.2.4-pre", "prepatch"],
|
|
|
|
["0.0.1", "0.0.1-pre", "prerelease"],
|
|
|
|
["0.0.1", "0.0.1-pre-2", "prerelease"],
|
|
|
|
["1.1.0", "1.1.0-pre", "prerelease"],
|
|
|
|
["1.1.0-pre-1", "1.1.0-pre-2", "prerelease"],
|
2023-06-12 03:47:03 +00:00
|
|
|
["1.0.0", "1.0.0", undefined],
|
2022-07-18 11:17:42 +00:00
|
|
|
];
|
|
|
|
|
2023-06-12 03:47:03 +00:00
|
|
|
for (const [v0, v1, expected] of versions) {
|
2024-02-29 04:00:20 +00:00
|
|
|
await t.step(`${v0} ≏ ${v1}`, () => {
|
2023-06-12 03:47:03 +00:00
|
|
|
const s0 = parse(v0);
|
|
|
|
const s1 = parse(v1);
|
|
|
|
const actual = difference(s0, s1);
|
|
|
|
assertEquals(actual, expected);
|
|
|
|
});
|
|
|
|
}
|
2022-07-18 11:17:42 +00:00
|
|
|
});
|