Rewrite [codeclimate] coverage (#3316)
Attacking this in two pieces for ease of review. The legacy implementation for coverage is still there, though I disabled it via the route. That whole file will be removed in the next PR. Ref #2863
This commit is contained in:
@@ -14,6 +14,7 @@ const { isValidRoute, prepareRoute, namedParamsForMatch } = require('./route')
|
||||
const trace = require('./trace')
|
||||
|
||||
const attrSchema = Joi.object({
|
||||
name: Joi.string().min(3),
|
||||
category: isValidCategory,
|
||||
route: isValidRoute,
|
||||
transformPath: Joi.func()
|
||||
@@ -30,6 +31,7 @@ const attrSchema = Joi.object({
|
||||
|
||||
module.exports = function redirector(attrs) {
|
||||
const {
|
||||
name,
|
||||
category,
|
||||
route,
|
||||
transformPath,
|
||||
@@ -51,9 +53,13 @@ module.exports = function redirector(attrs) {
|
||||
}
|
||||
|
||||
static get name() {
|
||||
return `${camelcase(route.base.replace(/\//g, '_'), {
|
||||
pascalCase: true,
|
||||
})}Redirect`
|
||||
if (name) {
|
||||
return name
|
||||
} else {
|
||||
return `${camelcase(route.base.replace(/\//g, '_'), {
|
||||
pascalCase: true,
|
||||
})}Redirect`
|
||||
}
|
||||
}
|
||||
|
||||
static register({ camp, requestCounter }) {
|
||||
|
||||
@@ -24,6 +24,15 @@ describe('Redirector', function() {
|
||||
expect(redirector(attrs).name).to.equal('VeryOldServiceRedirect')
|
||||
})
|
||||
|
||||
it('overrides the name', function() {
|
||||
expect(
|
||||
redirector({
|
||||
...attrs,
|
||||
name: 'ShinyRedirect',
|
||||
}).name
|
||||
).to.equal('ShinyRedirect')
|
||||
})
|
||||
|
||||
it('sets specified route', function() {
|
||||
expect(redirector(attrs).route).to.deep.equal(route)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user