summaryrefslogtreecommitdiff
path: root/std/testing/asserts_test.ts
diff options
context:
space:
mode:
authorxcatliu <xcatliu@gmail.com>2020-08-27 17:03:15 +0800
committerGitHub <noreply@github.com>2020-08-27 11:03:15 +0200
commit6b95b25000a713cb86cdb5ddceb5aa46c819962e (patch)
treea17ceb6bf752a801b86577d290ca375b36d96d0c /std/testing/asserts_test.ts
parente1564f385c770ac37c550f7d9e164d6a846c191e (diff)
feat(std/testing): add assertNotMatch (#6775)
Diffstat (limited to 'std/testing/asserts_test.ts')
-rw-r--r--std/testing/asserts_test.ts20
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 {