mirror of
https://github.com/BreizhHardware/express-prom-bundle.git
synced 2026-01-18 16:27:28 +01:00
Implement test
This commit is contained in:
23
spec/normalizeStatusCode.spec.js
Normal file
23
spec/normalizeStatusCode.spec.js
Normal file
@@ -0,0 +1,23 @@
|
||||
'use strict';
|
||||
/* eslint-env jasmine */
|
||||
|
||||
const normalizeStatusCode = require('../src/normalizeStatusCode');
|
||||
|
||||
describe('normalizeStatusCode', () => {
|
||||
it('returns original if disabled in opts', () => {
|
||||
expect(
|
||||
normalizeStatusCode({status_code: 404}, {normalizeStatusCode: false})
|
||||
).toBe(404);
|
||||
});
|
||||
|
||||
it('returns run callback if configured', () => {
|
||||
expect(
|
||||
normalizeStatusCode(
|
||||
{status_code: 500},
|
||||
{
|
||||
formatStatusCode: res => String(res.status_code).slice(0, -2) + 'xx'
|
||||
}
|
||||
)
|
||||
).toBe('5xx');
|
||||
});
|
||||
});
|
||||
@@ -10,5 +10,5 @@ module.exports = function(res, opts) {
|
||||
return opts.formatStatusCode(res, opts);
|
||||
}
|
||||
|
||||
return req.status_code;
|
||||
return res.status_code;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user