Skip to content

Commit c472644

Browse files
authored
URLSearchParams: add tests for two-argument delete() and has()
For whatwg/url#735.
1 parent b4670cd commit c472644

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

url/urlsearchparams-delete.any.js

+9
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ test(() => {
6161
assert_equals(url.pathname, 'space ');
6262
assert_equals(url.href, 'data:space #test');
6363
}, 'Changing the query of a URL with an opaque path can impact the path if the URL has no fragment');
64+
65+
test(() => {
66+
const params = new URLSearchParams();
67+
params.append('a', 'b');
68+
params.append('a', 'c');
69+
params.append('a', 'd');
70+
params.delete('a', 'c');
71+
assert_equals(params.toString(), 'a=b&a=d');
72+
}, "Two-argument delete()");

url/urlsearchparams-has.any.js

+13
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,16 @@ test(function() {
2222
params.delete('first');
2323
assert_false(params.has('first'), 'Search params object has no name "first"');
2424
}, 'has() following delete()');
25+
26+
test(() => {
27+
const params = new URLSearchParams("a=b&a=d&c&e&");
28+
assert_true(params.has('a', 'b'));
29+
assert_false(params.has('a', 'c'));
30+
assert_true(params.has('a', 'd'));
31+
assert_true(params.has('e', ''));
32+
params.append('first', null);
33+
assert_false(params.has('first', ''));
34+
assert_true(params.has('first', 'null'));
35+
params.delete('a', 'b');
36+
assert_true(params.has('a', 'd'));
37+
}, "Two-argument has()");

0 commit comments

Comments
 (0)