- Replace the idea of color schemes with the idea of named colors (since none of our colorschemes have used `colorA`)
- Pass through the normalized color to `_shields_test` to harmonize with BaseService and simplify testing
- Update service tests
- Move responsibility for color generation into the npm package
- Remove several color helper functions and their tests
- Update gh-badge public API to accept `color` and `labelColor`
This is a precursor to refactoring some of the logo code for #2473.
51 lines
1.5 KiB
JavaScript
51 lines
1.5 KiB
JavaScript
'use strict'
|
|
|
|
const Joi = require('joi')
|
|
|
|
const t = (module.exports = require('../create-service-tester')())
|
|
|
|
t.create('Tag')
|
|
.get('/tag/photonstorm/phaser.json')
|
|
.expectJSONTypes(Joi.object().keys({ name: 'tag', value: Joi.string() }))
|
|
|
|
t.create('Tag (inc pre-release)')
|
|
.get('/tag-pre/photonstorm/phaser.json')
|
|
.expectJSONTypes(Joi.object().keys({ name: 'tag', value: Joi.string() }))
|
|
|
|
t.create('Tag (repo not found)')
|
|
.get('/tag/badges/helmets.json')
|
|
.expectJSON({ name: 'tag', value: 'repo not found' })
|
|
|
|
const tagsFixture = [
|
|
{ name: 'cheese' }, // any old string
|
|
{ name: 'v1.3-beta3' }, // semver pre-release
|
|
{ name: 'v1.2' }, // semver release
|
|
]
|
|
|
|
t.create('Tag (mocked response, no pre-releases, semver ordering)')
|
|
.get('/tag/foo/bar.json?style=_shields_test')
|
|
.intercept(nock =>
|
|
nock('https://api.github.com')
|
|
.get('/repos/foo/bar/tags')
|
|
.reply(200, tagsFixture)
|
|
)
|
|
.expectJSON({ name: 'tag', value: 'v1.2', color: 'blue' })
|
|
|
|
t.create('Tag (mocked response, include pre-releases, semver ordering)')
|
|
.get('/tag-pre/foo/bar.json?style=_shields_test')
|
|
.intercept(nock =>
|
|
nock('https://api.github.com')
|
|
.get('/repos/foo/bar/tags')
|
|
.reply(200, tagsFixture)
|
|
)
|
|
.expectJSON({ name: 'tag', value: 'v1.3-beta3', color: 'orange' })
|
|
|
|
t.create('Tag (mocked response, date ordering)')
|
|
.get('/tag-date/foo/bar.json?style=_shields_test')
|
|
.intercept(nock =>
|
|
nock('https://api.github.com')
|
|
.get('/repos/foo/bar/tags')
|
|
.reply(200, tagsFixture)
|
|
)
|
|
.expectJSON({ name: 'tag', value: 'cheese', color: 'blue' })
|