mirror of https://github.com/lukechilds/node.git
Browse Source
PR-URL: https://github.com/nodejs/node/pull/10952 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>v7.x
abouthiroppy
8 years ago
committed by
Evan Lucas
11 changed files with 151 additions and 1 deletions
@ -0,0 +1,33 @@ |
|||
'use strict'; |
|||
|
|||
require('../common'); |
|||
const assert = require('assert'); |
|||
const URLSearchParams = require('url').URLSearchParams; |
|||
|
|||
const params = new URLSearchParams('a=b&c=d'); |
|||
const entries = params.entries(); |
|||
assert.strictEqual(typeof entries[Symbol.iterator], 'function'); |
|||
assert.strictEqual(entries[Symbol.iterator](), entries); |
|||
assert.deepStrictEqual(entries.next(), { |
|||
value: ['a', 'b'], |
|||
done: false |
|||
}); |
|||
assert.deepStrictEqual(entries.next(), { |
|||
value: ['c', 'd'], |
|||
done: false |
|||
}); |
|||
assert.deepStrictEqual(entries.next(), { |
|||
value: undefined, |
|||
done: true |
|||
}); |
|||
assert.deepStrictEqual(entries.next(), { |
|||
value: undefined, |
|||
done: true |
|||
}); |
|||
|
|||
assert.throws(() => { |
|||
entries.next.call(undefined); |
|||
}, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); |
|||
assert.throws(() => { |
|||
params.entries.call(undefined); |
|||
}, /^TypeError: Value of `this` is not a URLSearchParams$/); |
@ -0,0 +1,34 @@ |
|||
'use strict'; |
|||
|
|||
require('../common'); |
|||
const assert = require('assert'); |
|||
const URLSearchParams = require('url').URLSearchParams; |
|||
|
|||
const params = new URLSearchParams('a=b&c=d'); |
|||
const keys = params.keys(); |
|||
|
|||
assert.strictEqual(typeof keys[Symbol.iterator], 'function'); |
|||
assert.strictEqual(keys[Symbol.iterator](), keys); |
|||
assert.deepStrictEqual(keys.next(), { |
|||
value: 'a', |
|||
done: false |
|||
}); |
|||
assert.deepStrictEqual(keys.next(), { |
|||
value: 'c', |
|||
done: false |
|||
}); |
|||
assert.deepStrictEqual(keys.next(), { |
|||
value: undefined, |
|||
done: true |
|||
}); |
|||
assert.deepStrictEqual(keys.next(), { |
|||
value: undefined, |
|||
done: true |
|||
}); |
|||
|
|||
assert.throws(() => { |
|||
keys.next.call(undefined); |
|||
}, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); |
|||
assert.throws(() => { |
|||
params.keys.call(undefined); |
|||
}, /^TypeError: Value of `this` is not a URLSearchParams$/); |
@ -0,0 +1,34 @@ |
|||
'use strict'; |
|||
|
|||
require('../common'); |
|||
const assert = require('assert'); |
|||
const URLSearchParams = require('url').URLSearchParams; |
|||
|
|||
const params = new URLSearchParams('a=b&c=d'); |
|||
const values = params.values(); |
|||
|
|||
assert.strictEqual(typeof values[Symbol.iterator], 'function'); |
|||
assert.strictEqual(values[Symbol.iterator](), values); |
|||
assert.deepStrictEqual(values.next(), { |
|||
value: 'b', |
|||
done: false |
|||
}); |
|||
assert.deepStrictEqual(values.next(), { |
|||
value: 'd', |
|||
done: false |
|||
}); |
|||
assert.deepStrictEqual(values.next(), { |
|||
value: undefined, |
|||
done: true |
|||
}); |
|||
assert.deepStrictEqual(values.next(), { |
|||
value: undefined, |
|||
done: true |
|||
}); |
|||
|
|||
assert.throws(() => { |
|||
values.next.call(undefined); |
|||
}, /^TypeError: Value of `this` is not a URLSearchParamsIterator$/); |
|||
assert.throws(() => { |
|||
params.values.call(undefined); |
|||
}, /^TypeError: Value of `this` is not a URLSearchParams$/); |
Loading…
Reference in new issue