DeletingAThreadTests.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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', async function () {
  6. const projectId = ObjectId().toString()
  7. const userId = ObjectId().toString()
  8. before(async function () {
  9. await ChatApp.ensureRunning()
  10. })
  11. describe('with a thread that is deleted', async function () {
  12. const threadId = ObjectId().toString()
  13. const content = 'deleted thread message'
  14. before(async function () {
  15. const { response } = await ChatClient.sendMessage(
  16. projectId,
  17. threadId,
  18. userId,
  19. content
  20. )
  21. expect(response.statusCode).to.equal(201)
  22. const { response: response2 } = await ChatClient.deleteThread(
  23. projectId,
  24. threadId
  25. )
  26. expect(response2.statusCode).to.equal(204)
  27. })
  28. it('should then not list the thread for the project', async function () {
  29. const { response, body: threads } = await ChatClient.getThreads(projectId)
  30. expect(response.statusCode).to.equal(200)
  31. expect(Object.keys(threads).length).to.equal(0)
  32. })
  33. })
  34. })