1
0
mirror of https://github.com/badges/shields.git synced 2025-07-08 18:01:59 +03:00

Port [StackExchange] from legacy to BaseJsonService (#2418)

Per part of issue #2378, convert StackExchange service to the newer
BaseJson class. Refactor also to seperate StackExchange reputation and
questions tag info into new StackExchange subservice files
as the legacy class contained both which may be difficult to keep track
of in the future as the service continues to grow.
More tests have been added to make sure other StackExchange sites besides
StackOverflow will still work with the new badge setup.
This commit is contained in:
Monica Bui
2018-11-28 19:40:12 -07:00
committed by Paul Melnikow
parent 43d99f96e6
commit 9713964812
6 changed files with 211 additions and 167 deletions

View File

@ -0,0 +1,28 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = require('../create-service-tester')()
module.exports = t
t.create('Invalid parameters')
.get('/stackoverflow/invalidimage.json')
.expectJSON({ name: 'stackoverflow', value: 'invalid parameters' })
t.create('Reputation for StackOverflow user 22656')
.get('/stackoverflow/22656.json')
.expectJSONTypes(
Joi.object().keys({
name: 'stackoverflow reputation',
value: isMetric,
})
)
t.create('Reputation for Tex user 22656')
.get('/tex/226.json')
.expectJSONTypes(
Joi.object().keys({
name: 'tex reputation',
value: isMetric,
})
)