-
-
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.
[npm bountysource cdnjs circleci clojars docker gem homebrew itunes m…
…icrobadger nexus requires shippable suggest uptimerobot] Service tests for NPM total downloads + invalidJSON helper (#1471) * Service tests for NPM total downloads * Spread syntax removed * service-tests/helpers/mocks.js -> service-tests/helpers/response-fixtures.js * Another value an invalid JSON in response-fixtures * Using invalidJSON helper in service tests * Working example in a service test of microbadger * isPercentage supports decimal and integer values
- Loading branch information
1 parent
8ad176d
commit 17b4a70
Showing
18 changed files
with
115 additions
and
38 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
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
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
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 |
---|---|---|
|
@@ -7,6 +7,7 @@ const { | |
isVPlusDottedVersionAtLeastOne, | ||
isMetric | ||
} = require('./helpers/validators'); | ||
const { invalidJSON } = require('./helpers/response-fixtures'); | ||
const isOrdinalNumber = Joi.string().regex(/^[1-9][0-9]+(ᵗʰ|ˢᵗ|ⁿᵈ|ʳᵈ)$/); | ||
const isOrdinalNumberDaily = Joi.string().regex(/^[1-9][0-9]+(ᵗʰ|ˢᵗ|ⁿᵈ|ʳᵈ) daily$/); | ||
|
||
|
@@ -36,7 +37,7 @@ t.create('version (unexpected response)') | |
.get('/v/formatador.json') | ||
.intercept(nock => nock('https://rubygems.org') | ||
.get('/api/v1/gems/formatador.json') | ||
.reply(200, "{{{{{invalid json}}") | ||
.reply(invalidJSON) | ||
) | ||
.expectJSON({name: 'gem', value: 'invalid'}); | ||
|
||
|
@@ -64,7 +65,7 @@ t.create('total downloads (unexpected response)') | |
.get('/dt/rails.json') | ||
.intercept(nock => nock('https://rubygems.org') | ||
.get('/api/v1/gems/rails.json') | ||
.reply(200, "{{{{{invalid json}}") | ||
.reply(invalidJSON) | ||
) | ||
.expectJSON({name: 'downloads', value: 'invalid'}); | ||
|
||
|
@@ -105,7 +106,7 @@ t.create('version downloads (unexpected response)') | |
.get('/dv/rails/4.1.0.json') | ||
.intercept(nock => nock('https://rubygems.org') | ||
.get('/api/v1/versions/rails.json') | ||
.reply(200, "{{{{{invalid json}}") | ||
.reply(invalidJSON) | ||
) | ||
.expectJSON({name: '[email protected]', value: 'invalid'}); | ||
|
||
|
@@ -131,7 +132,7 @@ t.create('latest version downloads (unexpected response)') | |
.get('/dtv/rails.json') | ||
.intercept(nock => nock('https://rubygems.org') | ||
.get('/api/v1/gems/rails.json') | ||
.reply(200, "{{{{{invalid json}}") | ||
.reply(invalidJSON) | ||
) | ||
.expectJSON({name: 'downloads@latest', value: 'invalid'}); | ||
|
||
|
@@ -158,7 +159,7 @@ t.create('users (unexpected response)') | |
.get('/u/raphink.json') | ||
.intercept(nock => nock('https://rubygems.org') | ||
.get('/api/v1/owners/raphink/gems.json') | ||
.reply(200, "{{{{{invalid json}}") | ||
.reply(invalidJSON) | ||
) | ||
.expectJSON({name: 'gems', value: 'invalid'}); | ||
|
||
|
@@ -192,6 +193,6 @@ t.create('rank (unexpected response)') | |
.get('/rt/rspec-puppet-facts.json') | ||
.intercept(nock => nock('http://bestgems.org') | ||
.get('/api/v1/gems/rspec-puppet-facts/total_ranking.json') | ||
.reply(200, "{{{{{invalid json}}") | ||
.reply(invalidJSON) | ||
) | ||
.expectJSON({name: 'rank', value: 'invalid'}); |
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,13 @@ | ||
'use strict'; | ||
|
||
const invalidJSON = function() { | ||
return [ | ||
200, | ||
'{{{{{invalid json}}', | ||
{ 'Content-Type': 'application/json' } | ||
]; | ||
}; | ||
|
||
module.exports = { | ||
invalidJSON | ||
}; |
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
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
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
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
Oops, something went wrong.