diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2019-03-06 20:48:46 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-06 20:48:46 -0500 |
commit | c42a9d737081fb8ee768c7178dae0e1f19c0f343 (patch) | |
tree | 9ffb7e502da62793ea099c34bd7b29c8a7a19b19 /js/url_test.ts | |
parent | de1a10e5f7afe793a66b2349642ea135fc066104 (diff) |
Upgrade deno_std (#1892)
A major API change was that asserts are imported from testing/asserts.ts
now rather than testing/mod.ts and assertEqual as renamed to
assertEquals to conform to what is most common in JavaScript.
Diffstat (limited to 'js/url_test.ts')
-rw-r--r-- | js/url_test.ts | 100 |
1 files changed, 56 insertions, 44 deletions
diff --git a/js/url_test.ts b/js/url_test.ts index d001b8306..643490e45 100644 --- a/js/url_test.ts +++ b/js/url_test.ts @@ -1,31 +1,31 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { test, assert, assertEqual } from "./test_util.ts"; +import { test, assert, assertEquals } from "./test_util.ts"; test(function urlParsing() { const url = new URL( "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" ); - assertEqual(url.hash, "#qat"); - assertEqual(url.host, "baz.qat:8000"); - assertEqual(url.hostname, "baz.qat"); - assertEqual( + assertEquals(url.hash, "#qat"); + assertEquals(url.host, "baz.qat:8000"); + assertEquals(url.hostname, "baz.qat"); + assertEquals( url.href, "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" ); - assertEqual(url.origin, "https://baz.qat:8000"); - assertEqual(url.password, "bar"); - assertEqual(url.pathname, "/qux/quux"); - assertEqual(url.port, "8000"); - assertEqual(url.protocol, "https:"); - assertEqual(url.search, "?foo=bar&baz=12"); - assertEqual(url.searchParams.getAll("foo"), ["bar"]); - assertEqual(url.searchParams.getAll("baz"), ["12"]); - assertEqual(url.username, "foo"); - assertEqual( + assertEquals(url.origin, "https://baz.qat:8000"); + assertEquals(url.password, "bar"); + assertEquals(url.pathname, "/qux/quux"); + assertEquals(url.port, "8000"); + assertEquals(url.protocol, "https:"); + assertEquals(url.search, "?foo=bar&baz=12"); + assertEquals(url.searchParams.getAll("foo"), ["bar"]); + assertEquals(url.searchParams.getAll("baz"), ["12"]); + assertEquals(url.username, "foo"); + assertEquals( String(url), "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" ); - assertEqual( + assertEquals( JSON.stringify({ key: url }), `{"key":"https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat"}` ); @@ -36,39 +36,51 @@ test(function urlModifications() { "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" ); url.hash = ""; - assertEqual(url.href, "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12"); + assertEquals( + url.href, + "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12" + ); url.host = "qat.baz:8080"; - assertEqual(url.href, "https://foo:bar@qat.baz:8080/qux/quux?foo=bar&baz=12"); + assertEquals( + url.href, + "https://foo:bar@qat.baz:8080/qux/quux?foo=bar&baz=12" + ); url.hostname = "foo.bar"; - assertEqual(url.href, "https://foo:bar@foo.bar:8080/qux/quux?foo=bar&baz=12"); + assertEquals( + url.href, + "https://foo:bar@foo.bar:8080/qux/quux?foo=bar&baz=12" + ); url.password = "qux"; - assertEqual(url.href, "https://foo:qux@foo.bar:8080/qux/quux?foo=bar&baz=12"); + assertEquals( + url.href, + "https://foo:qux@foo.bar:8080/qux/quux?foo=bar&baz=12" + ); url.pathname = "/foo/bar%qat"; - assertEqual( + assertEquals( url.href, "https://foo:qux@foo.bar:8080/foo/bar%qat?foo=bar&baz=12" ); url.port = ""; - assertEqual(url.href, "https://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12"); + assertEquals(url.href, "https://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12"); url.protocol = "http:"; - assertEqual(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12"); + assertEquals(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&baz=12"); url.search = "?foo=bar&foo=baz"; - assertEqual(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz"); - assertEqual(url.searchParams.getAll("foo"), ["bar", "baz"]); + assertEquals(url.href, "http://foo:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz"); + assertEquals(url.searchParams.getAll("foo"), ["bar", "baz"]); url.username = "foo@bar"; - assertEqual( + assertEquals( url.href, "http://foo%40bar:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz" ); url.searchParams.set("bar", "qat"); - assertEqual( + assertEquals( url.href, "http://foo%40bar:qux@foo.bar/foo/bar%qat?foo=bar&foo=baz&bar=qat" ); url.searchParams.delete("foo"); - assertEqual(url.href, "http://foo%40bar:qux@foo.bar/foo/bar%qat?bar=qat"); + assertEquals(url.href, "http://foo%40bar:qux@foo.bar/foo/bar%qat?bar=qat"); url.searchParams.append("foo", "bar"); - assertEqual( + assertEquals( url.href, "http://foo%40bar:qux@foo.bar/foo/bar%qat?bar=qat&foo=bar" ); @@ -77,32 +89,32 @@ test(function urlModifications() { test(function urlModifyHref() { const url = new URL("http://example.com/"); url.href = "https://foo:bar@example.com:8080/baz/qat#qux"; - assertEqual(url.protocol, "https:"); - assertEqual(url.username, "foo"); - assertEqual(url.password, "bar"); - assertEqual(url.host, "example.com:8080"); - assertEqual(url.hostname, "example.com"); - assertEqual(url.pathname, "/baz/qat"); - assertEqual(url.hash, "#qux"); + assertEquals(url.protocol, "https:"); + assertEquals(url.username, "foo"); + assertEquals(url.password, "bar"); + assertEquals(url.host, "example.com:8080"); + assertEquals(url.hostname, "example.com"); + assertEquals(url.pathname, "/baz/qat"); + assertEquals(url.hash, "#qux"); }); test(function urlModifyPathname() { const url = new URL("http://foo.bar/baz%qat/qux%quux"); - assertEqual(url.pathname, "/baz%qat/qux%quux"); + assertEquals(url.pathname, "/baz%qat/qux%quux"); url.pathname = url.pathname; - assertEqual(url.pathname, "/baz%qat/qux%quux"); + assertEquals(url.pathname, "/baz%qat/qux%quux"); url.pathname = "baz#qat qux"; - assertEqual(url.pathname, "/baz%23qat%20qux"); + assertEquals(url.pathname, "/baz%23qat%20qux"); url.pathname = url.pathname; - assertEqual(url.pathname, "/baz%23qat%20qux"); + assertEquals(url.pathname, "/baz%23qat%20qux"); }); test(function urlModifyHash() { const url = new URL("http://foo.bar"); url.hash = "%foo bar/qat%qux#bar"; - assertEqual(url.hash, "#%foo%20bar/qat%qux#bar"); + assertEquals(url.hash, "#%foo%20bar/qat%qux#bar"); url.hash = url.hash; - assertEqual(url.hash, "#%foo%20bar/qat%qux#bar"); + assertEquals(url.hash, "#%foo%20bar/qat%qux#bar"); }); test(function urlSearchParamsReuse() { @@ -119,7 +131,7 @@ test(function urlBaseURL() { "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" ); const url = new URL("/foo/bar?baz=foo#qux", base); - assertEqual(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux"); + assertEquals(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux"); }); test(function urlBaseString() { @@ -127,5 +139,5 @@ test(function urlBaseString() { "/foo/bar?baz=foo#qux", "https://foo:bar@baz.qat:8000/qux/quux?foo=bar&baz=12#qat" ); - assertEqual(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux"); + assertEquals(url.href, "https://foo:bar@baz.qat:8000/foo/bar?baz=foo#qux"); }); |