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.
This commit is contained in:
parent
8c17517809
commit
13086d2fcd
2 changed files with 8 additions and 9 deletions
|
@ -7,14 +7,15 @@ const assert = require('assert');
|
||||||
describe('req.URL', () => {
|
describe('req.URL', () => {
|
||||||
describe('should not throw when', () => {
|
describe('should not throw when', () => {
|
||||||
it('host is void', () => {
|
it('host is void', () => {
|
||||||
const req = request();
|
// Accessing the URL should not throw.
|
||||||
assert.doesNotThrow(() => req.URL, TypeError);
|
request().URL;
|
||||||
});
|
});
|
||||||
|
|
||||||
it('header.host is invalid', () => {
|
it('header.host is invalid', () => {
|
||||||
const req = request();
|
const req = request();
|
||||||
req.header.host = 'invalid host';
|
req.header.host = 'invalid host';
|
||||||
assert.doesNotThrow(() => req.URL, TypeError);
|
// Accessing the URL should not throw.
|
||||||
|
req.URL;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -17,17 +17,15 @@ describe('res.status=', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not throw', () => {
|
it('should not throw', () => {
|
||||||
assert.doesNotThrow(() => {
|
|
||||||
response().status = 403;
|
response().status = 403;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
describe('and invalid', () => {
|
describe('and invalid', () => {
|
||||||
it('should throw', () => {
|
it('should throw', () => {
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
response().status = 999;
|
response().status = 999;
|
||||||
}, 'invalid status code: 999');
|
}, /invalid status code: 999/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -41,7 +39,7 @@ describe('res.status=', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not throw', () => {
|
it('should not throw', () => {
|
||||||
assert.doesNotThrow(() => response().status = 700);
|
response().status = 700;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -59,7 +57,7 @@ describe('res.status=', () => {
|
||||||
|
|
||||||
describe('when a status string', () => {
|
describe('when a status string', () => {
|
||||||
it('should throw', () => {
|
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/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue