This repository has been archived by the owner on Mar 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from digicatapult/chore/template-content-updates
helper and test updates
- Loading branch information
Showing
8 changed files
with
63 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* eslint no-console: "off" */ | ||
const request = require('supertest') | ||
|
||
const { API_MAJOR_VERSION } = require('../../app/env') | ||
|
||
async function apiDocs({ app }) { | ||
return request(app) | ||
.get(`/${API_MAJOR_VERSION}/api-docs`) | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.then((response) => { | ||
return response | ||
}) | ||
.catch((err) => { | ||
console.error(`healthCheckErr ${err}`) | ||
return err | ||
}) | ||
} | ||
|
||
async function healthCheck({ app }) { | ||
return request(app) | ||
.get('/health') | ||
.set('Accept', 'application/json') | ||
.set('Content-Type', 'application/json') | ||
.then((response) => { | ||
return response | ||
}) | ||
.catch((err) => { | ||
console.error(`healthCheckErr ${err}`) | ||
return err | ||
}) | ||
} | ||
|
||
module.exports = { | ||
apiDocs, | ||
healthCheck, | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,22 @@ | ||
const { describe, before, it } = require('mocha') | ||
const { describe, before, test } = require('mocha') | ||
const { expect } = require('chai') | ||
|
||
const { setupServer } = require('../helpers/server') | ||
const { createHttpServer } = require('../../app/server') | ||
const { API_VERSION } = require('../../app/env') | ||
const { healthCheck } = require('../helper/routeHelper') | ||
|
||
describe('health', function () { | ||
const context = {} | ||
let app | ||
|
||
before(async function () { | ||
await setupServer(context) | ||
context.response = await context.request.get('/health') | ||
app = await createHttpServer() | ||
}) | ||
|
||
it('should return 200', function () { | ||
expect(context.response.status).to.equal(200) | ||
}) | ||
test('health check', async function () { | ||
const expectedResult = { status: 'ok', version: API_VERSION } | ||
|
||
it('should return success', function () { | ||
expect(context.response.body).to.deep.equal({ version: API_VERSION, status: 'ok' }) | ||
const actualResult = await healthCheck(app) | ||
expect(actualResult.status).to.equal(200) | ||
expect(actualResult.body).to.deep.equal(expectedResult) | ||
}) | ||
}) |