Files
shields/lib/all-badge-examples.spec.js
chris48s ae190c5f07 generate static examples without api call [apm appveyor cdnjs clojars gem npm uptimerobot] (#1740)
* allow service classes to define a static example
* define static example for some services
  (apm, appveyor, cdnjs, clojars, gem, librariesio, npm, uptimerobot)
* add/update tests


This allows us to show an example without making an API call to a live service for better performance.

We can now specify 3 fields in the example definition:

* urlPattern for the version with placeholders e.g: /npm/dw/:package.svg
* ExampleUrl/Uri for the concrete example e.g: /npm/dw/localeval.svg
* PreviewUrl/Uri for the static (or live) image we will actually show
2018-08-23 20:22:24 +01:00

33 lines
1011 B
JavaScript

'use strict'
const { expect } = require('chai')
const allBadgeExamples = require('./all-badge-examples')
describe('The badge examples', function() {
it('should include AppVeyor, which is added automatically', function() {
const { examples } = allBadgeExamples.findCategory('build')
const appVeyorBuildExamples = examples
.filter(ex => ex.title.includes('AppVeyor'))
.filter(ex => !ex.title.includes('tests'))
expect(appVeyorBuildExamples).to.deep.equal([
{
title: 'AppVeyor',
exampleUri: '/appveyor/ci/gruntjs/grunt.svg',
previewUri: '/badge/build-passing-brightgreen.svg',
urlPattern: '/appveyor/ci/:user/:repo.svg',
documentation: undefined,
},
{
title: 'AppVeyor branch',
exampleUri: '/appveyor/ci/gruntjs/grunt/master.svg',
previewUri: '/badge/build-passing-brightgreen.svg',
urlPattern: '/appveyor/ci/:user/:repo/:branch.svg',
documentation: undefined,
},
])
})
})