summaryrefslogtreecommitdiff
path: root/std/testing/asserts_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'std/testing/asserts_test.ts')
-rw-r--r--std/testing/asserts_test.ts29
1 files changed, 29 insertions, 0 deletions
diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts
index d357a761b..4f153e78c 100644
--- a/std/testing/asserts_test.ts
+++ b/std/testing/asserts_test.ts
@@ -4,6 +4,7 @@ import {
assert,
assertArrayIncludes,
assertEquals,
+ assertExists,
AssertionError,
assertMatch,
assertNotEquals,
@@ -160,6 +161,34 @@ Deno.test("testingNotEquals", function (): void {
assertEquals(didThrow, true);
});
+Deno.test("testingAssertExists", function (): void {
+ assertExists("Denosaurus");
+ assertExists(false);
+ assertExists(0);
+ assertExists("");
+ assertExists(-0);
+ assertExists(0);
+ assertExists(NaN);
+ let didThrow;
+ try {
+ assertExists(undefined);
+ didThrow = false;
+ } catch (e) {
+ assert(e instanceof AssertionError);
+ didThrow = true;
+ }
+ assertEquals(didThrow, true);
+ didThrow = false;
+ try {
+ assertExists(null);
+ didThrow = false;
+ } catch (e) {
+ assert(e instanceof AssertionError);
+ didThrow = true;
+ }
+ assertEquals(didThrow, true);
+});
+
Deno.test("testingAssertStringContains", function (): void {
assertStringIncludes("Denosaurus", "saur");
assertStringIncludes("Denosaurus", "Deno");