add tests for [cookbook] service (#2197)
This commit is contained in:
@@ -7,6 +7,9 @@ const { version: versionColor } = require('../../lib/color-formatters')
|
||||
|
||||
// For Chef cookbook.
|
||||
module.exports = class Cookbook extends LegacyService {
|
||||
static get url() {
|
||||
return { base: 'cookbook' }
|
||||
}
|
||||
static registerLegacyRouteHandler({ camp, cache }) {
|
||||
camp.route(
|
||||
/^\/cookbook\/v\/(.*)\.(svg|png|gif|jpg|json)$/,
|
||||
|
||||
34
services/cookbook/cookbook.tester.js
Normal file
34
services/cookbook/cookbook.tester.js
Normal file
@@ -0,0 +1,34 @@
|
||||
'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('version')
|
||||
.get('/v/chef-sugar.json')
|
||||
.expectJSONTypes(
|
||||
Joi.object().keys({
|
||||
name: 'cookbook',
|
||||
value: isVPlusDottedVersionAtLeastOne,
|
||||
})
|
||||
)
|
||||
|
||||
t.create('version (mocked)')
|
||||
.get('/v/chef-sugar.json?style=_shields_test')
|
||||
.intercept(nock =>
|
||||
nock('https://supermarket.getchef.com')
|
||||
.get('/api/v1/cookbooks/chef-sugar/versions/latest')
|
||||
.reply(200, {
|
||||
version: '4.1.0',
|
||||
})
|
||||
)
|
||||
.expectJSON({
|
||||
name: 'cookbook',
|
||||
value: 'v4.1.0',
|
||||
colorB: colorScheme.blue,
|
||||
})
|
||||
Reference in New Issue
Block a user