Files
shields/services/codacy/codacy-grade.tester.js
Paul Melnikow 226fa67a02 Create shortcut for BaseService-related imports (#2809)
Continue to implement #2698:

- Add `core/base-service/index.js` (but hold off on moving the things it imports)
- Add shortcuts in `services/index.js` for Base*Service, errors, and deprecatedService. This file will be streamlined later to avoid cluttering it with rarely used bits.
- Apply consistent ordering of imports and use of `module.exports` in testers.
- Remove some renaming of imports.
- Remove obsolete tests here and there.
2019-01-21 15:41:24 -05:00

45 lines
1.3 KiB
JavaScript

'use strict'
const Joi = require('joi')
const { codacyGrade } = require('./codacy-helpers')
const t = (module.exports = require('..').createServiceTester())
t.create('Code quality')
.get('/grade/e27821fb6289410b8f58338c7e0bc686.json')
.expectJSONTypes(
Joi.object().keys({
name: 'code quality',
value: codacyGrade,
})
)
t.create('Code quality on branch')
.get('/grade/e27821fb6289410b8f58338c7e0bc686/master.json')
.expectJSONTypes(
Joi.object().keys({
name: 'code quality',
value: codacyGrade,
})
)
t.create('Code quality (package not found)')
.get('/grade/00000000000000000000000000000000/master.json')
.expectJSON({
name: 'code quality',
value: 'project or branch not found',
})
// This is a known bug. The badge endpoint for a nonexistent branch returns
// the same result. It seems possible the branch specification isn't being
// considered at all.
// e.g.
// https://api.codacy.com/project/badge/grade/e27821fb6289410b8f58338c7e0bc686
// https://api.codacy.com/project/badge/grade/e27821fb6289410b8f58338c7e0bc686?branch=foo
// t.create('Code quality on branch (branch not found)')
// .get('/grade/e27821fb6289410b8f58338c7e0bc686/not-a-branch.json')
// .expectJSON({
// name: 'code quality',
// value: 'project or branch not found',
// })