Skip to content

Commit

Permalink
URLSearchParams: add tests for two-argument delete() and has()
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk authored May 5, 2023
1 parent b4670cd commit c472644
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions url/urlsearchparams-delete.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,12 @@ test(() => {
assert_equals(url.pathname, 'space ');
assert_equals(url.href, 'data:space #test');
}, 'Changing the query of a URL with an opaque path can impact the path if the URL has no fragment');

test(() => {
const params = new URLSearchParams();
params.append('a', 'b');
params.append('a', 'c');
params.append('a', 'd');
params.delete('a', 'c');
assert_equals(params.toString(), 'a=b&a=d');
}, "Two-argument delete()");
13 changes: 13 additions & 0 deletions url/urlsearchparams-has.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@ test(function() {
params.delete('first');
assert_false(params.has('first'), 'Search params object has no name "first"');
}, 'has() following delete()');

test(() => {
const params = new URLSearchParams("a=b&a=d&c&e&");
assert_true(params.has('a', 'b'));
assert_false(params.has('a', 'c'));
assert_true(params.has('a', 'd'));
assert_true(params.has('e', ''));
params.append('first', null);
assert_false(params.has('first', ''));
assert_true(params.has('first', 'null'));
params.delete('a', 'b');
assert_true(params.has('a', 'd'));
}, "Two-argument has()");

0 comments on commit c472644

Please sign in to comment.