Files
shields/services/codetally/codetally.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

40 lines
1.1 KiB
JavaScript

'use strict'
const Joi = require('joi')
const t = (module.exports = require('../tester').createServiceTester())
// This test will extract the currency value from the
// string value response from the server.
// \b = Asset position at word boundary
// \d+ = match a digit [0-9]
// credit for this regex goes to:
// https://stackoverflow.com/questions/38074000/how-to-get-float-value-from-string-using-regex
t.create('Codetally')
.get('/triggerman722/colorstrap.json')
.expectJSONTypes(
Joi.object().keys({
name: 'codetally',
value: Joi.string().regex(/\b\d+(?:.\d+)?/),
})
)
t.create('Empty')
.get('/triggerman722/colorstrap.json')
.intercept(nock =>
nock('http://www.codetally.com')
.get('/formattedshield/triggerman722/colorstrap')
.reply(200, {
currency_sign: '$',
amount: '0.00',
multiplier: '',
currency_abbreviation: 'CAD',
})
)
.expectJSON({ name: 'codetally', value: '$0.00' })
t.create('Non existent')
.get('/not/real.json')
.timeout(10000)
.expectJSON({ name: 'codetally', value: 'repo not found' })