UNPKG

@infomaker/http-test-server

Version:

IMID HTTP Test Server

40 lines (31 loc) 1.02 kB
/*eslint-env node, jasmine */ 'use strict' const HTTPTestServer = require('../src/http-test-server') const got = require('got') const SUT_PORT = 8080 const SUT_HOST = 'http://localhost' const SUT_URL = `${SUT_HOST}:${SUT_PORT}` let httpTestServerUnderTest const healthEndpoint = 'my-health-endpoint' describe('HTTP test server', () => { it('should be able to be instatiated without errors', () => { httpTestServerUnderTest = new HTTPTestServer({ port: SUT_PORT, enableHealthEndpointAt: `/${healthEndpoint}` }) }) it('should be able to start without errors', () => { return httpTestServerUnderTest.start() }) it('health endpoint should reply with 200', () => { return got.get(`${SUT_URL}/${healthEndpoint}`).then(res => { expect(res.statusCode).toEqual(200) expect(res.body).toEqual('ok') }) }) it('should be able to stop without errors', () => { return httpTestServerUnderTest.stop().catch(err => { expect(err).toEqual(null) }) }) })