Sha256: 7510b5260b1a0185e4ebd6d71a246b69666c96e1a73eb30c427ccb5df29632d6

Contents?: true

Size: 1.64 KB

Versions: 1

Compression:

Stored size: 1.64 KB

Contents

'use strict';

require('../common');
const assert = require('assert');
const URL = require('url').URL;

const m = new URL('http://example.org');
let params = m.searchParams;

// Until we export URLSearchParams
const URLSearchParams = params.constructor;

// Append same name
params = new URLSearchParams();
params.append('a', 'b');
assert.strictEqual(params + '', 'a=b');
params.append('a', 'b');
assert.strictEqual(params + '', 'a=b&a=b');
params.append('a', 'c');
assert.strictEqual(params + '', 'a=b&a=b&a=c');

// Append empty strings
params = new URLSearchParams();
params.append('', '');
assert.strictEqual(params + '', '=');
params.append('', '');
assert.strictEqual(params + '', '=&=');

// Append null
params = new URLSearchParams();
params.append(null, null);
assert.strictEqual(params + '', 'null=null');
params.append(null, null);
assert.strictEqual(params + '', 'null=null&null=null');

// Append multiple
params = new URLSearchParams();
params.append('first', 1);
params.append('second', 2);
params.append('third', '');
params.append('first', 10);
assert.strictEqual(true, params.has('first'),
                   'Search params object has name "first"');
assert.strictEqual(params.get('first'), '1',
                   'Search params object has name "first" with value "1"');
assert.strictEqual(params.get('second'), '2',
                   'Search params object has name "second" with value "2"');
assert.strictEqual(params.get('third'), '',
                   'Search params object has name "third" with value ""');
params.append('first', 10);
assert.strictEqual(params.get('first'), '1',
                   'Search params object has name "first" with value "1"');

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
node-compiler-0.9.1 vendor/node/test/parallel/test-whatwg-url-searchparams-append.js