summaryrefslogtreecommitdiff
path: root/testing/asserts_test.ts
diff options
context:
space:
mode:
authorVincent LE GOFF <g_n_s@hotmail.fr>2019-03-05 20:58:28 +0100
committerRyan Dahl <ry@tinyclouds.org>2019-03-05 14:58:28 -0500
commit787207f11bfcd657b93b47f2ffeb457cdd6f4eb0 (patch)
treeac71143a059261805d4c5750a7254583714397d7 /testing/asserts_test.ts
parent39fde3a454b6bcc7daa6bca4fb7f4317550e9e58 (diff)
Refactor asserts in testing (denoland/deno_std#227)
Original: https://github.com/denoland/deno_std/commit/c734e3234322cea5298a887373fe4ad1591d7c97
Diffstat (limited to 'testing/asserts_test.ts')
-rw-r--r--testing/asserts_test.ts46
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/asserts_test.ts b/testing/asserts_test.ts
new file mode 100644
index 000000000..f4256d8f5
--- /dev/null
+++ b/testing/asserts_test.ts
@@ -0,0 +1,46 @@
+// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
+
+import { assertStrContains, assertMatch } from "./asserts.ts";
+import { test, assert } from "./mod.ts";
+// import { assertEqual as prettyAssertEqual } from "./pretty.ts";
+// import "./format_test.ts";
+// import "./diff_test.ts";
+// import "./pretty_test.ts";
+
+test(function testingAssertStringContains() {
+ assertStrContains("Denosaurus", "saur");
+ assertStrContains("Denosaurus", "Deno");
+ assertStrContains("Denosaurus", "rus");
+});
+
+test(function testingAssertStringContainsThrow() {
+ let didThrow = false;
+ try {
+ assertStrContains("Denosaurus from Jurassic", "Raptor");
+ } catch (e) {
+ assert(
+ e.message ===
+ `actual: "Denosaurus from Jurassic" expected to contains: "Raptor"`
+ );
+ didThrow = true;
+ }
+ assert(didThrow);
+});
+
+test(function testingAssertStringMatching() {
+ assertMatch("foobar@deno.com", RegExp(/[a-zA-Z]+@[a-zA-Z]+.com/));
+});
+
+test(function testingAssertStringMatchingThrows() {
+ let didThrow = false;
+ try {
+ assertMatch("Denosaurus from Jurassic", RegExp(/Raptor/));
+ } catch (e) {
+ assert(
+ e.message ===
+ `actual: "Denosaurus from Jurassic" expected to match: "/Raptor/"`
+ );
+ didThrow = true;
+ }
+ assert(didThrow);
+});