2023-06-12 03:47:03 +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";
|
|
|
|
import { parseRange } from "./parse_range.ts";
|
|
|
|
import { minSatisfying } from "./min_satisfying.ts";
|
|
|
|
|
2024-02-29 04:00:20 +00:00
|
|
|
Deno.test("minSatisfying()", async (t) => {
|
2023-06-12 03:47:03 +00:00
|
|
|
const versions: [string[], string, string][] = [
|
|
|
|
[["1.2.3", "1.2.4"], "1.2", "1.2.3"],
|
|
|
|
[["1.2.4", "1.2.3"], "1.2", "1.2.3"],
|
|
|
|
[["1.2.3", "1.2.4", "1.2.5", "1.2.6"], "~1.2.3", "1.2.3"],
|
|
|
|
];
|
|
|
|
|
|
|
|
for (const [v, r, e] of versions) {
|
2024-02-29 04:00:20 +00:00
|
|
|
await t.step(r, () => {
|
2023-06-12 03:47:03 +00:00
|
|
|
const s = v.map((v) => parse(v));
|
|
|
|
const range = parseRange(r);
|
|
|
|
const expected = parse(e);
|
|
|
|
const actual = minSatisfying(s, range);
|
|
|
|
assertEquals(actual, expected);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|