HealthCheckerTest.js 786 B

12345678910111213141516171819202122232425262728
  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', function (done) {
  7. DocstoreApp.ensureRunning(done)
  8. })
  9. beforeEach('clear docs collection', async function () {
  10. await db.docs.deleteMany({})
  11. })
  12. let res
  13. beforeEach('run health check', function (done) {
  14. DocstoreClient.healthCheck((err, _res) => {
  15. res = _res
  16. done(err)
  17. })
  18. })
  19. it('should return 200', function () {
  20. res.statusCode.should.equal(200)
  21. })
  22. it('should not leave any cruft behind', async function () {
  23. expect(await db.docs.find({}).toArray()).to.deep.equal([])
  24. })
  25. })