DeletingAThreadTests.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* eslint-disable
  2. max-len,
  3. no-unused-vars,
  4. */
  5. // TODO: This file was created by bulk-decaffeinate.
  6. // Fix any style issues and re-enable lint.
  7. /*
  8. * decaffeinate suggestions:
  9. * DS102: Remove unnecessary code created because of implicit returns
  10. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  11. */
  12. const { ObjectId } = require('../../../app/js/mongojs')
  13. const { expect } = require('chai')
  14. const crypto = require('crypto')
  15. const ChatClient = require('./helpers/ChatClient')
  16. const ChatApp = require('./helpers/ChatApp')
  17. describe('Deleting a thread', function () {
  18. before(function (done) {
  19. this.project_id = ObjectId().toString()
  20. this.user_id = ObjectId().toString()
  21. return ChatApp.ensureRunning(done)
  22. })
  23. return describe('with a thread that is deleted', function () {
  24. before(function (done) {
  25. this.thread_id = ObjectId().toString()
  26. this.content = 'deleted thread message'
  27. return ChatClient.sendMessage(
  28. this.project_id,
  29. this.thread_id,
  30. this.user_id,
  31. this.content,
  32. (error, response, body) => {
  33. expect(error).to.be.null
  34. expect(response.statusCode).to.equal(201)
  35. return ChatClient.deleteThread(
  36. this.project_id,
  37. this.thread_id,
  38. (error, response, body) => {
  39. expect(error).to.be.null
  40. expect(response.statusCode).to.equal(204)
  41. return done()
  42. }
  43. )
  44. }
  45. )
  46. })
  47. return it('should then not list the thread for the project', function (done) {
  48. return ChatClient.getThreads(
  49. this.project_id,
  50. (error, response, threads) => {
  51. expect(error).to.be.null
  52. expect(response.statusCode).to.equal(200)
  53. expect(Object.keys(threads).length).to.equal(0)
  54. return done()
  55. }
  56. )
  57. })
  58. })
  59. })