allow missing 'goal' key in [liberapay] badges (#6258)

* allow missing 'goal' key in [liberapay] badges

closes #6254

* fix test name

Co-authored-by: repo-ranger[bot] <39074581+repo-ranger[bot]@users.noreply.github.com>
This commit is contained in:
chris48s
2021-03-12 19:46:07 +00:00
committed by GitHub
parent 9d404bc2b0
commit 50a962d79f
3 changed files with 25 additions and 2 deletions

View File

@@ -26,8 +26,7 @@ const schema = Joi.object({
.keys({
amount: Joi.string().required(),
})
.allow(null)
.required(),
.allow(null),
}).required()
const isCurrencyOverTime = Joi.string().regex(

View File

@@ -12,6 +12,19 @@ t.create('Giving (not found)')
.get('/does-not-exist.json')
.expectBadge({ label: 'liberapay', message: 'not found' })
t.create('Giving (missing goal key)')
.get('/Liberapay.json')
.intercept(nock =>
nock('https://liberapay.com')
.get('/Liberapay/public.json')
.reply(200, {
npatrons: 0,
giving: { amount: '3.71', currency: 'EUR' },
receiving: null,
})
)
.expectBadge({ label: 'gives', message: isCurrencyOverTime })
t.create('Giving (null)')
.get('/Liberapay.json')
.intercept(nock =>

View File

@@ -8,6 +8,17 @@ t.create('Goal Progress (valid)').get('/Liberapay.json').expectBadge({
message: isIntegerPercentage,
})
t.create('Goal (missing goal key)')
.get('/Liberapay.json')
.intercept(nock =>
nock('https://liberapay.com').get('/Liberapay/public.json').reply(200, {
npatrons: 0,
giving: null,
receiving: null,
})
)
.expectBadge({ label: 'liberapay', message: 'no public goals' })
t.create('Goal Progress (not found)')
.get('/does-not-exist.json')
.expectBadge({ label: 'liberapay', message: 'not found' })