Move service tests alongside code (#1563)

Per discussion in #1543
This commit is contained in:
Paul Melnikow
2018-03-20 18:32:48 -07:00
committed by GitHub
parent 71ef474afc
commit ea4b758612
98 changed files with 186 additions and 183 deletions

View File

@@ -0,0 +1,57 @@
'use strict';
const Joi = require('joi');
const ServiceTester = require('../service-tester');
const {
isMetric,
isStarRating,
isVPlusDottedVersionAtLeastOne,
} = require('../test-validators');
const t = new ServiceTester({ id: 'amo', title: 'Mozilla Addons' });
module.exports = t;
t.create('Downloads')
.get('/d/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({ name: 'downloads', value: isMetric }));
t.create('Version')
.get('/v/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({
name: 'mozilla add-on',
value: isVPlusDottedVersionAtLeastOne
}));
t.create('Version - Custom label')
.get('/v/IndieGala-Helper.json?label=IndieGala Helper')
.expectJSONTypes(Joi.object().keys({
name: 'IndieGala Helper',
value: isVPlusDottedVersionAtLeastOne
}));
t.create('Users')
.get('/users/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({
name: 'users',
value: Joi.string().regex(/^\d+$/)
}));
t.create('Rating')
.get('/rating/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({
name: 'rating',
value: Joi.string().regex(/^\d\/\d$/)
}));
t.create('Stars')
.get('/stars/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({ name: 'stars', value: isStarRating }));
t.create('Invalid addon')
.get('/d/invalid-name-of-addon.json')
.expectJSON({ name: 'mozilla add-on', value: 'invalid' });
t.create('No connection')
.get('/v/IndieGala-Helper.json')
.networkOff()
.expectJSON({ name: 'mozilla add-on', value: 'inaccessible' });