2024-01-01 21:11:32 +00:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2024-07-02 03:42:40 +00:00
|
|
|
import { assertThrows } from "./throws.ts";
|
2024-05-07 00:08:16 +00:00
|
|
|
import { AssertionError, assertMatch } from "./mod.ts";
|
2023-07-13 07:04:30 +00:00
|
|
|
|
2024-05-07 00:08:16 +00:00
|
|
|
Deno.test("assertMatch()", () => {
|
2023-07-13 07:04:30 +00:00
|
|
|
assertMatch("foobar@deno.com", RegExp(/[a-zA-Z]+@[a-zA-Z]+.com/));
|
|
|
|
});
|
|
|
|
|
2024-05-07 00:08:16 +00:00
|
|
|
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`,
|
|
|
|
);
|
2023-07-13 07:04:30 +00:00
|
|
|
});
|