2018-12-20 14:14:05 -05:00
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
const {ObjectId} = require("../../../app/js/mongojs");
|
|
|
|
const { expect } = require("chai");
|
|
|
|
const crypto = require("crypto");
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
const ChatClient = require("./helpers/ChatClient");
|
|
|
|
const ChatApp = require("./helpers/ChatApp");
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
describe("Deleting a thread", function() {
|
|
|
|
before(function(done) {
|
|
|
|
this.project_id = ObjectId().toString();
|
|
|
|
this.user_id = ObjectId().toString();
|
|
|
|
return ChatApp.ensureRunning(done);
|
|
|
|
});
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
return describe("with a thread that is deleted", function() {
|
|
|
|
before(function(done) {
|
|
|
|
this.thread_id = ObjectId().toString();
|
|
|
|
this.content = "deleted thread message";
|
|
|
|
return ChatClient.sendMessage(this.project_id, this.thread_id, this.user_id, this.content, (error, response, body) => {
|
|
|
|
expect(error).to.be.null;
|
|
|
|
expect(response.statusCode).to.equal(201);
|
|
|
|
return ChatClient.deleteThread(this.project_id, this.thread_id, (error, response, body) => {
|
|
|
|
expect(error).to.be.null;
|
|
|
|
expect(response.statusCode).to.equal(204);
|
|
|
|
return done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:05 -05:00
|
|
|
return it("should then not list the thread for the project", function(done) {
|
|
|
|
return ChatClient.getThreads(this.project_id, (error, response, threads) => {
|
|
|
|
expect(error).to.be.null;
|
|
|
|
expect(response.statusCode).to.equal(200);
|
|
|
|
expect(Object.keys(threads).length).to.equal(0);
|
|
|
|
return done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|