SystemMessageManagerTests.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /* eslint-disable
  2. max-len,
  3. no-return-assign,
  4. no-unused-vars,
  5. */
  6. // TODO: This file was created by bulk-decaffeinate.
  7. // Fix any style issues and re-enable lint.
  8. /*
  9. * decaffeinate suggestions:
  10. * DS102: Remove unnecessary code created because of implicit returns
  11. * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
  12. */
  13. const SandboxedModule = require('sandboxed-module')
  14. const assert = require('assert')
  15. require('chai').should()
  16. const sinon = require('sinon')
  17. const modulePath = require('path').join(
  18. __dirname,
  19. '../../../../app/src/Features/SystemMessages/SystemMessageManager.js'
  20. )
  21. describe('SystemMessageManager', function() {
  22. beforeEach(function() {
  23. this.messages = ['messages-stub']
  24. this.SystemMessage = {
  25. find: sinon.stub().yields(null, this.messages)
  26. }
  27. this.SystemMessageManager = SandboxedModule.require(modulePath, {
  28. globals: {
  29. console: console
  30. },
  31. requires: {
  32. '../../models/SystemMessage': { SystemMessage: this.SystemMessage }
  33. }
  34. })
  35. return (this.callback = sinon.stub())
  36. })
  37. it('should look the messages up in the database on import', function() {
  38. sinon.assert.called(this.SystemMessage.find)
  39. })
  40. describe('getMessage', function() {
  41. beforeEach(function() {
  42. this.SystemMessageManager._cachedMessages = this.messages
  43. return this.SystemMessageManager.getMessages(this.callback)
  44. })
  45. it('should return the messages', function() {
  46. return this.callback.calledWith(null, this.messages).should.equal(true)
  47. })
  48. })
  49. describe('clearMessages', function() {
  50. beforeEach(function() {
  51. this.SystemMessage.remove = sinon.stub().callsArg(1)
  52. return this.SystemMessageManager.clearMessages(this.callback)
  53. })
  54. it('should remove the messages from the database', function() {
  55. return this.SystemMessage.remove.calledWith({}).should.equal(true)
  56. })
  57. it('should return the callback', function() {
  58. return this.callback.called.should.equal(true)
  59. })
  60. })
  61. })