Files
shields/services/aur/aur.tester.js
Paul Melnikow 8a8311d931 Unify and minimize tester boilerplate (#2472)
I started using this one-line boilerplate a while back and it seems to tidy things up a bit.
2018-12-08 13:15:24 -05:00

65 lines
1.5 KiB
JavaScript

'use strict'
const Joi = require('joi')
const ServiceTester = require('../service-tester')
const {
isVPlusDottedVersionNClausesWithOptionalSuffix,
isMetric,
} = require('../test-validators')
const t = (module.exports = new ServiceTester({
id: 'aur',
title: 'Arch Linux AUR',
}))
// version tests
t.create('version (valid)')
.get('/version/yaourt.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'aur',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
colorB: '#007ec6',
})
)
t.create('version (valid, out of date)')
.get('/version/gog-gemini-rue.json?style=_shields_test')
.expectJSONTypes(
Joi.object().keys({
name: 'aur',
value: isVPlusDottedVersionNClausesWithOptionalSuffix,
colorB: '#fe7d37',
})
)
t.create('version (not found)')
.get('/version/not-a-package.json')
.expectJSON({ name: 'aur', value: 'package not found' })
// votes tests
t.create('votes (valid)')
.get('/votes/yaourt.json')
.expectJSONTypes(
Joi.object().keys({
name: 'votes',
value: isMetric,
})
)
t.create('votes (not found)')
.get('/votes/not-a-package.json')
.expectJSON({ name: 'votes', value: 'package not found' })
// license tests
t.create('license (valid)')
.get('/license/yaourt.json')
.expectJSON({ name: 'license', value: 'GPL' })
t.create('license (not found)')
.get('/license/not-a-package.json')
.expectJSON({ name: 'license', value: 'package not found' })