summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsreepurnajasti <sreepurna.jasti@gmail.com>2018-01-05 13:13:51 +0530
committerJames M Snell <jasnell@gmail.com>2018-01-09 15:32:50 -0800
commit7969811a88a5f0a33c51ffe4078a9ec28a19906d (patch)
tree23c3fb591843301ac5a11c80b42482edb462ad27 /test
parentbcb01de515216699ec5ffa2471b98953ec1b2098 (diff)
downloadandroid-node-v8-7969811a88a5f0a33c51ffe4078a9ec28a19906d.tar.gz
android-node-v8-7969811a88a5f0a33c51ffe4078a9ec28a19906d.tar.bz2
android-node-v8-7969811a88a5f0a33c51ffe4078a9ec28a19906d.zip
test: replace assert.throws with expectsError
PR-URL: https://github.com/nodejs/node/pull/17997 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Diffstat (limited to 'test')
-rw-r--r--test/parallel/test-http-response-statuscode.js7
-rw-r--r--test/parallel/test-url-format-invalid-input.js5
-rw-r--r--test/parallel/test-url-parse-invalid-input.js5
-rw-r--r--test/parallel/test-util-inherits.js21
4 files changed, 19 insertions, 19 deletions
diff --git a/test/parallel/test-http-response-statuscode.js b/test/parallel/test-http-response-statuscode.js
index 79c3f63054..7e93ad10a9 100644
--- a/test/parallel/test-http-response-statuscode.js
+++ b/test/parallel/test-http-response-statuscode.js
@@ -8,14 +8,13 @@ const MAX_REQUESTS = 13;
let reqNum = 0;
function test(res, header, code) {
- const errRegExp = common.expectsError({
+ common.expectsError(() => {
+ res.writeHead(header);
+ }, {
code: 'ERR_HTTP_INVALID_STATUS_CODE',
type: RangeError,
message: `Invalid status code: ${code}`
});
- assert.throws(() => {
- res.writeHead(header);
- }, errRegExp);
}
const server = http.Server(common.mustCall(function(req, res) {
diff --git a/test/parallel/test-url-format-invalid-input.js b/test/parallel/test-url-format-invalid-input.js
index a94546aaf2..4f0f1a11d7 100644
--- a/test/parallel/test-url-format-invalid-input.js
+++ b/test/parallel/test-url-format-invalid-input.js
@@ -14,13 +14,14 @@ const throwsObjsAndReportTypes = new Map([
]);
for (const [urlObject, type] of throwsObjsAndReportTypes) {
- const error = common.expectsError({
+ common.expectsError(function() {
+ url.format(urlObject);
+ }, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "urlObject" argument must be one of type Object or string. ' +
`Received type ${type}`
});
- assert.throws(function() { url.format(urlObject); }, error);
}
assert.strictEqual(url.format(''), '');
assert.strictEqual(url.format({}), '');
diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js
index 86751a2935..d2c7a1135a 100644
--- a/test/parallel/test-url-parse-invalid-input.js
+++ b/test/parallel/test-url-parse-invalid-input.js
@@ -16,12 +16,13 @@ const url = require('url');
[() => {}, 'function'],
[Symbol('foo'), 'symbol']
].forEach(([val, type]) => {
- const error = common.expectsError({
+ common.expectsError(() => {
+ url.parse(val);
+ }, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: `The "url" argument must be of type string. Received type ${type}`
});
- assert.throws(() => { url.parse(val); }, error);
});
assert.throws(() => { url.parse('http://%E0%A4%A@fail'); },
diff --git a/test/parallel/test-util-inherits.js b/test/parallel/test-util-inherits.js
index 9c610e3800..afbd504beb 100644
--- a/test/parallel/test-util-inherits.js
+++ b/test/parallel/test-util-inherits.js
@@ -3,11 +3,6 @@
const common = require('../common');
const assert = require('assert');
const inherits = require('util').inherits;
-const errCheck = common.expectsError({
- code: 'ERR_INVALID_ARG_TYPE',
- type: TypeError,
- message: 'The "superCtor" argument must be of type Function'
-});
// super constructor
function A() {
@@ -86,16 +81,20 @@ common.expectsError(function() {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "superCtor.prototype" property must be of type Function'
-}
-);
-assert.throws(function() {
+});
+
+common.expectsError(function() {
inherits(A, null);
-}, errCheck);
+}, {
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError,
+ message: 'The "superCtor" argument must be of type Function'
+});
+
common.expectsError(function() {
inherits(null, A);
}, {
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError,
message: 'The "ctor" argument must be of type Function'
-}
-);
+});