Merge pull request #17782 from overleaf/mj-project-history-merge-test-fix

[project-history] Fix project history unit test

GitOrigin-RevId: 4a8c5c2337ee8a06d46638ceba18d4a0f8742b42
This commit is contained in:
Mathias Jakobsen 2024-04-05 11:57:02 +01:00 committed by Copybot
parent 815c29cf82
commit 7d7e5c9a8f

View file

@ -123,18 +123,16 @@ describe('SnapshotManager', function () {
describe('of a text file with no tracked changes', function () { describe('of a text file with no tracked changes', function () {
beforeEach(function (done) { beforeEach(function (done) {
this.HistoryStoreManager.getBlobStore.withArgs(this.historyId).returns({ this.HistoryStoreManager.getBlobStore.withArgs(this.historyId).returns({
getString: BPromise.promisify( getString: (this.getString = sinon.stub().resolves(
(this.getString = sinon.stub().yields( `\
null,
`\
Hello world Hello world
One two three One two three
Four five six\ Four five six\
`.replace(/^\t/g, '') `.replace(/^\t/g, '')
)) )),
), getObject: sinon.stub().rejects(),
}) })
this.SnapshotManager.getFileSnapshotStream( this.SnapshotManager.getFileSnapshotStream(
this.projectId, this.projectId,
@ -185,7 +183,8 @@ Seven eight nine\
this.HistoryStoreManager.getBlobStore this.HistoryStoreManager.getBlobStore
.withArgs(this.historyId) .withArgs(this.historyId)
.returns({ .returns({
getString: BPromise.promisify(sinon.stub().throws(this.error)), getString: sinon.stub().rejects(this.error),
getObject: sinon.stub().rejects(this.error),
}) })
}) })
@ -503,7 +502,8 @@ Four five six\
beforeEach(function () { beforeEach(function () {
this.error = new Error('ESOCKETTIMEDOUT') this.error = new Error('ESOCKETTIMEDOUT')
this.HistoryStoreManager.getBlobStore.withArgs(this.historyId).returns({ this.HistoryStoreManager.getBlobStore.withArgs(this.historyId).returns({
getString: BPromise.promisify(sinon.stub().yields(this.error)), getString: sinon.stub().rejects(this.error),
getObject: sinon.stub().resolves(),
}) })
}) })
@ -571,18 +571,16 @@ Four five six\
}) })
this.HistoryStoreManager.getBlobStore.withArgs(this.historyId).returns({ this.HistoryStoreManager.getBlobStore.withArgs(this.historyId).returns({
getString: BPromise.promisify( getString: (this.getString = sinon.stub().resolves(
(this.getString = sinon.stub().yields( `\
null,
`\
Hello world Hello world
One two three One two three
Four five six\ Four five six\
`.replace(/^\t/g, '') `.replace(/^\t/g, '')
)) )),
), getObject: sinon.stub().rejects(),
}) })
this.SnapshotManager.getLatestSnapshot( this.SnapshotManager.getLatestSnapshot(
this.projectId, this.projectId,