diff options
author | Yasser A.Idrissi <spookyframework@gmail.com> | 2020-10-26 16:46:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-26 16:46:38 +0100 |
commit | 35caa160bf9b781d20364d77f53fee6e8f9899c3 (patch) | |
tree | 888852814fa920c0423332cb675ccf16980238fb /std/testing/asserts_test.ts | |
parent | ae86cbb551f7b88f83d73a447411f753485e49e2 (diff) |
feat(std/testing): Add assertExists assertion (#7874)
Diffstat (limited to 'std/testing/asserts_test.ts')
-rw-r--r-- | std/testing/asserts_test.ts | 29 |
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"); |