• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3// Tests below are not from WPT.
4
5require('../common');
6const assert = require('assert');
7const util = require('util');
8
9const sp = new URLSearchParams('?a=a&b=b&b=c');
10assert.strictEqual(util.inspect(sp),
11                   "URLSearchParams { 'a' => 'a', 'b' => 'b', 'b' => 'c' }");
12assert.strictEqual(util.inspect(sp.keys()),
13                   "URLSearchParams Iterator { 'a', 'b', 'b' }");
14assert.strictEqual(util.inspect(sp.values()),
15                   "URLSearchParams Iterator { 'a', 'b', 'c' }");
16assert.strictEqual(util.inspect(sp.keys(), { breakLength: 1 }),
17                   "URLSearchParams Iterator {\n  'a',\n  'b',\n  'b' }");
18
19const iterator = sp.entries();
20assert.strictEqual(util.inspect(iterator),
21                   "URLSearchParams Iterator { [ 'a', 'a' ], [ 'b', 'b' ], " +
22                                             "[ 'b', 'c' ] }");
23iterator.next();
24assert.strictEqual(util.inspect(iterator),
25                   "URLSearchParams Iterator { [ 'b', 'b' ], [ 'b', 'c' ] }");
26iterator.next();
27iterator.next();
28assert.strictEqual(util.inspect(iterator),
29                   'URLSearchParams Iterator {  }');
30