2017-01-24 09:44:32 -05:00
|
|
|
{ObjectId} = require "../../../app/js/mongojs"
|
|
|
|
expect = require("chai").expect
|
|
|
|
|
|
|
|
ChatClient = require "./helpers/ChatClient"
|
2018-01-29 07:01:26 -05:00
|
|
|
ChatApp = require "./helpers/ChatApp"
|
2017-01-24 09:44:32 -05:00
|
|
|
|
|
|
|
describe "Editing a message", ->
|
2018-01-29 07:01:26 -05:00
|
|
|
before (done) ->
|
2017-01-24 09:44:32 -05:00
|
|
|
@project_id = ObjectId().toString()
|
|
|
|
@user_id = ObjectId().toString()
|
|
|
|
@thread_id = ObjectId().toString()
|
2018-01-29 07:01:26 -05:00
|
|
|
ChatApp.ensureRunning done
|
2017-01-24 09:44:32 -05:00
|
|
|
|
|
|
|
describe "in a thread", ->
|
|
|
|
before (done) ->
|
|
|
|
@content = "thread message"
|
|
|
|
@new_content = "updated thread message"
|
|
|
|
ChatClient.sendMessage @project_id, @thread_id, @user_id, @content, (error, response, @message) =>
|
|
|
|
expect(error).to.be.null
|
|
|
|
expect(response.statusCode).to.equal 201
|
|
|
|
expect(@message.id).to.exist
|
|
|
|
expect(@message.content).to.equal @content
|
|
|
|
ChatClient.editMessage @project_id, @thread_id, @message.id, @new_content, (error, response, @new_message) =>
|
|
|
|
expect(error).to.be.null
|
2017-01-25 08:47:45 -05:00
|
|
|
expect(response.statusCode).to.equal 204
|
2017-01-24 09:44:32 -05:00
|
|
|
done()
|
|
|
|
|
|
|
|
it "should then list the updated message in the threads", (done) ->
|
|
|
|
ChatClient.getThreads @project_id, (error, response, threads) =>
|
|
|
|
expect(error).to.be.null
|
|
|
|
expect(response.statusCode).to.equal 200
|
|
|
|
expect(threads[@thread_id].messages.length).to.equal 1
|
|
|
|
expect(threads[@thread_id].messages[0].content).to.equal @new_content
|
|
|
|
done()
|