* Modernised JSON format and removed _shields_test style * Added logoWidth and labelColor fields to JSON response * Reinstated and updated comment * Extended expectBadge to accept Joi schemas for all fields
43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
'use strict'
|
|
|
|
const t = (module.exports = require('../tester').createServiceTester())
|
|
|
|
t.create('status of http://shields.io')
|
|
.get('/http/shields.io.json')
|
|
.expectBadge({ label: 'website', message: 'up', color: 'brightgreen' })
|
|
|
|
t.create('status of https://shields.io')
|
|
.get('/https/shields.io.json')
|
|
.expectBadge({ label: 'website', message: 'up', color: 'brightgreen' })
|
|
|
|
t.create('status of nonexistent domain')
|
|
.get('/https/shields-io.io.json')
|
|
.expectBadge({ label: 'website', message: 'down', color: 'red' })
|
|
|
|
t.create('status when network is off')
|
|
.get('/http/shields.io.json')
|
|
.networkOff()
|
|
.expectBadge({ label: 'website', message: 'down', color: 'red' })
|
|
|
|
t.create('custom online label, online message and online color')
|
|
.get(
|
|
'/http/online.com.json?up_message=up&down_message=down&up_color=green&down_color=grey'
|
|
)
|
|
.intercept(nock =>
|
|
nock('http://online.com')
|
|
.head('/')
|
|
.reply(200)
|
|
)
|
|
.expectBadge({ label: 'website', message: 'up', color: 'green' })
|
|
|
|
t.create('custom offline message and offline color')
|
|
.get(
|
|
'/http/offline.com.json?up_message=up&down_message=down&up_color=green&down_color=grey'
|
|
)
|
|
.intercept(nock =>
|
|
nock('http://offline.com')
|
|
.head('/')
|
|
.reply(500)
|
|
)
|
|
.expectBadge({ label: 'website', message: 'down', color: 'grey' })
|