mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 16:55:46 +00:00

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>
33 lines
839 B
JavaScript
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}`);
|
|
}
|
|
}
|
|
}
|