From 5819cfbeec6afeb280015df8f155ed9f325d7645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piyotaro=2C=20Kiiroi=20=28=E3=81=8D=E3=81=84=E3=82=8D?= =?UTF-8?q?=E3=81=84=20=E3=81=B4=E3=82=88=E5=A4=AA=E9=83=8E=29?= <70329111+piyota6@users.noreply.github.com> Date: Tue, 15 Sep 2020 11:47:45 +0900 Subject: docs(std/testing) add a description of assertNotMatch(). (#7470) --- docs/testing/assertions.md | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'docs/testing') diff --git a/docs/testing/assertions.md b/docs/testing/assertions.md index 9016ddf48..4513d5a8d 100644 --- a/docs/testing/assertions.md +++ b/docs/testing/assertions.md @@ -12,7 +12,7 @@ Deno.test("Hello Test", () => { }); ``` -The assertions module provides nine assertions: +The assertions module provides 10 assertions: - `assert(expr: unknown, msg = ""): asserts expr` - `assertEquals(actual: unknown, expected: unknown, msg?: string): void` @@ -21,6 +21,7 @@ The assertions module provides nine assertions: - `assertStringContains(actual: string, expected: string, msg?: string): void` - `assertArrayContains(actual: unknown[], expected: unknown[], msg?: string): void` - `assertMatch(actual: string, expected: RegExp, msg?: string): void` +- `assertNotMatch(actual: string, expected: RegExp, msg?: string): void` - `assertThrows(fn: () => void, ErrorClass?: Constructor, msgIncludes = "", msg?: string): Error` - `assertThrowsAsync(fn: () => Promise, ErrorClass?: Constructor, msgIncludes = "", msg?: string): Promise` @@ -115,7 +116,8 @@ Deno.test("Test Assert Array Contains", () => { ### Regex -You can assert regular expressions via the `assertMatch()` assertion. +You can assert regular expressions via `assertMatch()` and `assertNotMatch()` +assertions. ```js Deno.test("Test Assert Match", () => { @@ -125,6 +127,13 @@ Deno.test("Test Assert Match", () => { assertMatch("https://www.google.com", basicUrl); assertMatch("http://facebook.com", basicUrl); }); + +Deno.test("Test Assert Not Match", () => { + assertNotMatch("abcdefghi", new RegExp("jkl")); + + const basicUrl = new RegExp("^https?://[a-z.]+.com$"); + assertNotMatch("https://deno.land/", basicUrl); +}); ``` ### Throws -- cgit v1.2.3