Files
shields/services/github/github-languages.tester.js
Paul Melnikow 4bf55a7826 Fix numeric colorB (#2780)
Numeric colors weren't properly being handled by `makeBadge` after #2742.

Since this function really does not need to be accepting colors as strings, rather than make the function more lenient to work with Scoutcamp, I coerced the types of the colors on the way in.

Two tests cover the functionality in the modern service. I don't feel strongly that the legacy version needs coverage at this point, though I've added one for the moment on the github languages badge where this manifested.

Fix #2778
2019-01-16 11:55:50 -05:00

62 lines
1.4 KiB
JavaScript

'use strict'
const Joi = require('joi')
const ServiceTester = require('../service-tester')
const { isFileSize } = require('../test-validators')
const t = (module.exports = new ServiceTester({
id: 'GithubLanguages',
title: 'GithubLanguages',
pathPrefix: '/github/languages',
}))
t.create('top language')
.get('/top/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'javascript',
value: Joi.string().regex(/^([1-9]?[0-9]\.[0-9]|100\.0)%$/),
})
)
t.create('top language')
.get('/top/badges/shields.json?colorB=123&format=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'javascript',
value: Joi.string().regex(/^([1-9]?[0-9]\.[0-9]|100\.0)%$/),
color: '#123',
})
)
t.create('top language with empty repository')
.get('/top/pyvesb/emptyrepo.json')
.expectJSON({ name: 'language', value: 'none' })
t.create('language count')
.get('/count/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'languages',
value: Joi.number()
.integer()
.positive(),
})
)
t.create('language count (repo not found)')
.get('/count/badges/helmets.json')
.expectJSON({
name: 'languages',
value: 'repo not found',
})
t.create('code size in bytes for all languages')
.get('/code-size/badges/shields.json')
.expectJSONTypes(
Joi.object().keys({
name: 'code size',
value: isFileSize,
})
)