mirror of
https://github.com/nodejs/node.git
synced 2025-05-02 17:01:08 +00:00

Also slightly revises grammar. PR-URL: https://github.com/nodejs/node/pull/12574 Refs: https://github.com/nodejs/node/issues/11273 Refs: https://github.com/nodejs/node/issues/11299 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
44 lines
1.0 KiB
JavaScript
44 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const common = 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 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);
|
|
}, common.expectsError({
|
|
code: 'ERR_INVALID_THIS',
|
|
type: TypeError,
|
|
message: 'Value of "this" must be of type URLSearchParamsIterator'
|
|
}));
|
|
assert.throws(() => {
|
|
params.values.call(undefined);
|
|
}, common.expectsError({
|
|
code: 'ERR_INVALID_THIS',
|
|
type: TypeError,
|
|
message: 'Value of "this" must be of type URLSearchParams'
|
|
}));
|