From 1813467d27d5e83f824e23f0b0bb0e77fc0e128f Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Mon, 24 Jul 2017 22:56:21 +0200 Subject: [PATCH] =?UTF-8?q?test:=20upgrade=20tests=20to=20work=20with=20ma?= =?UTF-8?q?ster=E2=80=99s=20`common`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/14459 Reviewed-By: Refael Ackermann --- test/parallel/test-assert-fail.js | 2 +- test/parallel/test-assert.js | 6 +--- ...ild-process-spawnsync-validation-errors.js | 2 +- .../test-child-process-validate-stdio.js | 4 +-- test/parallel/test-internal-errors.js | 2 +- test/parallel/test-process-emitwarning.js | 2 +- test/parallel/test-url-format-whatwg.js | 32 +++++++++---------- test/parallel/test-whatwg-url-domainto.js | 2 +- test/parallel/test-whatwg-url-parsing.js | 2 +- ...est-whatwg-url-searchparams-constructor.js | 2 +- test/parallel/test-whatwg-url-searchparams.js | 2 +- 11 files changed, 27 insertions(+), 31 deletions(-) diff --git a/test/parallel/test-assert-fail.js b/test/parallel/test-assert-fail.js index d64947fa1000a6..dac8ce49903f5f 100644 --- a/test/parallel/test-assert-fail.js +++ b/test/parallel/test-assert-fail.js @@ -23,7 +23,7 @@ assert.throws( code: 'ERR_ASSERTION', type: assert.AssertionError, operator: undefined, - actual: undefined, + actual: 'custom message', expected: undefined, message: 'custom message' }) diff --git a/test/parallel/test-assert.js b/test/parallel/test-assert.js index 382123ef870256..1033eaf1ac1330 100644 --- a/test/parallel/test-assert.js +++ b/test/parallel/test-assert.js @@ -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\')'); diff --git a/test/parallel/test-child-process-spawnsync-validation-errors.js b/test/parallel/test-child-process-spawnsync-validation-errors.js index dab4b1d37d80f9..b966375288e29c 100644 --- a/test/parallel/test-child-process-spawnsync-validation-errors.js +++ b/test/parallel/test-child-process-spawnsync-validation-errors.js @@ -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); diff --git a/test/parallel/test-child-process-validate-stdio.js b/test/parallel/test-child-process-validate-stdio.js index c6a9bd8e19129c..129ca9822afcd5 100644 --- a/test/parallel/test-child-process-validate-stdio.js +++ b/test/parallel/test-child-process-validate-stdio.js @@ -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); @@ -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]; diff --git a/test/parallel/test-internal-errors.js b/test/parallel/test-internal-errors.js index 8e06bab34944a1..b8cdc840938ca1 100644 --- a/test/parallel/test-internal-errors.js +++ b/test/parallel/test-internal-errors.js @@ -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(() => { diff --git a/test/parallel/test-process-emitwarning.js b/test/parallel/test-process-emitwarning.js index d2d090eae339ee..06772c7be6c210 100644 --- a/test/parallel/test-process-emitwarning.js +++ b/test/parallel/test-process-emitwarning.js @@ -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); diff --git a/test/parallel/test-url-format-whatwg.js b/test/parallel/test-url-format-whatwg.js index d484760c808584..9174c5a2740ec3 100644 --- a/test/parallel/test-url-format-whatwg.js +++ b/test/parallel/test-url-format-whatwg.js @@ -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); @@ -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' ); diff --git a/test/parallel/test-whatwg-url-domainto.js b/test/parallel/test-whatwg-url-domainto.js index bfd5e94d2e5dd8..9e22068a9261f8 100644 --- a/test/parallel/test-whatwg-url-domainto.js +++ b/test/parallel/test-whatwg-url-domainto.js @@ -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'); diff --git a/test/parallel/test-whatwg-url-parsing.js b/test/parallel/test-whatwg-url-parsing.js index 39756449c08c6a..2c1d15d10ce351 100644 --- a/test/parallel/test-whatwg-url-parsing.js +++ b/test/parallel/test-whatwg-url-parsing.js @@ -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( diff --git a/test/parallel/test-whatwg-url-searchparams-constructor.js b/test/parallel/test-whatwg-url-searchparams-constructor.js index 8920a03943bb5d..b6e720cc7fb04c 100644 --- a/test/parallel/test-whatwg-url-searchparams-constructor.js +++ b/test/parallel/test-whatwg-url-searchparams-constructor.js @@ -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); diff --git a/test/parallel/test-whatwg-url-searchparams.js b/test/parallel/test-whatwg-url-searchparams.js index 5bb9cf407dc1e9..db7f9a491719dc 100644 --- a/test/parallel/test-whatwg-url-searchparams.js +++ b/test/parallel/test-whatwg-url-searchparams.js @@ -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); }