diff options
author | xcatliu <xcatliu@gmail.com> | 2020-08-27 17:03:15 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-08-27 11:03:15 +0200 |
commit | 6b95b25000a713cb86cdb5ddceb5aa46c819962e (patch) | |
tree | a17ceb6bf752a801b86577d290ca375b36d96d0c /std/testing/asserts_test.ts | |
parent | e1564f385c770ac37c550f7d9e164d6a846c191e (diff) |
feat(std/testing): add assertNotMatch (#6775)
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 { |