HealthCheckerTest.js 745 B

12345678910111213141516171819202122232425
  1. const { db } = require('../../../app/js/mongodb')
  2. const DocstoreApp = require('./helpers/DocstoreApp')
  3. const DocstoreClient = require('./helpers/DocstoreClient')
  4. const { expect } = require('chai')
  5. describe('HealthChecker', function () {
  6. beforeEach('start', async function () {
  7. await DocstoreApp.ensureRunning()
  8. })
  9. beforeEach('clear docs collection', async function () {
  10. await db.docs.deleteMany({})
  11. })
  12. let res
  13. beforeEach('run health check', async function () {
  14. res = await DocstoreClient.healthCheck()
  15. })
  16. it('should return 200', function () {
  17. res.status.should.equal(200)
  18. })
  19. it('should not leave any cruft behind', async function () {
  20. expect(await db.docs.find({}).toArray()).to.deep.equal([])
  21. })
  22. })