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

format_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
// Copyright Isaac Z. Schlueter and Contributors. All rights reserved. ISC license.// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.import { assertEquals } from "../assert/mod.ts";import { format } from "./format.ts";import { parse } from "./parse.ts";import { INVALID, MAX, MIN } from "./constants.ts";import type { SemVer } from "./types.ts";
Deno.test("format()", async (t) => { const versions: [string, string][] = [ ["1.2.3", "1.2.3"], ["1.2.3-pre", "1.2.3-pre"], ["1.2.3-pre.0", "1.2.3-pre.0"], ["1.2.3+b", "1.2.3+b"], ["1.2.3+b.0", "1.2.3+b.0"], ["1.2.3-pre.0+b.0", "1.2.3-pre.0+b.0"], ];
for (const [version, expected] of versions) { await t.step({ name: version, fn: () => { const v = parse(version)!; const actual = format(v); assertEquals(actual, expected); }, }); }
const constantSemVers: [SemVer, string][] = [ [MAX, "∞.∞.∞"], [MIN, "0.0.0"], [INVALID, "⧞.∞.∞"], ]; for (const [version, expected] of constantSemVers) { await t.step({ name: format(version), fn: () => { const actual = format(version); assertEquals(actual, expected); }, }); }});
std

Version Info

Tagged at
3 weeks ago