summaryrefslogtreecommitdiff
path: root/test/parallel/test-whatwg-url-setters.js
blob: 4c29ef098cc46301a66f0e61909f94fff7fd5008 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
'use strict';

const common = require('../common');
const path = require('path');
const URL = require('url').URL;
const assert = require('assert');
const attrs = require(path.join(common.fixturesDir, 'url-setter-tests.json'));

for (const attr in attrs) {
  if (attr === 'comment')
    continue;
  const tests = attrs[attr];
  var n = 0;
  for (const test of tests) {
    if (test.skip) continue;
    n++;
    const url = new URL(test.href);
    url[attr] = test.new_value;
    for (const test_attr in test.expected) {
      assert.equal(test.expected[test_attr], url[test_attr],
                   `${n} ${attr} ${test_attr} ${test.href} ${test.comment}`);
    }
  }
}