Files
shields/services/wordpress/wordpress.tester.js
Paul Melnikow ea4b758612 Move service tests alongside code (#1563)
Per discussion in #1543
2018-03-20 18:32:48 -07:00

55 lines
1.2 KiB
JavaScript

'use strict';
const Joi = require('joi');
const ServiceTester = require('../service-tester');
const {
isMetric,
isStarRating,
isVPlusDottedVersionAtLeastOne
} = require('../test-validators');
const t = new ServiceTester({ id: 'wordpress', title: 'Wordpress' });
module.exports = t;
t.create('supported version')
.get('/v/akismet.json')
.expectJSONTypes(Joi.object().keys({
name: 'wordpress',
value: Joi.string().regex(/^\d+(\.\d+)?(\.\d+)? tested$/)
}));
t.create('plugin version')
.get('/plugin/v/akismet.json')
.expectJSONTypes(Joi.object().keys({
name: 'plugin',
value: isVPlusDottedVersionAtLeastOne
}));
t.create('plugin rating')
.get('/plugin/r/akismet.json')
.expectJSONTypes(Joi.object().keys({
name: 'rating',
value: isStarRating
}));
t.create('plugin downloads')
.get('/plugin/dt/akismet.json')
.expectJSONTypes(Joi.object().keys({
name: 'downloads',
value: isMetric
}));
t.create('theme rating')
.get('/theme/r/hestia.json')
.expectJSONTypes(Joi.object().keys({
name: 'rating',
value: isStarRating
}));
t.create('theme downloads')
.get('/theme/dt/hestia.json')
.expectJSONTypes(Joi.object().keys({
name: 'downloads',
value: isMetric
}));