mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
test(uuid): add tests for invalid namespace UUID (#4875)
This commit is contained in:
parent
a0b0f4c553
commit
fc3d376447
@ -1,5 +1,10 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert, assertEquals } from "@std/assert";
|
||||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
AssertionError,
|
||||
assertRejects,
|
||||
} from "@std/assert";
|
||||
import { generate, validate } from "./v3.ts";
|
||||
|
||||
const NAMESPACE = "1b671a64-40d5-491e-99b0-da01ff1f3341";
|
||||
@ -37,3 +42,11 @@ Deno.test("validate() checks if a string is a valid v3 UUID", async () => {
|
||||
assert(validate(t), `${t} should be valid`);
|
||||
assert(!validate(n), `${n} should not be valid`);
|
||||
});
|
||||
|
||||
Deno.test("generate() throws on invalid namespace", async () => {
|
||||
await assertRejects(
|
||||
async () => await generate("invalid-uuid", new Uint8Array()),
|
||||
AssertionError,
|
||||
"namespace must be a valid UUID",
|
||||
);
|
||||
});
|
||||
|
@ -1,5 +1,10 @@
|
||||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
import { assert, assertEquals } from "@std/assert";
|
||||
import {
|
||||
assert,
|
||||
assertEquals,
|
||||
AssertionError,
|
||||
assertRejects,
|
||||
} from "@std/assert";
|
||||
import { generate, validate } from "./v5.ts";
|
||||
|
||||
const NAMESPACE = "1b671a64-40d5-491e-99b0-da01ff1f3341";
|
||||
@ -37,3 +42,11 @@ Deno.test("validate() checks if a string is a valid v5 UUID", async () => {
|
||||
assert(validate(t), `${t} should be valid`);
|
||||
assert(!validate(n), `${n} should not be valid`);
|
||||
});
|
||||
|
||||
Deno.test("generate() throws on invalid namespace", async () => {
|
||||
await assertRejects(
|
||||
async () => await generate("invalid-uuid", new Uint8Array()),
|
||||
AssertionError,
|
||||
"namespace must be a valid UUID",
|
||||
);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user