Migrated most service tests to use new expectBadge (#3122)

This commit is contained in:
Pierre-Yves B
2019-02-28 21:43:23 +00:00
committed by GitHub
parent 4e2d144f97
commit 1f29c22d3d
230 changed files with 3480 additions and 4439 deletions

View File

@@ -1,22 +1,17 @@
'use strict'
const Joi = require('joi')
const { ServiceTester } = require('../tester')
const { isMetricOverTimePeriod } = require('../test-validators')
const t = (module.exports = new ServiceTester({ id: 'amo', title: 'AMO' }))
t.create('Weekly Downloads')
.get('/dw/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({ name: 'downloads', value: isMetricOverTimePeriod })
)
.expectBadge({ label: 'downloads', message: isMetricOverTimePeriod })
t.create('Weekly Downloads (not found)')
.get('/dw/not-a-real-plugin.json')
.expectJSON({ name: 'downloads', value: 'not found' })
.expectBadge({ label: 'downloads', message: 'not found' })
t.create('/d URL should redirect to /dw')
.get('/d/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({ name: 'downloads', value: isMetricOverTimePeriod })
)
.expectBadge({ label: 'downloads', message: isMetricOverTimePeriod })

View File

@@ -6,17 +6,15 @@ const t = (module.exports = require('../tester').createServiceTester())
t.create('Rating')
.get('/rating/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({
name: 'rating',
value: Joi.string().regex(/^\d\/\d$/),
})
)
.expectBadge({
label: 'rating',
message: Joi.string().regex(/^\d\/\d$/),
})
t.create('Stars')
.get('/stars/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({ name: 'stars', value: isStarRating }))
.expectBadge({ label: 'stars', message: isStarRating })
t.create('Rating (not found)')
.get('/rating/not-a-real-plugin.json')
.expectJSON({ name: 'mozilla add-on', value: 'not found' })
.expectBadge({ label: 'mozilla add-on', message: 'not found' })

View File

@@ -1,13 +1,12 @@
'use strict'
const Joi = require('joi')
const { isMetric } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('Users')
.get('/IndieGala-Helper.json')
.expectJSONTypes(Joi.object().keys({ name: 'users', value: isMetric }))
.expectBadge({ label: 'users', message: isMetric })
t.create('Users (not found)')
.get('/not-a-real-plugin.json')
.expectJSON({ name: 'users', value: 'not found' })
.expectBadge({ label: 'users', message: 'not found' })

View File

@@ -1,18 +1,15 @@
'use strict'
const Joi = require('joi')
const { isVPlusDottedVersionAtLeastOne } = require('../test-validators')
const t = (module.exports = require('../tester').createServiceTester())
t.create('Version')
.get('/IndieGala-Helper.json')
.expectJSONTypes(
Joi.object().keys({
name: 'mozilla add-on',
value: isVPlusDottedVersionAtLeastOne,
})
)
.expectBadge({
label: 'mozilla add-on',
message: isVPlusDottedVersionAtLeastOne,
})
t.create('Version (not found)')
.get('/not-a-real-plugin.json')
.expectJSON({ name: 'mozilla add-on', value: 'not found' })
.expectBadge({ label: 'mozilla add-on', message: 'not found' })