diff options
Diffstat (limited to 'std/testing/asserts_test.ts')
-rw-r--r-- | std/testing/asserts_test.ts | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts index 13dba756d..1b07cd179 100644 --- a/std/testing/asserts_test.ts +++ b/std/testing/asserts_test.ts @@ -6,6 +6,7 @@ import { assertStringContains, assertArrayContains, assertMatch, + assertNotMatch, assertEquals, assertStrictEquals, assertNotStrictEquals, @@ -232,6 +233,25 @@ Deno.test("testingAssertStringMatchingThrows", function (): void { assert(didThrow); }); +Deno.test("testingAssertStringNotMatching", function (): void { + assertNotMatch("foobar.deno.com", RegExp(/[a-zA-Z]+@[a-zA-Z]+.com/)); +}); + +Deno.test("testingAssertStringNotMatchingThrows", function (): void { + let didThrow = false; + try { + assertNotMatch("Denosaurus from Jurassic", RegExp(/from/)); + } catch (e) { + assert( + e.message === + `actual: "Denosaurus from Jurassic" expected to not match: "/from/"`, + ); + assert(e instanceof AssertionError); + didThrow = true; + } + assert(didThrow); +}); + Deno.test("testingAssertsUnimplemented", function (): void { let didThrow = false; try { |