Merge pull request #29967 from overleaf/ar/web-remove-mocha-unit-tests
[web] remove mocha unit tests GitOrigin-RevId: eda753af3470dbd1f385cb0bc3f06d78ade8a764
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { expect, vi } from 'vitest'
|
||||
import sinon from 'sinon'
|
||||
import MockResponse from '../helpers/MockResponse.js'
|
||||
import MockResponse from '../helpers/MockResponse.mjs'
|
||||
const modulePath = '../../../../app/src/Features/Metadata/MetaController.mjs'
|
||||
|
||||
describe('MetaController', function () {
|
||||
@@ -45,7 +45,7 @@ describe('MetaController', function () {
|
||||
.resolves(projectMeta)
|
||||
|
||||
const req = { params: { project_id: 'project-id' } }
|
||||
const res = new MockResponse()
|
||||
const res = new MockResponse(vi)
|
||||
const next = sinon.stub()
|
||||
|
||||
await ctx.MetadataController.getMetadata(req, res, next)
|
||||
@@ -53,7 +53,8 @@ describe('MetaController', function () {
|
||||
ctx.MetaHandler.promises.getAllMetaForProject.should.have.been.calledWith(
|
||||
'project-id'
|
||||
)
|
||||
res.json.should.have.been.calledOnceWith({
|
||||
expect(res.json).toHaveBeenCalledTimes(1)
|
||||
expect(res.json).toHaveBeenCalledWith({
|
||||
projectId: 'project-id',
|
||||
projectMeta,
|
||||
})
|
||||
@@ -66,7 +67,7 @@ describe('MetaController', function () {
|
||||
.throws(new Error('woops'))
|
||||
|
||||
const req = { params: { project_id: 'project-id' } }
|
||||
const res = new MockResponse()
|
||||
const res = new MockResponse(vi)
|
||||
const next = sinon.stub()
|
||||
|
||||
await ctx.MetadataController.getMetadata(req, res, next)
|
||||
@@ -74,7 +75,7 @@ describe('MetaController', function () {
|
||||
ctx.MetaHandler.promises.getAllMetaForProject.should.have.been.calledWith(
|
||||
'project-id'
|
||||
)
|
||||
res.json.should.not.have.been.called
|
||||
expect(res.json).not.toHaveBeenCalled()
|
||||
next.should.have.been.calledWithMatch(error => error instanceof Error)
|
||||
})
|
||||
})
|
||||
@@ -93,7 +94,7 @@ describe('MetaController', function () {
|
||||
params: { project_id: 'project-id', doc_id: 'doc-id' },
|
||||
body: { broadcast: true },
|
||||
}
|
||||
const res = new MockResponse()
|
||||
const res = new MockResponse(vi)
|
||||
const next = sinon.stub()
|
||||
|
||||
await ctx.MetadataController.broadcastMetadataForDoc(req, res, next)
|
||||
@@ -101,8 +102,9 @@ describe('MetaController', function () {
|
||||
ctx.MetaHandler.promises.getMetaForDoc.should.have.been.calledWith(
|
||||
'project-id'
|
||||
)
|
||||
res.json.should.not.have.been.called
|
||||
res.sendStatus.should.have.been.calledOnceWith(200)
|
||||
expect(res.json).not.toHaveBeenCalled()
|
||||
expect(res.sendStatus).toHaveBeenCalledTimes(1)
|
||||
expect(res.sendStatus).toHaveBeenCalledWith(200)
|
||||
next.should.not.have.been.called
|
||||
|
||||
ctx.EditorRealTimeController.emitToRoom.should.have.been.calledOnce
|
||||
@@ -127,7 +129,7 @@ describe('MetaController', function () {
|
||||
params: { project_id: 'project-id', doc_id: 'doc-id' },
|
||||
body: { broadcast: false },
|
||||
}
|
||||
const res = new MockResponse()
|
||||
const res = new MockResponse(vi)
|
||||
const next = sinon.stub()
|
||||
|
||||
await ctx.MetadataController.broadcastMetadataForDoc(req, res, next)
|
||||
@@ -136,7 +138,8 @@ describe('MetaController', function () {
|
||||
'project-id'
|
||||
)
|
||||
ctx.EditorRealTimeController.emitToRoom.should.not.have.been.called
|
||||
res.json.should.have.been.calledOnceWith({
|
||||
expect(res.json).toHaveBeenCalledTimes(1)
|
||||
expect(res.json).toHaveBeenCalledWith({
|
||||
docId: 'doc-id',
|
||||
meta: docMeta,
|
||||
})
|
||||
@@ -154,7 +157,7 @@ describe('MetaController', function () {
|
||||
params: { project_id: 'project-id', doc_id: 'doc-id' },
|
||||
body: { broadcast: true },
|
||||
}
|
||||
const res = new MockResponse()
|
||||
const res = new MockResponse(vi)
|
||||
const next = sinon.stub()
|
||||
|
||||
await ctx.MetadataController.broadcastMetadataForDoc(req, res, next)
|
||||
@@ -162,7 +165,7 @@ describe('MetaController', function () {
|
||||
ctx.MetaHandler.promises.getMetaForDoc.should.have.been.calledWith(
|
||||
'project-id'
|
||||
)
|
||||
res.json.should.not.have.been.called
|
||||
expect(res.json).not.toHaveBeenCalled()
|
||||
next.should.have.been.calledWithMatch(error => error instanceof Error)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user