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:
Paul Melnikow
2019-04-15 23:47:25 -04:00
committed by GitHub
parent 700b61e16b
commit 91d6dd6643
8 changed files with 224 additions and 71 deletions

View File

@@ -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 }) {

View File

@@ -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)
})