HealthCheckerTest.js 759 B

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