node/test/parallel/test-whatwg-url-setters.js
James M Snell 52670fc09e test: skip whatwg url parse and setter tests when icu is missing
the WHATWG url parser relies on ICU's punycode implementation.
A handful of the standard tests fail when ICU is not present
because of the additional checks that are not implemented. For
now, skip the parse and setter tests if ICU is not present.

PR-URL: https://github.com/nodejs/node/pull/9246
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2016-10-25 08:12:07 -07:00

32 lines
814 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasIntl) {
// A handful of the tests fail when ICU is not included.
common.skip('missing Intl... skipping test');
return;
}
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}`);
}
}
}