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:
@@ -26,8 +26,7 @@ const schema = Joi.object({
|
||||
.keys({
|
||||
amount: Joi.string().required(),
|
||||
})
|
||||
.allow(null)
|
||||
.required(),
|
||||
.allow(null),
|
||||
}).required()
|
||||
|
||||
const isCurrencyOverTime = Joi.string().regex(
|
||||
|
||||
@@ -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 =>
|
||||
|
||||
@@ -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' })
|
||||
|
||||
Reference in New Issue
Block a user