node/test/parallel/test-whatwg-url-searchparams-values.js
abouthiroppy e7f4825c8a test: add tests for searchParams
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>
2017-01-29 01:46:31 -08:00

35 lines
864 B
JavaScript

'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$/);