From 7906ed50fab6d3e8f6bd259484c465f2df1bc754 Mon Sep 17 00:00:00 2001 From: Andrei Cioromila Date: Sun, 7 May 2017 14:12:30 +0300 Subject: [PATCH] test: add regex check in test-url-parse-invalid-input Use a regex to validate the error message. PR-URL: https://github.com/nodejs/node/pull/12879 Reviewed-By: Anna Henningsen Reviewed-By: Luigi Pinca Reviewed-By: Yuta Hiroto Reviewed-By: David Cai Reviewed-By: Timothy Gu Reviewed-By: Daijiro Wachi Reviewed-By: James M Snell --- test/parallel/test-url-parse-invalid-input.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/test/parallel/test-url-parse-invalid-input.js b/test/parallel/test-url-parse-invalid-input.js index 688d48beb6..a6de25e10c 100644 --- a/test/parallel/test-url-parse-invalid-input.js +++ b/test/parallel/test-url-parse-invalid-input.js @@ -12,9 +12,13 @@ const url = require('url'); 0.0, 0, [], - {} -].forEach(function(val) { - assert.throws(function() { url.parse(val); }, TypeError); + {}, + () => {}, + Symbol('foo') +].forEach((val) => { + assert.throws(() => { url.parse(val); }, + /^TypeError: Parameter "url" must be a string, not (undefined|boolean|number|object|function|symbol)$/); }); -assert.throws(function() { url.parse('http://%E0%A4%A@fail'); }, /^URIError: URI malformed$/); +assert.throws(() => { url.parse('http://%E0%A4%A@fail'); }, + /^URIError: URI malformed$/);