deno.land / std@0.224.0 / semver / format_test.ts
123456789101112131415161718192021222324252627282930313233343536373839404142434445// 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); }, }); }});
Version Info