mirror of
https://github.com/nodejs/node.git
synced 2024-12-01 16:10:02 +01:00
10b687b58b
* attributon of WPT in url-setter-tests * add WPT test utilities * synchronize WPT URLSearchParams tests * synchronize WPT url tests * split whatwg-url-inspect test * port historical url tests from WPT * protocol setter and special URLs Refs: https://github.com/w3c/web-platform-tests/pull/4413 Refs: https://github.com/whatwg/url/issues/104 PR-URL: https://github.com/nodejs/node/pull/11079 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Timothy Gu <timothygu99@gmail.com>
36 lines
875 B
JavaScript
36 lines
875 B
JavaScript
'use strict';
|
|
|
|
require('../common');
|
|
const assert = require('assert');
|
|
const URLSearchParams = require('url').URLSearchParams;
|
|
|
|
// Tests below are not from WPT.
|
|
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$/);
|