Files
shields/services/discord/discord.tester.js
Caleb Cartwright 855c9cd261 Remove dev dep imports in production code (#2937)
Fixes #2876 with @paulmelnikow's suggestion 

Moved imports of `ServiceTester` and `createServiceTester` to a separate file so that dev dependencies are not imported by service classes.
2019-02-05 21:51:55 -05:00

41 lines
1019 B
JavaScript

'use strict'
const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())
t.create('gets status for Reactiflux')
.get('/102860784329052160.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'chat',
value: Joi.string().regex(/^[0-9]+ online$/),
color: 'brightgreen',
})
)
t.create('invalid server ID')
.get('/12345.json')
.expectJSON({ name: 'chat', value: 'invalid server' })
t.create('widget disabled')
.get('/12345.json')
.intercept(nock =>
nock('https://discordapp.com/')
.get('/api/guilds/12345/widget.json')
.reply(403, {
code: 50004,
message: 'Widget Disabled',
})
)
.expectJSON({ name: 'chat', value: 'widget disabled' })
t.create('server error')
.get('/12345.json')
.intercept(nock =>
nock('https://discordapp.com/')
.get('/api/guilds/12345/widget.json')
.reply(500, 'Something broke')
)
.expectJSON({ name: 'chat', value: 'inaccessible' })