summaryrefslogtreecommitdiff
path: root/js/url_search_params_test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'js/url_search_params_test.ts')
-rw-r--r--js/url_search_params_test.ts38
1 files changed, 38 insertions, 0 deletions
diff --git a/js/url_search_params_test.ts b/js/url_search_params_test.ts
index 802ab288b..0637bf0d8 100644
--- a/js/url_search_params_test.ts
+++ b/js/url_search_params_test.ts
@@ -138,3 +138,41 @@ test(function urlSearchParamsShouldThrowTypeError() {
assertEqual(hasThrown, 2);
});
+
+test(function urlSearchParamsAppendArgumentsCheck() {
+ const methodRequireOneParam = ["delete", "getAll", "get", "has", "forEach"];
+
+ const methodRequireTwoParams = ["append", "set"];
+
+ methodRequireOneParam.concat(methodRequireTwoParams).forEach(method => {
+ const searchParams = new URLSearchParams();
+ let hasThrown = 0;
+ try {
+ searchParams[method]();
+ hasThrown = 1;
+ } catch (err) {
+ if (err instanceof TypeError) {
+ hasThrown = 2;
+ } else {
+ hasThrown = 3;
+ }
+ }
+ assertEqual(hasThrown, 2);
+ });
+
+ methodRequireTwoParams.forEach(method => {
+ const searchParams = new URLSearchParams();
+ let hasThrown = 0;
+ try {
+ searchParams[method]("foo");
+ hasThrown = 1;
+ } catch (err) {
+ if (err instanceof TypeError) {
+ hasThrown = 2;
+ } else {
+ hasThrown = 3;
+ }
+ }
+ assertEqual(hasThrown, 2);
+ });
+});