-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13502b3
commit 20ab540
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
'use strict'; | ||
|
||
const Joi = require('joi'); | ||
const ServiceTester = require('./runner/service-tester'); | ||
|
||
const t = new ServiceTester({ id : 'codetally', title: 'Codetally' }); | ||
module.exports = t; | ||
|
||
// 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: Joi.equal('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 '}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters