Files
shields/services/swagger/swagger.tester.js
T
Pierre-Yves BandGitHub 25f8541e5b JSON format modernisation and _shields_test removal (#3272)
* 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
2019-04-07 18:57:55 +01:00

44 lines
929 B
JavaScript

'use strict'
const getURL = '/https/example.com/example.json.json'
const apiURL = 'http://online.swagger.io'
const apiGetURL = '/validator/debug'
const apiGetQueryParams = { url: 'https://example.com/example.json' }
const t = (module.exports = require('../tester').createServiceTester())
t.create('Valid (mocked)')
.get(getURL)
.intercept(nock =>
nock(apiURL)
.get(apiGetURL)
.query(apiGetQueryParams)
.reply(200, {})
)
.expectBadge({
label: 'swagger',
message: 'valid',
color: 'brightgreen',
})
t.create('Invalid (mocked)')
.get(getURL)
.intercept(nock =>
nock(apiURL)
.get(apiGetURL)
.query(apiGetQueryParams)
.reply(200, {
schemaValidationMessages: [
{
level: 'error',
message: 'error',
},
],
})
)
.expectBadge({
label: 'swagger',
message: 'invalid',
color: 'red',
})