EditingAMessageTests.coffee 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. {ObjectId} = require "../../../app/js/mongojs"
  2. expect = require("chai").expect
  3. ChatClient = require "./helpers/ChatClient"
  4. describe "Editing a message", ->
  5. before ->
  6. @project_id = ObjectId().toString()
  7. @user_id = ObjectId().toString()
  8. @thread_id = ObjectId().toString()
  9. describe "in a thread", ->
  10. before (done) ->
  11. @content = "thread message"
  12. @new_content = "updated thread message"
  13. ChatClient.sendMessage @project_id, @thread_id, @user_id, @content, (error, response, @message) =>
  14. expect(error).to.be.null
  15. expect(response.statusCode).to.equal 201
  16. expect(@message.id).to.exist
  17. expect(@message.content).to.equal @content
  18. ChatClient.editMessage @project_id, @thread_id, @message.id, @new_content, (error, response, @new_message) =>
  19. expect(error).to.be.null
  20. expect(response.statusCode).to.equal 204
  21. done()
  22. it "should then list the updated message in the threads", (done) ->
  23. ChatClient.getThreads @project_id, (error, response, threads) =>
  24. expect(error).to.be.null
  25. expect(response.statusCode).to.equal 200
  26. expect(threads[@thread_id].messages.length).to.equal 1
  27. expect(threads[@thread_id].messages[0].content).to.equal @new_content
  28. done()