mirror of
https://github.com/denoland/std.git
synced 2024-11-21 20:50:22 +00:00
b649680328
* test(assert): improve test coverage * chore: format * chore: lint * nits --------- Co-authored-by: Asher Gomez <ashersaupingomez@gmail.com>
29 lines
843 B
TypeScript
29 lines
843 B
TypeScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
import { assertThrows } from "./assert_throws.ts";
|
|
import { AssertionError, assertMatch } from "./mod.ts";
|
|
|
|
Deno.test("assertMatch()", () => {
|
|
assertMatch("foobar@deno.com", RegExp(/[a-zA-Z]+@[a-zA-Z]+.com/));
|
|
});
|
|
|
|
Deno.test("assertMatch() throws", () => {
|
|
assertThrows(
|
|
() => assertMatch("Denosaurus from Jurassic", RegExp(/Raptor/)),
|
|
AssertionError,
|
|
`Expected actual: "Denosaurus from Jurassic" to match: "/Raptor/".`,
|
|
);
|
|
});
|
|
|
|
Deno.test("assertMatch() throws with custom message", () => {
|
|
assertThrows(
|
|
() =>
|
|
assertMatch(
|
|
"Denosaurus from Jurassic",
|
|
RegExp(/Raptor/),
|
|
"CUSTOM MESSAGE",
|
|
),
|
|
AssertionError,
|
|
`Expected actual: "Denosaurus from Jurassic" to match: "/Raptor/": CUSTOM MESSAGE`,
|
|
);
|
|
});
|