Merge pull request #30312 from overleaf/mj-mock-web-api-async

[document-updater] Remove callbacks from MockWebApi

GitOrigin-RevId: 0189d5735f3e90160e593fb04043a10b1e922685
This commit is contained in:
Mathias Jakobsen
2025-12-18 09:05:55 +00:00
committed by Copybot
parent ea4dcd4452
commit 82cb0e2839
3 changed files with 40 additions and 75 deletions
@@ -147,14 +147,7 @@ describe('Getting a document', function () {
describe('when the web api returns an error', function () {
before(function () {
sinon
.stub(MockWebApi, 'getDocument')
.callsFake((projectId, docId, callback) => {
if (callback == null) {
callback = function () {}
}
callback(new Error('oops'))
})
sinon.stub(MockWebApi, 'getDocument').rejects(new Error('oops'))
})
after(function () {
@@ -173,14 +166,11 @@ describe('Getting a document', function () {
describe('when the web api http request takes a long time', function () {
before(function (done) {
this.timeout = 10000
sinon
.stub(MockWebApi, 'getDocument')
.callsFake((projectId, docId, callback) => {
if (callback == null) {
callback = function () {}
}
setTimeout(callback, 30000)
sinon.stub(MockWebApi, 'getDocument').returns(
new Promise(resolve => {
setTimeout(() => resolve(null), 30000)
})
)
done()
})