From f6fa65938437385a4ec00ec090f797381f6638b7 Mon Sep 17 00:00:00 2001 From: Joel Chippindale Date: Sat, 13 Jun 2020 15:01:05 +0100 Subject: Fix assertEqual so that it handles URL objects (#6278) --- std/testing/asserts.ts | 3 ++- std/testing/asserts_test.ts | 9 +++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'std') diff --git a/std/testing/asserts.ts b/std/testing/asserts.ts index 5e1b8af69..50a9c59ce 100644 --- a/std/testing/asserts.ts +++ b/std/testing/asserts.ts @@ -82,7 +82,8 @@ export function equal(c: unknown, d: unknown): boolean { a && b && ((a instanceof RegExp && b instanceof RegExp) || - (a instanceof Date && b instanceof Date)) + (a instanceof Date && b instanceof Date) || + (a instanceof URL && b instanceof URL)) ) { return String(a) === String(b); } diff --git a/std/testing/asserts_test.ts b/std/testing/asserts_test.ts index 7f2d978ea..36d054356 100644 --- a/std/testing/asserts_test.ts +++ b/std/testing/asserts_test.ts @@ -112,6 +112,15 @@ Deno.test("testingEqual", function (): void { assert(!equal([1, 2, 3, 4], [1, 4, 2, 3])); assert(equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([1, 2, 3, 4]))); assert(!equal(new Uint8Array([1, 2, 3, 4]), new Uint8Array([2, 1, 4, 3]))); + assert( + equal(new URL("https://example.test"), new URL("https://example.test")) + ); + assert( + !equal( + new URL("https://example.test"), + new URL("https://example.test/with-path") + ) + ); }); Deno.test("testingNotEquals", function (): void { -- cgit v1.2.3