Skip to content

Commit

Permalink
test: upgrade tests to work with master’s common
Browse files Browse the repository at this point in the history
PR-URL: nodejs#14459
Reviewed-By: Refael Ackermann <[email protected]>
  • Loading branch information
addaleax committed Jul 27, 2017
1 parent d89bb1c commit 1813467
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 31 deletions.
2 changes: 1 addition & 1 deletion test/parallel/test-assert-fail.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ assert.throws(
code: 'ERR_ASSERTION',
type: assert.AssertionError,
operator: undefined,
actual: undefined,
actual: 'custom message',
expected: undefined,
message: 'custom message'
})
Expand Down
6 changes: 1 addition & 5 deletions test/parallel/test-assert.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im),
{
const re1 = /a/g;
re1.lastIndex = 3;
assert.doesNotThrow(makeBlock(a.deepEqual, re1, /a/g),
common.expectsError({
code: 'ERR_ASSERTION',
message: /^\/a\/g deepEqual \/a\/g$/
}));
assert.doesNotThrow(makeBlock(a.deepEqual, re1, /a/g));
}

assert.doesNotThrow(makeBlock(a.deepEqual, 4, '4'), 'deepEqual(4, \'4\')');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ if (!common.isWindows) {
// Validate the killSignal option
const typeErr = /^TypeError: "killSignal" must be a string or number$/;
const unknownSignalErr =
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' });
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }, 17);

pass('killSignal', undefined);
pass('killSignal', null);
Expand Down
4 changes: 2 additions & 2 deletions test/parallel/test-child-process-validate-stdio.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const assert = require('assert');
const _validateStdio = require('internal/child_process')._validateStdio;

const expectedError =
common.expectsError({code: 'ERR_INVALID_OPT_VALUE', type: TypeError});
common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }, 2);

// should throw if string and not ignore, pipe, or inherit
assert.throws(() => _validateStdio('foo'), expectedError);
Expand All @@ -27,7 +27,7 @@ assert.throws(() => _validateStdio(600), expectedError);
// should throw if stdio has ipc and sync is true
const stdio2 = ['ipc', 'ipc', 'ipc'];
assert.throws(() => _validateStdio(stdio2, true),
common.expectsError({code: 'ERR_IPC_SYNC_FORK', type: Error}));
common.expectsError({ code: 'ERR_IPC_SYNC_FORK', type: Error }));

{
const stdio3 = [process.stdin, process.stdout, process.stderr];
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-internal-errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ assert.throws(() => {
}, common.expectsError({ code: 'TEST_ERROR_1', type: RangeError }));
}, common.expectsError({
code: 'ERR_ASSERTION',
message: /^.+ is not the expected type \S/
message: /^.+ is not instance of \S/
}));

assert.throws(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-process-emitwarning.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ warningThrowToString.toString = function() {
process.emitWarning(warningThrowToString);

const expectedError =
common.expectsError({code: 'ERR_INVALID_ARG_TYPE', type: TypeError});
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 11);

// TypeError is thrown on invalid input
assert.throws(() => process.emitWarning(1), expectedError);
Expand Down
32 changes: 16 additions & 16 deletions test/parallel/test-url-format-whatwg.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ assert.strictEqual(
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "options" argument must be of type object'
});
}, 4);
assert.throws(() => url.format(myURL, true), expectedErr);
assert.throws(() => url.format(myURL, 1), expectedErr);
assert.throws(() => url.format(myURL, 'test'), expectedErr);
Expand All @@ -36,76 +36,76 @@ assert.strictEqual(
// Any truthy value will be treated as true.

assert.strictEqual(
url.format(myURL, {fragment: false}),
url.format(myURL, { fragment: false }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
);

assert.strictEqual(
url.format(myURL, {fragment: ''}),
url.format(myURL, { fragment: '' }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
);

assert.strictEqual(
url.format(myURL, {fragment: 0}),
url.format(myURL, { fragment: 0 }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b'
);

assert.strictEqual(
url.format(myURL, {fragment: 1}),
url.format(myURL, { fragment: 1 }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {fragment: {}}),
url.format(myURL, { fragment: {} }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {search: false}),
url.format(myURL, { search: false }),
'http://xn--lck1c3crb1723bpq4a.com/a#c'
);

assert.strictEqual(
url.format(myURL, {search: ''}),
url.format(myURL, { search: '' }),
'http://xn--lck1c3crb1723bpq4a.com/a#c'
);

assert.strictEqual(
url.format(myURL, {search: 0}),
url.format(myURL, { search: 0 }),
'http://xn--lck1c3crb1723bpq4a.com/a#c'
);

assert.strictEqual(
url.format(myURL, {search: 1}),
url.format(myURL, { search: 1 }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {search: {}}),
url.format(myURL, { search: {} }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {unicode: true}),
url.format(myURL, { unicode: true }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {unicode: 1}),
url.format(myURL, { unicode: 1 }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {unicode: {}}),
url.format(myURL, { unicode: {} }),
'http://理容ナカムラ.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {unicode: false}),
url.format(myURL, { unicode: false }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
);

assert.strictEqual(
url.format(myURL, {unicode: 0}),
url.format(myURL, { unicode: 0 }),
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
);
2 changes: 1 addition & 1 deletion test/parallel/test-whatwg-url-domainto.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const wptToASCIITests = require('../fixtures/url-toascii.js');

{
const expectedError = common.expectsError(
{ code: 'ERR_MISSING_ARGS', type: TypeError });
{ code: 'ERR_MISSING_ARGS', type: TypeError }, 2);
assert.throws(() => domainToASCII(), expectedError);
assert.throws(() => domainToUnicode(), expectedError);
assert.strictEqual(domainToASCII(undefined), 'undefined');
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-whatwg-url-parsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const failureTests = tests.filter((test) => test.failure).concat([
]);

const expectedError = common.expectsError(
{ code: 'ERR_INVALID_URL', type: TypeError });
{ code: 'ERR_INVALID_URL', type: TypeError }, 102);

for (const test of failureTests) {
assert.throws(
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-whatwg-url-searchparams-constructor.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ function makeIterableFunc(array) {
code: 'ERR_INVALID_TUPLE',
type: TypeError,
message: 'Each query pair must be an iterable [name, value] tuple'
});
}, 6);

let params;
params = new URLSearchParams(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-whatwg-url-searchparams.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ sp.forEach(function() {
const callbackErr = common.expectsError({
code: 'ERR_INVALID_CALLBACK',
type: TypeError
});
}, 2);
assert.throws(() => sp.forEach(), callbackErr);
assert.throws(() => sp.forEach(1), callbackErr);
}
Expand Down

0 comments on commit 1813467

Please sign in to comment.