diff options
author | Bert Belder <bertbelder@gmail.com> | 2021-03-02 19:09:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-02 19:09:58 +0100 |
commit | 1f47bdd69d4c07c2d183cdaf8d86dcf5ecf4b662 (patch) | |
tree | e0f461055b2302fb57ca8954f4771864650c4969 | |
parent | 79c198f3488a4faaab2076aec751e29f4363001a (diff) |
test(op_crates/web): add regression tests for past URL bugs (#9639) (#9639)
Closes: #9383
-rw-r--r-- | cli/tests/unit/url_test.ts | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/cli/tests/unit/url_test.ts b/cli/tests/unit/url_test.ts index e32cab72a..8d280ccb5 100644 --- a/cli/tests/unit/url_test.ts +++ b/cli/tests/unit/url_test.ts @@ -1,5 +1,11 @@ // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -import { assert, assertEquals, assertThrows, unitTest } from "./test_util.ts"; +import { + assert, + assertEquals, + assertStrictEquals, + assertThrows, + unitTest, +} from "./test_util.ts"; unitTest(function urlParsing(): void { const url = new URL( @@ -470,3 +476,22 @@ unitTest(function emptyPortForSchemeDefaultPort(): void { url2.protocol = "http"; assertEquals(url2.port, ""); }); + +unitTest(function assigningPortPropertyAffectsReceiverOnly() { + // Setting `.port` should update only the receiver. + const u1 = new URL("http://google.com/"); + // deno-lint-ignore no-explicit-any + const u2 = new URL(u1 as any); + u2.port = "123"; + assertStrictEquals(u1.port, ""); + assertStrictEquals(u2.port, "123"); +}); + +unitTest(function urlSearchParamsIdentityPreserved() { + // URLSearchParams identity should not be lost when URL is updated. + const u = new URL("http://foo.com/"); + const sp1 = u.searchParams; + u.href = "http://bar.com/?baz=42"; + const sp2 = u.searchParams; + assertStrictEquals(sp1, sp2); +}); |