deno.land / std@0.224.0 / semver / is_semver_test.ts

is_semver_test.ts
View Documentation
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
71
72
73
74
75
76
77
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { assert } from "../assert/mod.ts";import { MAX, MIN } from "./constants.ts";import { isSemVer } from "./is_semver.ts";
Deno.test({ name: "isSemVer() handles invalid input", fn: async (t) => { const versions: [unknown][] = [ [null], [undefined], [{}], [[]], [true], [false], [0], ["1.2.3"], [{ major: 0, minor: 0, build: [], prerelease: [] }], [{ major: 0, patch: 0, build: [], prerelease: [] }], [{ minor: 0, patch: 0, build: [], prerelease: [] }], [{ major: "", minor: 0, patch: 0, build: [], prerelease: [] }], [{ major: 0, minor: "", patch: 0, build: [], prerelease: [] }], [{ major: 0, minor: 0, patch: "", build: [], prerelease: [] }], [{ major: 0, minor: 0, patch: 0, build: {}, prerelease: [] }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: {} }], [{ major: 0, minor: 0, patch: 0, build: [{}], prerelease: [] }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: [{}] }], [{ major: 0, minor: 0, patch: 0, build: [""], prerelease: [] }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: [""] }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: [-1] }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: [Number.NaN] }], ]; for (const [v] of versions) { await t.step(`${Deno.inspect(v)}`, () => { const actual = isSemVer(v); assert(!actual); }); } },});
Deno.test({ name: "isSemVer()", fn: async (t) => { const versions: [unknown][] = [ [{ major: 0, minor: 0, patch: 0 }], [{ major: 0, minor: 0, patch: 0, prerelease: [] }], [{ major: 0, minor: 0, patch: 0, build: [] }], [{ major: 0, minor: 0, patch: 0, prerelease: undefined }], [{ major: 0, minor: 0, patch: 0, build: undefined }], [{ major: 0, minor: 0, patch: 0, prerelease: undefined, build: undefined, }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: [] }], [{ extra: 1, major: 0, minor: 0, patch: 0, build: [], prerelease: [] }], [{ major: 0, minor: 0, patch: 0, build: ["abc"], prerelease: [] }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: ["abc"] }], [{ major: 0, minor: 0, patch: 0, build: [], prerelease: ["abc", 0] }], [MIN], [MAX], ]; for (const [v] of versions) { await t.step( `${Deno.inspect(v)}`, () => { const actual = isSemVer(v); assert(actual); }, ); } },});
std

Version Info

Tagged at
6 months ago