[beerpay] test (#2174)

This commit is contained in:
Jowita Mielnicka
2018-10-14 20:49:26 +02:00
committed by chris48s
parent fb6e91c3b2
commit 584fc99f54
3 changed files with 39 additions and 0 deletions

View File

@@ -7,6 +7,9 @@ const { makeBadgeData: getBadgeData } = require('../../lib/badge-data')
// e.g. JSON response: https://beerpay.io/api/v1/beerpay/projects/beerpay.io
// e.g. SVG badge: https://beerpay.io/beerpay/beerpay.io/badge.svg?style=flat-square
module.exports = class Beerpay extends LegacyService {
static get url() {
return { base: 'beerpay' }
}
static registerLegacyRouteHandler({ camp, cache }) {
camp.route(
/^\/beerpay\/(.*)\/(.*)\.(svg|png|gif|jpg|json)$/,

View File

@@ -0,0 +1,35 @@
'use strict'
const Joi = require('joi')
const createServiceTester = require('../create-service-tester')
const { withRegex } = require('../test-validators')
const { colorScheme } = require('../test-helpers')
const t = createServiceTester()
module.exports = t
const amountOfMoney = withRegex(/^\$[0-9]+(\.[0-9]+)?/)
t.create('funding')
.get('/hashdog/scrapfy-chrome-extension.json')
.expectJSONTypes(
Joi.object().keys({
name: 'beerpay',
value: amountOfMoney,
})
)
t.create('funding 0')
.get('/hashdog/scrapfy-chrome-extension.json?style=_shields_test')
.intercept(nock =>
nock('https://beerpay.io')
.get('/api/v1/hashdog/projects/scrapfy-chrome-extension')
.reply(200, {})
)
.expectJSON({
name: 'beerpay',
value: '$0',
colorB: colorScheme.red,
})

View File

@@ -130,4 +130,5 @@ module.exports = {
isFormattedDate,
isDependencyState,
isBuildStatus,
withRegex,
}