Files
shields/services/wheelmap/wheelmap.tester.js
Paul Melnikow 226fa67a02 Create shortcut for BaseService-related imports (#2809)
Continue to implement #2698:

- Add `core/base-service/index.js` (but hold off on moving the things it imports)
- Add shortcuts in `services/index.js` for Base*Service, errors, and deprecatedService. This file will be streamlined later to avoid cluttering it with rarely used bits.
- Apply consistent ordering of imports and use of `module.exports` in testers.
- Remove some renaming of imports.
- Remove obsolete tests here and there.
2019-01-21 15:41:24 -05:00

95 lines
1.9 KiB
JavaScript

'use strict'
const serverSecrets = require('../../lib/server-secrets')
const t = (module.exports = require('..').createServiceTester())
const noToken = !serverSecrets.wheelmap_token
function logTokenWarning() {
if (noToken) {
console.warn(
"No token provided, this test will mock Wheelmap's API responses."
)
}
}
t.create('node with accessibility')
.before(logTokenWarning)
.get('/26699541.json?style=_shields_test')
.timeout(7500)
.interceptIf(noToken, nock =>
nock('https://wheelmap.org/')
.get('/api/nodes/26699541')
.reply(
200,
JSON.stringify({
node: {
wheelchair: 'yes',
},
})
)
)
.expectJSON({
name: 'accessibility',
value: 'yes',
color: 'brightgreen',
})
t.create('node with limited accessibility')
.before(logTokenWarning)
.get('/2034868974.json?style=_shields_test')
.timeout(7500)
.interceptIf(noToken, nock =>
nock('https://wheelmap.org/')
.get('/api/nodes/2034868974')
.reply(
200,
JSON.stringify({
node: {
wheelchair: 'limited',
},
})
)
)
.expectJSON({
name: 'accessibility',
value: 'limited',
color: 'yellow',
})
t.create('node without accessibility')
.before(logTokenWarning)
.get('/-147495158.json?style=_shields_test')
.timeout(7500)
.interceptIf(noToken, nock =>
nock('https://wheelmap.org/')
.get('/api/nodes/-147495158')
.reply(
200,
JSON.stringify({
node: {
wheelchair: 'no',
},
})
)
)
.expectJSON({
name: 'accessibility',
value: 'no',
color: 'red',
})
t.create('node not found')
.before(logTokenWarning)
.get('/0.json')
.timeout(7500)
.interceptIf(noToken, nock =>
nock('https://wheelmap.org/')
.get('/api/nodes/0')
.reply(404)
)
.expectJSON({
name: 'accessibility',
value: 'node not found',
})