Files
shields/services/cran/cran.tester.js
T
Paul MelnikowandGitHub 7a664ca3e8 Run prettier (#1866)
Merging this separately so the commit with the tooling change is readable. This is a follow-on to #1167 which turned prettier on.
2018-08-08 17:57:14 -04:00

54 lines
1.3 KiB
JavaScript

'use strict'
const Joi = require('joi')
const ServiceTester = require('../service-tester')
const { isVPlusTripleDottedVersion } = require('../test-validators')
const t = new ServiceTester({ id: 'cran', title: 'CRAN/METACRAN' })
module.exports = t
t.create('version')
.get('/v/devtools.json')
.expectJSONTypes(
Joi.object().keys({
name: 'cran',
value: isVPlusTripleDottedVersion,
})
)
t.create('specified license')
.get('/l/devtools.json')
.expectJSON({ name: 'license', value: 'GPL (>= 2)' })
t.create('unknown package')
.get('/l/some-bogus-package.json')
.expectJSON({ name: 'cran', value: 'not found' })
t.create('unknown info')
.get('/z/devtools.json')
.expectStatus(404)
.expectJSON({ name: '404', value: 'badge not found' })
t.create('malformed response')
.get('/v/foobar.json')
.intercept(nock =>
nock('http://crandb.r-pkg.org')
.get('/foobar')
.reply(200)
) // JSON without Version.
.expectJSON({ name: 'cran', value: 'invalid' })
t.create('connection error')
.get('/v/foobar.json')
.networkOff()
.expectJSON({ name: 'cran', value: 'inaccessible' })
t.create('unspecified license')
.get('/l/foobar.json')
.intercept(nock =>
nock('http://crandb.r-pkg.org')
.get('/foobar')
.reply(200, {})
) // JSON without License.
.expectJSON({ name: 'license', value: 'unknown' })