[ctan] add tests (#2191)

* add ctan tests

* prettier
This commit is contained in:
Przemo Nowaczyk
2018-10-19 11:35:19 +02:00
committed by Marcin Mielnicki
parent de1eb664ec
commit 999a24320e
2 changed files with 46 additions and 0 deletions

View File

@@ -9,6 +9,9 @@ const { addv: versionText } = require('../../lib/text-formatters')
const { version: versionColor } = require('../../lib/color-formatters')
module.exports = class Ctan extends LegacyService {
static get url() {
return { base: 'ctan' }
}
static registerLegacyRouteHandler({ camp, cache }) {
camp.route(
/^\/ctan\/([vl])\/([^/]+)\.(svg|png|gif|jpg|json)$/,

View File

@@ -0,0 +1,43 @@
'use strict'
const Joi = require('joi')
const createServiceTester = require('../create-service-tester')
const { colorScheme } = require('../test-helpers')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
const t = createServiceTester()
module.exports = t
t.create('license')
.get('/l/novel.json')
.expectJSON({
name: 'license',
value: 'lppl1.3c,ofl',
})
t.create('version')
.get('/v/novel.json')
.expectJSONTypes(
Joi.object().keys({
name: 'ctan',
value: isVPlusDottedVersionAtLeastOne,
})
)
t.create('version (mocked)')
.get('/v/novel.json?style=_shields_test')
.intercept(nock =>
nock('http://www.ctan.org')
.get('/json/pkg/novel')
.reply(200, {
version: {
number: 'v1.11',
},
})
)
.expectJSON({
name: 'ctan',
value: 'v1.11',
colorB: colorScheme.blue,
})