From 13086d2fcd5559296f473b4c7bbd56021f9cb373 Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 10 Apr 2018 04:36:52 +0200 Subject: [PATCH] fix tests: remove unnecessary assert doesNotThrow and api calls (#1170) * tests: fix error verification So far the error message was not tested at all. This change makes sure the error will actually be tested for. * tests: remove unnecessary api calls `assert.doesNotThrow` does not provide any benefit since it will only catch errors and then rethrow in case of an error. --- test/request/whatwg-url.js | 7 ++++--- test/response/status.js | 10 ++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/test/request/whatwg-url.js b/test/request/whatwg-url.js index af13e4c..7a52a69 100644 --- a/test/request/whatwg-url.js +++ b/test/request/whatwg-url.js @@ -7,14 +7,15 @@ const assert = require('assert'); describe('req.URL', () => { describe('should not throw when', () => { it('host is void', () => { - const req = request(); - assert.doesNotThrow(() => req.URL, TypeError); + // Accessing the URL should not throw. + request().URL; }); it('header.host is invalid', () => { const req = request(); req.header.host = 'invalid host'; - assert.doesNotThrow(() => req.URL, TypeError); + // Accessing the URL should not throw. + req.URL; }); }); diff --git a/test/response/status.js b/test/response/status.js index 9b74612..63e2ff6 100644 --- a/test/response/status.js +++ b/test/response/status.js @@ -17,9 +17,7 @@ describe('res.status=', () => { }); it('should not throw', () => { - assert.doesNotThrow(() => { - response().status = 403; - }); + response().status = 403; }); }); @@ -27,7 +25,7 @@ describe('res.status=', () => { it('should throw', () => { assert.throws(() => { response().status = 999; - }, 'invalid status code: 999'); + }, /invalid status code: 999/); }); }); @@ -41,7 +39,7 @@ describe('res.status=', () => { }); it('should not throw', () => { - assert.doesNotThrow(() => response().status = 700); + response().status = 700; }); }); @@ -59,7 +57,7 @@ describe('res.status=', () => { describe('when a status string', () => { it('should throw', () => { - assert.throws(() => response().status = 'forbidden', 'status code must be a number'); + assert.throws(() => response().status = 'forbidden', /status code must be a number/); }); });