[librariesio] Missing try/catch block and tests (#1644)
This commit is contained in:
41
services/librariesio/librariesio.tester.js
Normal file
41
services/librariesio/librariesio.tester.js
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const Joi = require('joi');
|
||||
const ServiceTester = require('../service-tester');
|
||||
const {
|
||||
isDependencyState
|
||||
} = require('../test-validators');
|
||||
|
||||
const t = new ServiceTester({ id: 'librariesio', title: 'Libraries.io' });
|
||||
module.exports = t;
|
||||
|
||||
t.create('dependencies for releases')
|
||||
.get('/release/hex/phoenix/1.0.3.json')
|
||||
.expectJSONTypes(Joi.object().keys({
|
||||
name: 'dependencies',
|
||||
value: isDependencyState,
|
||||
}));
|
||||
|
||||
t.create('dependencies for github')
|
||||
.get('/github/pyvesb/notepad4e.json')
|
||||
.expectJSONTypes(Joi.object().keys({
|
||||
name: 'dependencies',
|
||||
value: isDependencyState,
|
||||
}));
|
||||
|
||||
t.create('release not found')
|
||||
.get('/release/hex/invalid/4.0.4.json')
|
||||
.expectJSON({
|
||||
name: 'dependencies',
|
||||
value: 'not available',
|
||||
});
|
||||
|
||||
t.create('no response data')
|
||||
.get('/github/phoenixframework/phoenix.json')
|
||||
.intercept(nock => nock('https://libraries.io')
|
||||
.get('/api/github/phoenixframework/phoenix/dependencies')
|
||||
.reply(200))
|
||||
.expectJSON({
|
||||
name: 'dependencies',
|
||||
value: 'invalid',
|
||||
});
|
||||
@@ -67,6 +67,8 @@ const isFormattedDate = Joi.alternatives().try(
|
||||
Joi.string().regex(/^last (sun|mon|tues|wednes|thurs|fri|satur)day$/),
|
||||
Joi.string().regex(/^(january|february|march|april|may|june|july|august|september|october|november|december)( \d{4})?$/));
|
||||
|
||||
const isDependencyState = withRegex(/^(\d+ out of date|\d+ deprecated|up to date)$/);
|
||||
|
||||
module.exports = {
|
||||
isSemver,
|
||||
isVPlusTripleDottedVersion,
|
||||
@@ -83,5 +85,6 @@ module.exports = {
|
||||
isIntegerPercentage,
|
||||
isDecimalPercentage,
|
||||
isFileSize,
|
||||
isFormattedDate
|
||||
isFormattedDate,
|
||||
isDependencyState
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user