deno.land / std@0.166.0 / semver / semver_test.ts

semver_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright Isaac Z. Schlueter and Contributors. All rights reserved. ISC license.// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.import { assertEquals, assertThrows } from "../testing/asserts.ts";import * as semver from "./mod.ts";
Deno.test("invalidVersion", function () { const versions = ["1.2.3.4", "NOT VALID", 1.2, null, "Infinity.NaN.Infinity"];
versions.forEach(function (v) { assertThrows( function () { new semver.SemVer(v as string); }, TypeError, `Invalid Version: ${v}`, ); });});
Deno.test("maxSatisfying", function () { const versions: [string[], string, string][] = [ [["1.2.3", "1.2.4"], "1.2", "1.2.4"], [["1.2.4", "1.2.3"], "1.2", "1.2.4"], [["1.2.3", "1.2.4", "1.2.5", "1.2.6"], "~1.2.3", "1.2.6"], ];
versions.forEach(function (v) { const versions = v[0]; const range = v[1]; const expect = v[2]; const actual = semver.maxSatisfying(versions, range); assertEquals(actual, expect); });});
Deno.test("minSatisfying", function () { 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"], ];
versions.forEach(function (v) { const versions = v[0]; const range = v[1]; const expect = v[2]; const actual = semver.minSatisfying(versions, range); assertEquals(actual, expect); });});
Deno.test("sorting", function () { const list = ["1.2.3+1", "1.2.3+0", "1.2.3", "5.9.6", "0.1.2"]; const sorted = ["0.1.2", "1.2.3", "1.2.3+0", "1.2.3+1", "5.9.6"]; const rsorted = ["5.9.6", "1.2.3+1", "1.2.3+0", "1.2.3", "0.1.2"]; assertEquals(semver.sort(list), sorted); assertEquals(semver.rsort(list), rsorted);});
Deno.test("badRangesInMaxOrMinSatisfying", function () { const r = "some frogs and sneks-v2.5.6"; assertEquals(semver.maxSatisfying([], r), null); assertEquals(semver.minSatisfying([], r), null);});
Deno.test("bigNumericPrerelease", function () { const r = new semver.SemVer("1.2.3-beta." + Number.MAX_SAFE_INTEGER + "0"); assertEquals(r.prerelease, ["beta", "90071992547409910"]);});
std
Deno standard library
GitHub Repositorydenoland/deno_std
GitHub Stars
2458

Version Info

Tagged at
2 months ago