2020-08-19 08:00:01 -04:00
|
|
|
const { ObjectId } = require('../../../app/js/mongodb')
|
2018-12-20 14:14:11 -05:00
|
|
|
const { expect } = require('chai')
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2018-12-20 14:14:11 -05:00
|
|
|
const ChatClient = require('./helpers/ChatClient')
|
|
|
|
const ChatApp = require('./helpers/ChatApp')
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2022-01-10 04:29:32 -05:00
|
|
|
describe('Deleting a thread', async function () {
|
|
|
|
before(async function () {
|
2018-12-20 14:14:11 -05:00
|
|
|
this.project_id = ObjectId().toString()
|
|
|
|
this.user_id = ObjectId().toString()
|
2022-01-10 04:29:32 -05:00
|
|
|
await ChatApp.ensureRunning()
|
2018-12-20 14:14:11 -05:00
|
|
|
})
|
2017-01-24 09:44:32 -05:00
|
|
|
|
2022-01-10 04:29:32 -05:00
|
|
|
describe('with a thread that is deleted', async function () {
|
|
|
|
before(async function () {
|
2018-12-20 14:14:11 -05:00
|
|
|
this.thread_id = ObjectId().toString()
|
|
|
|
this.content = 'deleted thread message'
|
2022-01-10 04:29:32 -05:00
|
|
|
const { response } = await ChatClient.sendMessage(
|
2018-12-20 14:14:11 -05:00
|
|
|
this.project_id,
|
|
|
|
this.thread_id,
|
|
|
|
this.user_id,
|
2022-01-10 04:29:32 -05:00
|
|
|
this.content
|
2018-12-20 14:14:11 -05:00
|
|
|
)
|
2022-01-10 04:29:32 -05:00
|
|
|
expect(response.statusCode).to.equal(201)
|
|
|
|
const { response: response2 } = await ChatClient.deleteThread(
|
|
|
|
this.project_id,
|
|
|
|
this.thread_id
|
|
|
|
)
|
|
|
|
expect(response2.statusCode).to.equal(204)
|
2018-12-20 14:14:11 -05:00
|
|
|
})
|
|
|
|
|
2022-01-10 04:29:32 -05:00
|
|
|
it('should then not list the thread for the project', async function () {
|
|
|
|
const { response, body: threads } = await ChatClient.getThreads(
|
|
|
|
this.project_id
|
|
|
|
)
|
|
|
|
expect(response.statusCode).to.equal(200)
|
|
|
|
expect(Object.keys(threads).length).to.equal(0)
|
2018-12-20 14:14:11 -05:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|