Files
shields/services/codacy/codacy-grade.tester.js
Paul Melnikow 4bd16f93e8 Sort imports and requires (#3056)
This will definitely save time, and ensure more uniformity.

It moves the `createServiceTester()` calls to a different place from where I'd like them, though I'm happy to have them checked by the linter.

Closes #2701
2019-02-21 22:14:40 -05:00

44 lines
1.3 KiB
JavaScript

'use strict'
const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())
const { codacyGrade } = require('./codacy-helpers')
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',
// })