DeletingAThreadTests.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { ObjectId } from '../../../app/js/mongodb.js'
  2. import { expect } from 'chai'
  3. import * as ChatClient from './helpers/ChatClient.js'
  4. import * as ChatApp from './helpers/ChatApp.js'
  5. describe('Deleting a thread', async function () {
  6. const projectId = new ObjectId().toString()
  7. const userId = new ObjectId().toString()
  8. before(async function () {
  9. await ChatApp.ensureRunning()
  10. })
  11. describe('with a thread that is deleted', async function () {
  12. const threadId = new 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. })