Skip to content

Commit 1813467

Browse files
committed
test: upgrade tests to work with master’s common
PR-URL: #14459 Reviewed-By: Refael Ackermann <[email protected]>
1 parent d89bb1c commit 1813467

11 files changed

+27
-31
lines changed

test/parallel/test-assert-fail.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ assert.throws(
2323
code: 'ERR_ASSERTION',
2424
type: assert.AssertionError,
2525
operator: undefined,
26-
actual: undefined,
26+
actual: 'custom message',
2727
expected: undefined,
2828
message: 'custom message'
2929
})

test/parallel/test-assert.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,7 @@ assert.throws(makeBlock(a.deepEqual, /a/igm, /a/im),
143143
{
144144
const re1 = /a/g;
145145
re1.lastIndex = 3;
146-
assert.doesNotThrow(makeBlock(a.deepEqual, re1, /a/g),
147-
common.expectsError({
148-
code: 'ERR_ASSERTION',
149-
message: /^\/a\/g deepEqual \/a\/g$/
150-
}));
146+
assert.doesNotThrow(makeBlock(a.deepEqual, re1, /a/g));
151147
}
152148

153149
assert.doesNotThrow(makeBlock(a.deepEqual, 4, '4'), 'deepEqual(4, \'4\')');

test/parallel/test-child-process-spawnsync-validation-errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ if (!common.isWindows) {
186186
// Validate the killSignal option
187187
const typeErr = /^TypeError: "killSignal" must be a string or number$/;
188188
const unknownSignalErr =
189-
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' });
189+
common.expectsError({ code: 'ERR_UNKNOWN_SIGNAL' }, 17);
190190

191191
pass('killSignal', undefined);
192192
pass('killSignal', null);

test/parallel/test-child-process-validate-stdio.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const assert = require('assert');
66
const _validateStdio = require('internal/child_process')._validateStdio;
77

88
const expectedError =
9-
common.expectsError({code: 'ERR_INVALID_OPT_VALUE', type: TypeError});
9+
common.expectsError({ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }, 2);
1010

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

3232
{
3333
const stdio3 = [process.stdin, process.stdout, process.stderr];

test/parallel/test-internal-errors.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ assert.throws(() => {
166166
}, common.expectsError({ code: 'TEST_ERROR_1', type: RangeError }));
167167
}, common.expectsError({
168168
code: 'ERR_ASSERTION',
169-
message: /^.+ is not the expected type \S/
169+
message: /^.+ is not instance of \S/
170170
}));
171171

172172
assert.throws(() => {

test/parallel/test-process-emitwarning.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ warningThrowToString.toString = function() {
5858
process.emitWarning(warningThrowToString);
5959

6060
const expectedError =
61-
common.expectsError({code: 'ERR_INVALID_ARG_TYPE', type: TypeError});
61+
common.expectsError({ code: 'ERR_INVALID_ARG_TYPE', type: TypeError }, 11);
6262

6363
// TypeError is thrown on invalid input
6464
assert.throws(() => process.emitWarning(1), expectedError);

test/parallel/test-url-format-whatwg.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ assert.strictEqual(
2525
code: 'ERR_INVALID_ARG_TYPE',
2626
type: TypeError,
2727
message: 'The "options" argument must be of type object'
28-
});
28+
}, 4);
2929
assert.throws(() => url.format(myURL, true), expectedErr);
3030
assert.throws(() => url.format(myURL, 1), expectedErr);
3131
assert.throws(() => url.format(myURL, 'test'), expectedErr);
@@ -36,76 +36,76 @@ assert.strictEqual(
3636
// Any truthy value will be treated as true.
3737

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

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

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

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

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

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

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

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

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

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

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

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

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

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

108108
assert.strictEqual(
109-
url.format(myURL, {unicode: 0}),
109+
url.format(myURL, { unicode: 0 }),
110110
'http://xn--lck1c3crb1723bpq4a.com/a?a=b#c'
111111
);

test/parallel/test-whatwg-url-domainto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const wptToASCIITests = require('../fixtures/url-toascii.js');
1313

1414
{
1515
const expectedError = common.expectsError(
16-
{ code: 'ERR_MISSING_ARGS', type: TypeError });
16+
{ code: 'ERR_MISSING_ARGS', type: TypeError }, 2);
1717
assert.throws(() => domainToASCII(), expectedError);
1818
assert.throws(() => domainToUnicode(), expectedError);
1919
assert.strictEqual(domainToASCII(undefined), 'undefined');

test/parallel/test-whatwg-url-parsing.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const failureTests = tests.filter((test) => test.failure).concat([
2626
]);
2727

2828
const expectedError = common.expectsError(
29-
{ code: 'ERR_INVALID_URL', type: TypeError });
29+
{ code: 'ERR_INVALID_URL', type: TypeError }, 102);
3030

3131
for (const test of failureTests) {
3232
assert.throws(

test/parallel/test-whatwg-url-searchparams-constructor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ function makeIterableFunc(array) {
210210
code: 'ERR_INVALID_TUPLE',
211211
type: TypeError,
212212
message: 'Each query pair must be an iterable [name, value] tuple'
213-
});
213+
}, 6);
214214

215215
let params;
216216
params = new URLSearchParams(undefined);

test/parallel/test-whatwg-url-searchparams.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ sp.forEach(function() {
7676
const callbackErr = common.expectsError({
7777
code: 'ERR_INVALID_CALLBACK',
7878
type: TypeError
79-
});
79+
}, 2);
8080
assert.throws(() => sp.forEach(), callbackErr);
8181
assert.throws(() => sp.forEach(1), callbackErr);
8282
}

0 commit comments

Comments
 (0)