mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-08 00:29:04 +02:00
Merge pull request #28544 from overleaf/ac-some-web-esm-migration-4
[web] Convert some Features files to ES modules (part 4) GitOrigin-RevId: cf11a7584e39c4d4de08e2f924240e488a4066c4
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { vi } from 'vitest'
|
||||
import sinon from 'sinon'
|
||||
|
||||
const modulePath =
|
||||
'../../../../app/src/Features/SystemMessages/SystemMessageManager.mjs'
|
||||
|
||||
describe('SystemMessageManager', function () {
|
||||
beforeEach(async function (ctx) {
|
||||
ctx.messages = ['messages-stub']
|
||||
ctx.SystemMessage = {
|
||||
find: sinon.stub().returns({
|
||||
exec: sinon.stub().resolves(ctx.messages),
|
||||
}),
|
||||
}
|
||||
|
||||
vi.doMock('../../../../app/src/models/SystemMessage', () => ({
|
||||
SystemMessage: ctx.SystemMessage,
|
||||
}))
|
||||
|
||||
ctx.SystemMessageManager = (await import(modulePath)).default
|
||||
})
|
||||
|
||||
it('should look the messages up in the database on import', function (ctx) {
|
||||
sinon.assert.called(ctx.SystemMessage.find)
|
||||
})
|
||||
|
||||
describe('getMessage', function () {
|
||||
beforeEach(function (ctx) {
|
||||
ctx.SystemMessageManager._cachedMessages = ctx.messages
|
||||
ctx.result = ctx.SystemMessageManager.getMessages()
|
||||
})
|
||||
|
||||
it('should return the messages', function (ctx) {
|
||||
ctx.result.should.equal(ctx.messages)
|
||||
})
|
||||
})
|
||||
|
||||
describe('clearMessages', function () {
|
||||
beforeEach(function (ctx) {
|
||||
ctx.SystemMessage.deleteMany = sinon.stub().returns({
|
||||
exec: sinon.stub().resolves(),
|
||||
})
|
||||
ctx.SystemMessageManager.promises.clearMessages()
|
||||
})
|
||||
|
||||
it('should remove the messages from the database', function (ctx) {
|
||||
ctx.SystemMessage.deleteMany.calledWith({}).should.equal(true)
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user