1
0
mirror of https://github.com/badges/shields.git synced 2025-07-24 20:42:04 +03:00

refactor [cocoapods] service (#2977)

* refactor [cocoapods] service

* remove pointless default

* move join to render()
This commit is contained in:
chris48s
2019-02-13 02:14:36 +00:00
committed by Caleb Cartwright
parent e1a50a7246
commit b87d67bb18
11 changed files with 145 additions and 221 deletions

View File

@ -0,0 +1,28 @@
'use strict'
const Joi = require('joi')
const { isIntegerPercentage } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('doc percent (valid)')
.get('/AFNetworking.json')
.expectJSONTypes(
Joi.object().keys({
name: 'docs',
value: isIntegerPercentage,
})
)
t.create('doc percent (null)')
.get('/AFNetworking.json')
.intercept(nock =>
nock('https://metrics.cocoapods.org')
.get('/api/v1/pods/AFNetworking')
.reply(200, '{"cocoadocs": {"doc_percent": null}}')
)
.expectJSON({ name: 'docs', value: '0%' })
t.create('doc percent (not found)')
.get('/not-a-package.json')
.expectJSON({ name: 'docs', value: 'not found' })