| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c329843 commit fcd08b8
11 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -46,3 +46,10 @@ assert.strictEqual(params.get('third'), '', | |||
| 46 | 46 | params.append('first', 10); | |
| 47 | 47 | assert.strictEqual(params.get('first'), '1', | |
| 48 | 48 | 'Search params object has name "first" with value "1"'); | |
| 49 | + | ||
| 50 | + assert.throws(() => { | ||
| 51 | + params.append.call(undefined); | ||
| 52 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| 53 | + assert.throws(() => { | ||
| 54 | + params.set('a'); | ||
| 55 | + }, /^TypeError: "name" and "value" arguments must be specified$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -41,6 +41,13 @@ params.delete('first'); | |||
| 41 | 41 | assert.strictEqual(false, params.has('first'), | |
| 42 | 42 | 'Search params object has no "first" name'); | |
| 43 | 43 | ||
| 44 | + assert.throws(() => { | ||
| 45 | + params.delete.call(undefined); | ||
| 46 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| 47 | + assert.throws(() => { | ||
| 48 | + params.delete(); | ||
| 49 | + }, /^TypeError: "name" argument must be specified$/); | ||
| 50 | + | ||
| 44 | 51 | // https://github.com/nodejs/node/issues/10480 | |
| 45 | 52 | // Emptying searchParams should correctly update url's query | |
| 46 | 53 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,33 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const URLSearchParams = require('url').URLSearchParams; | ||
| 6 | + | ||
| 7 | + const params = new URLSearchParams('a=b&c=d'); | ||
| 8 | + const entries = params.entries(); | ||
| 9 | + assert.strictEqual(typeof entries[Symbol.iterator], 'function'); | ||
| 10 | + assert.strictEqual(entries[Symbol.iterator](), entries); | ||
| 11 | + assert.deepStrictEqual(entries.next(), { | ||
| 12 | + value: ['a', 'b'], | ||
| 13 | + done: false | ||
| 14 | + }); | ||
| 15 | + assert.deepStrictEqual(entries.next(), { | ||
| 16 | + value: ['c', 'd'], | ||
| 17 | + done: false | ||
| 18 | + }); | ||
| 19 | + assert.deepStrictEqual(entries.next(), { | ||
| 20 | + value: undefined, | ||
| 21 | + done: true | ||
| 22 | + }); | ||
| 23 | + assert.deepStrictEqual(entries.next(), { | ||
| 24 | + value: undefined, | ||
| 25 | + done: true | ||
| 26 | + }); | ||
| 27 | + | ||
| 28 | + assert.throws(() => { | ||
| 29 | + entries.next.call(undefined); | ||
| 30 | + }, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); | ||
| 31 | + assert.throws(() => { | ||
| 32 | + params.entries.call(undefined); | ||
| 33 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,7 +12,7 @@ let a, b, i; | |||
| 12 | 12 | const params = new URLSearchParams('a=1&b=2&c=3'); | |
| 13 | 13 | const keys = []; | |
| 14 | 14 | const values = []; | |
| 15 | - params.forEach(function(value, key) { | ||
| 15 | + params.forEach((value, key) => { | ||
| 16 | 16 | keys.push(key); | |
| 17 | 17 | values.push(value); | |
| 18 | 18 | }); | |
@@ -37,3 +37,7 @@ b = a.searchParams; | |||
| 37 | 37 | for (i of b) { | |
| 38 | 38 | common.fail('should not be reached'); | |
| 39 | 39 | } | |
| 40 | + | ||
| 41 | + assert.throws(() => { | ||
| 42 | + params.forEach.call(undefined); | ||
| 43 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,3 +29,10 @@ assert.strictEqual(params.get('third'), '', | |||
| 29 | 29 | 'Search params object has name "third" with empty value.'); | |
| 30 | 30 | assert.strictEqual(params.get('fourth'), null, | |
| 31 | 31 | 'Search params object has no "fourth" name and value.'); | |
| 32 | + | ||
| 33 | + assert.throws(() => { | ||
| 34 | + params.get.call(undefined); | ||
| 35 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| 36 | + assert.throws(() => { | ||
| 37 | + params.get(); | ||
| 38 | + }, /^TypeError: "name" argument must be specified$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -36,3 +36,10 @@ assert(matches && matches.length == 1, | |||
| 36 | 36 | 'Search params object has values for name "a"'); | |
| 37 | 37 | assert.deepStrictEqual(matches, ['one'], | |
| 38 | 38 | 'Search params object has expected name "a" values'); | |
| 39 | + | ||
| 40 | + assert.throws(() => { | ||
| 41 | + params.getAll.call(undefined); | ||
| 42 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| 43 | + assert.throws(() => { | ||
| 44 | + params.getAll(); | ||
| 45 | + }, /^TypeError: "name" argument must be specified$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,3 +33,10 @@ assert.strictEqual(false, params.has('d'), | |||
| 33 | 33 | params.delete('first'); | |
| 34 | 34 | assert.strictEqual(false, params.has('first'), | |
| 35 | 35 | 'Search params object has no name "first"'); | |
| 36 | + | ||
| 37 | + assert.throws(() => { | ||
| 38 | + params.has.call(undefined); | ||
| 39 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| 40 | + assert.throws(() => { | ||
| 41 | + params.has(); | ||
| 42 | + }, /^TypeError: "name" argument must be specified$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,34 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + const assert = require('assert'); | ||
| 5 | + const URLSearchParams = require('url').URLSearchParams; | ||
| 6 | + | ||
| 7 | + const params = new URLSearchParams('a=b&c=d'); | ||
| 8 | + const keys = params.keys(); | ||
| 9 | + | ||
| 10 | + assert.strictEqual(typeof keys[Symbol.iterator], 'function'); | ||
| 11 | + assert.strictEqual(keys[Symbol.iterator](), keys); | ||
| 12 | + assert.deepStrictEqual(keys.next(), { | ||
| 13 | + value: 'a', | ||
| 14 | + done: false | ||
| 15 | + }); | ||
| 16 | + assert.deepStrictEqual(keys.next(), { | ||
| 17 | + value: 'c', | ||
| 18 | + done: false | ||
| 19 | + }); | ||
| 20 | + assert.deepStrictEqual(keys.next(), { | ||
| 21 | + value: undefined, | ||
| 22 | + done: true | ||
| 23 | + }); | ||
| 24 | + assert.deepStrictEqual(keys.next(), { | ||
| 25 | + value: undefined, | ||
| 26 | + done: true | ||
| 27 | + }); | ||
| 28 | + | ||
| 29 | + assert.throws(() => { | ||
| 30 | + keys.next.call(undefined); | ||
| 31 | + }, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); | ||
| 32 | + assert.throws(() => { | ||
| 33 | + params.keys.call(undefined); | ||
| 34 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -32,3 +32,10 @@ assert.strictEqual(true, params.has('a'), | |||
| 32 | 32 | 'Search params object has name "a"'); | |
| 33 | 33 | assert.strictEqual(params.get('a'), '4', | |
| 34 | 34 | 'Search params object has name "a" with value "4"'); | |
| 35 | + | ||
| 36 | + assert.throws(() => { | ||
| 37 | + params.set.call(undefined); | ||
| 38 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| 39 | + assert.throws(() => { | ||
| 40 | + params.set('a'); | ||
| 41 | + }, /^TypeError: "name" and "value" arguments must be specified$/); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -110,3 +110,6 @@ assert.strictEqual(params + '', 'a%F0%9F%92%A9b=c'); | |||
| 110 | 110 | // The lone '=' _does_ survive the roundtrip. | |
| 111 | 111 | params = new URLSearchParams('a=&a=b'); | |
| 112 | 112 | assert.strictEqual(params.toString(), 'a=&a=b'); | |
| 113 | + assert.throws(() => { | ||
| 114 | + params.toString.call(undefined); | ||
| 115 | + }, /^TypeError: Value of `this` is not a URLSearchParams$/); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments