DeletingAThreadTests.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const { ObjectId } = require('../../../app/js/mongodb')
  2. const { expect } = require('chai')
  3. const ChatClient = require('./helpers/ChatClient')
  4. const ChatApp = require('./helpers/ChatApp')
  5. describe('Deleting a thread', function () {
  6. before(function (done) {
  7. this.project_id = ObjectId().toString()
  8. this.user_id = ObjectId().toString()
  9. ChatApp.ensureRunning(done)
  10. })
  11. describe('with a thread that is deleted', function () {
  12. before(function (done) {
  13. this.thread_id = ObjectId().toString()
  14. this.content = 'deleted thread message'
  15. ChatClient.sendMessage(
  16. this.project_id,
  17. this.thread_id,
  18. this.user_id,
  19. this.content,
  20. (error, response, body) => {
  21. expect(error).to.be.null
  22. expect(response.statusCode).to.equal(201)
  23. ChatClient.deleteThread(
  24. this.project_id,
  25. this.thread_id,
  26. (error, response, body) => {
  27. expect(error).to.be.null
  28. expect(response.statusCode).to.equal(204)
  29. done()
  30. }
  31. )
  32. }
  33. )
  34. })
  35. it('should then not list the thread for the project', function (done) {
  36. ChatClient.getThreads(this.project_id, (error, response, threads) => {
  37. expect(error).to.be.null
  38. expect(response.statusCode).to.equal(200)
  39. expect(Object.keys(threads).length).to.equal(0)
  40. done()
  41. })
  42. })
  43. })
  44. })