forked from badges/shields
-
Notifications
You must be signed in to change notification settings - Fork 0
/
amo.tester.js
57 lines (47 loc) · 1.51 KB
/
amo.tester.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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' });