diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-06-12 20:23:38 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-12 15:23:38 -0400 |
commit | 1fff6f55c3ba98a10018c6d374795e612061e9b6 (patch) | |
tree | 12074b6d44736b11513d857e437f9e30a6bf65a4 /std/testing/asserts_test.ts | |
parent | 26bf56afdaf16634ffbaa23684faf3a44cc10f62 (diff) |
refactor: Don't destructure the Deno namespace (#6268)
Diffstat (limited to 'std/testing/asserts_test.ts')
-rw-r--r-- | std/testing/asserts_test.ts | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts index feb4d097d..7f2d978ea 100644 --- a/std/testing/asserts_test.ts +++ b/std/testing/asserts_test.ts @@ -1,5 +1,4 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. - import { assert, assertNotEquals, @@ -17,9 +16,8 @@ import { unreachable, } from "./asserts.ts"; import { red, green, gray, bold, yellow } from "../fmt/colors.ts"; -const { test } = Deno; -test("testingEqual", function (): void { +Deno.test("testingEqual", function (): void { assert(equal("world", "world")); assert(!equal("hello", "world")); assert(equal(5, 5)); @@ -116,7 +114,7 @@ test("testingEqual", function (): void { assert(!equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([2, 1, 4, 3]))); }); -test("testingNotEquals", function (): void { +Deno.test("testingNotEquals", function (): void { const a = { foo: "bar" }; const b = { bar: "foo" }; assertNotEquals(a, b); @@ -132,7 +130,7 @@ test("testingNotEquals", function (): void { assertEquals(didThrow, true); }); -test("testingAssertStringContains", function (): void { +Deno.test("testingAssertStringContains", function (): void { assertStringContains("Denosaurus", "saur"); assertStringContains("Denosaurus", "Deno"); assertStringContains("Denosaurus", "rus"); @@ -147,7 +145,7 @@ test("testingAssertStringContains", function (): void { assertEquals(didThrow, true); }); -test("testingArrayContains", function (): void { +Deno.test("testingArrayContains", function (): void { const fixture = ["deno", "iz", "luv"]; const fixtureObject = [{ deno: "luv" }, { deno: "Js" }]; assertArrayContains(fixture, ["deno"]); @@ -159,7 +157,7 @@ test("testingArrayContains", function (): void { ); }); -test("testingAssertStringContainsThrow", function (): void { +Deno.test("testingAssertStringContainsThrow", function (): void { let didThrow = false; try { assertStringContains("Denosaurus from Jurassic", "Raptor"); @@ -174,11 +172,11 @@ test("testingAssertStringContainsThrow", function (): void { assert(didThrow); }); -test("testingAssertStringMatching", function (): void { +Deno.test("testingAssertStringMatching", function (): void { assertMatch("foobar@deno.com", RegExp(/[a-zA-Z]+@[a-zA-Z]+.com/)); }); -test("testingAssertStringMatchingThrows", function (): void { +Deno.test("testingAssertStringMatchingThrows", function (): void { let didThrow = false; try { assertMatch("Denosaurus from Jurassic", RegExp(/Raptor/)); @@ -193,7 +191,7 @@ test("testingAssertStringMatchingThrows", function (): void { assert(didThrow); }); -test("testingAssertsUnimplemented", function (): void { +Deno.test("testingAssertsUnimplemented", function (): void { let didThrow = false; try { unimplemented(); @@ -205,7 +203,7 @@ test("testingAssertsUnimplemented", function (): void { assert(didThrow); }); -test("testingAssertsUnreachable", function (): void { +Deno.test("testingAssertsUnreachable", function (): void { let didThrow = false; try { unreachable(); @@ -217,7 +215,7 @@ test("testingAssertsUnreachable", function (): void { assert(didThrow); }); -test("testingAssertFail", function (): void { +Deno.test("testingAssertFail", function (): void { assertThrows(fail, AssertionError, "Failed assertion."); assertThrows( (): void => { @@ -228,7 +226,7 @@ test("testingAssertFail", function (): void { ); }); -test("testingAssertFailWithWrongErrorClass", function (): void { +Deno.test("testingAssertFailWithWrongErrorClass", function (): void { assertThrows( (): void => { //This next assertThrows will throw an AssertionError due to the wrong @@ -246,14 +244,14 @@ test("testingAssertFailWithWrongErrorClass", function (): void { ); }); -test("testingAssertThrowsWithReturnType", () => { +Deno.test("testingAssertThrowsWithReturnType", () => { assertThrows(() => { throw new Error(); return "a string"; }); }); -test("testingAssertThrowsAsyncWithReturnType", () => { +Deno.test("testingAssertThrowsAsyncWithReturnType", () => { assertThrowsAsync(() => { throw new Error(); return Promise.resolve("a Promise<string>"); @@ -273,7 +271,7 @@ const createHeader = (): string[] => [ const added: (s: string) => string = (s: string): string => green(bold(s)); const removed: (s: string) => string = (s: string): string => red(bold(s)); -test({ +Deno.test({ name: "pass case", fn(): void { assertEquals({ a: 10 }, { a: 10 }); @@ -284,7 +282,7 @@ test({ }, }); -test({ +Deno.test({ name: "failed with number", fn(): void { assertThrows( @@ -301,7 +299,7 @@ test({ }, }); -test({ +Deno.test({ name: "failed with number vs string", fn(): void { assertThrows( @@ -317,7 +315,7 @@ test({ }, }); -test({ +Deno.test({ name: "failed with array", fn(): void { assertThrows( @@ -334,7 +332,7 @@ test({ }, }); -test({ +Deno.test({ name: "failed with object", fn(): void { assertThrows( @@ -355,7 +353,7 @@ test({ }, }); -test({ +Deno.test({ name: "strict pass case", fn(): void { assertStrictEquals(true, true); @@ -372,7 +370,7 @@ test({ }, }); -test({ +Deno.test({ name: "strict failed with structure diff", fn(): void { assertThrows( @@ -389,7 +387,7 @@ test({ }, }); -test({ +Deno.test({ name: "strict failed with reference diff", fn(): void { assertThrows( |