node/test/parallel/test-whatwg-url-setters.js
Daijiro Wachi 71650aa8fc test: use common.hasIntl in tests related to ICU
We should use `common.hasIntl` in tests for test cases which are
related to ICU.
This way we can easily find the test cases that are Intl dependent.
Plus, it will be able to make the tests a little faster if we check
hasIntl first.

Also, this tweaks the log messages to unify the message.

Refs: https://github.com/nodejs/node/pull/10707
PR-URL: https://github.com/nodejs/node/pull/10841
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2017-01-19 09:12:22 +01:00

33 lines
839 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');
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];
let 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.strictEqual(test.expected[test_attr], url[test_attr],
`${n} ${attr} ${test_attr} ` +
`${test.href} ${test.comment}`);
}
}
}