|
@@ -1,17 +1,4 @@
|
|
|
-/* eslint-disable
|
|
|
|
|
- max-len,
|
|
|
|
|
- no-return-assign,
|
|
|
|
|
- no-unused-vars,
|
|
|
|
|
-*/
|
|
|
|
|
-// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
|
-// Fix any style issues and re-enable lint.
|
|
|
|
|
-/*
|
|
|
|
|
- * decaffeinate suggestions:
|
|
|
|
|
- * DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
|
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
|
- */
|
|
|
|
|
const SandboxedModule = require('sandboxed-module')
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
-const assert = require('assert')
|
|
|
|
|
const sinon = require('sinon')
|
|
const sinon = require('sinon')
|
|
|
const modulePath = require('path').join(
|
|
const modulePath = require('path').join(
|
|
|
__dirname,
|
|
__dirname,
|
|
@@ -22,14 +9,15 @@ describe('SystemMessageManager', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.messages = ['messages-stub']
|
|
this.messages = ['messages-stub']
|
|
|
this.SystemMessage = {
|
|
this.SystemMessage = {
|
|
|
- find: sinon.stub().yields(null, this.messages),
|
|
|
|
|
|
|
+ find: sinon.stub().returns({
|
|
|
|
|
+ exec: sinon.stub().resolves(this.messages),
|
|
|
|
|
+ }),
|
|
|
}
|
|
}
|
|
|
this.SystemMessageManager = SandboxedModule.require(modulePath, {
|
|
this.SystemMessageManager = SandboxedModule.require(modulePath, {
|
|
|
requires: {
|
|
requires: {
|
|
|
'../../models/SystemMessage': { SystemMessage: this.SystemMessage },
|
|
'../../models/SystemMessage': { SystemMessage: this.SystemMessage },
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
- return (this.callback = sinon.stub())
|
|
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should look the messages up in the database on import', function () {
|
|
it('should look the messages up in the database on import', function () {
|
|
@@ -39,26 +27,24 @@ describe('SystemMessageManager', function () {
|
|
|
describe('getMessage', function () {
|
|
describe('getMessage', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
this.SystemMessageManager._cachedMessages = this.messages
|
|
this.SystemMessageManager._cachedMessages = this.messages
|
|
|
- return this.SystemMessageManager.getMessages(this.callback)
|
|
|
|
|
|
|
+ this.result = this.SystemMessageManager.getMessages()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should return the messages', function () {
|
|
it('should return the messages', function () {
|
|
|
- return this.callback.calledWith(null, this.messages).should.equal(true)
|
|
|
|
|
|
|
+ this.result.should.equal(this.messages)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('clearMessages', function () {
|
|
describe('clearMessages', function () {
|
|
|
beforeEach(function () {
|
|
beforeEach(function () {
|
|
|
- this.SystemMessage.deleteMany = sinon.stub().callsArg(1)
|
|
|
|
|
- return this.SystemMessageManager.clearMessages(this.callback)
|
|
|
|
|
|
|
+ this.SystemMessage.deleteMany = sinon.stub().returns({
|
|
|
|
|
+ exec: sinon.stub().resolves(),
|
|
|
|
|
+ })
|
|
|
|
|
+ this.SystemMessageManager.promises.clearMessages()
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
it('should remove the messages from the database', function () {
|
|
it('should remove the messages from the database', function () {
|
|
|
- return this.SystemMessage.deleteMany.calledWith({}).should.equal(true)
|
|
|
|
|
- })
|
|
|
|
|
-
|
|
|
|
|
- it('should return the callback', function () {
|
|
|
|
|
- return this.callback.called.should.equal(true)
|
|
|
|
|
|
|
+ this.SystemMessage.deleteMany.calledWith({}).should.equal(true)
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|