The server's entrypoint is an important bit of code which is not covered by our tests. This adds a test which should cover it.
30 lines
667 B
JavaScript
30 lines
667 B
JavaScript
'use strict'
|
|
|
|
const { expect } = require('chai')
|
|
const fetch = require('node-fetch')
|
|
const isSvg = require('is-svg')
|
|
const serverConfig = require('./lib/server-config')
|
|
|
|
let server
|
|
before(function() {
|
|
this.timeout('5s')
|
|
serverConfig.bind = {
|
|
port: 1111,
|
|
address: 'localhost',
|
|
}
|
|
server = require('./server')
|
|
})
|
|
|
|
after('shut down the server', async function() {
|
|
await server.stop()
|
|
})
|
|
|
|
it('should render a badge', async function() {
|
|
const res = await fetch('http://localhost:1111/badge/fruit-apple-green.svg')
|
|
expect(res.ok).to.be.true
|
|
expect(await res.text())
|
|
.to.satisfy(isSvg)
|
|
.and.to.include('fruit')
|
|
.and.to.include('apple')
|
|
})
|