|
|
@@ -63,7 +63,7 @@ describe('UpdateMerger :', function () {
|
|
|
|
|
|
this.EditorController = {
|
|
|
promises: {
|
|
|
- deleteEntityWithPath: sinon.stub().resolves(),
|
|
|
+ deleteEntityWithPath: sinon.stub().resolves(new ObjectId()),
|
|
|
upsertDocWithPath: sinon
|
|
|
.stub()
|
|
|
.resolves({ doc: this.doc, folder: this.folder }),
|
|
|
@@ -117,7 +117,7 @@ describe('UpdateMerger :', function () {
|
|
|
binary: false,
|
|
|
encoding: 'utf-8',
|
|
|
})
|
|
|
- await this.UpdateMerger.promises.mergeUpdate(
|
|
|
+ this.mergeUpdateResult = await this.UpdateMerger.promises.mergeUpdate(
|
|
|
this.userId,
|
|
|
this.projectId,
|
|
|
this.docPath,
|
|
|
@@ -145,12 +145,17 @@ describe('UpdateMerger :', function () {
|
|
|
it('removes the temp file from disk', function () {
|
|
|
expect(this.fsPromises.unlink).to.have.been.calledWith(this.fsPath)
|
|
|
})
|
|
|
+
|
|
|
+ it('returns the entity id and rev', function () {
|
|
|
+ expect(this.mergeUpdateResult.entityId).to.be.instanceOf(ObjectId)
|
|
|
+ expect(this.mergeUpdateResult.rev).to.equal(2)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('file updates for a new file ', function () {
|
|
|
beforeEach(async function () {
|
|
|
this.FileTypeManager.promises.getType.resolves({ binary: true })
|
|
|
- await this.UpdateMerger.promises.mergeUpdate(
|
|
|
+ this.mergeUpdateResult = await this.UpdateMerger.promises.mergeUpdate(
|
|
|
this.userId,
|
|
|
this.projectId,
|
|
|
this.filePath,
|
|
|
@@ -179,6 +184,11 @@ describe('UpdateMerger :', function () {
|
|
|
it('removes the temp file from disk', function () {
|
|
|
expect(this.fsPromises.unlink).to.have.been.calledWith(this.fsPath)
|
|
|
})
|
|
|
+
|
|
|
+ it('returns the entity id and rev', function () {
|
|
|
+ expect(this.mergeUpdateResult.entityId).to.be.instanceOf(ObjectId)
|
|
|
+ expect(this.mergeUpdateResult.rev).to.equal(6)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('doc updates for an existing doc', function () {
|
|
|
@@ -187,7 +197,7 @@ describe('UpdateMerger :', function () {
|
|
|
binary: false,
|
|
|
encoding: 'utf-8',
|
|
|
})
|
|
|
- await this.UpdateMerger.promises.mergeUpdate(
|
|
|
+ this.mergeUpdateResult = await this.UpdateMerger.promises.mergeUpdate(
|
|
|
this.userId,
|
|
|
this.projectId,
|
|
|
this.existingDocPath,
|
|
|
@@ -215,12 +225,17 @@ describe('UpdateMerger :', function () {
|
|
|
it('removes the temp file from disk', function () {
|
|
|
expect(this.fsPromises.unlink).to.have.been.calledWith(this.fsPath)
|
|
|
})
|
|
|
+
|
|
|
+ it('returns the entity id and rev', function () {
|
|
|
+ expect(this.mergeUpdateResult.entityId).to.be.instanceOf(ObjectId)
|
|
|
+ expect(this.mergeUpdateResult.rev).to.equal(2)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('file updates for an existing file', function () {
|
|
|
beforeEach(async function () {
|
|
|
this.FileTypeManager.promises.getType.resolves({ binary: true })
|
|
|
- await this.UpdateMerger.promises.mergeUpdate(
|
|
|
+ this.mergeUpdateResult = await this.UpdateMerger.promises.mergeUpdate(
|
|
|
this.userId,
|
|
|
this.projectId,
|
|
|
this.existingFilePath,
|
|
|
@@ -249,13 +264,18 @@ describe('UpdateMerger :', function () {
|
|
|
it('removes the temp file from disk', function () {
|
|
|
expect(this.fsPromises.unlink).to.have.been.calledWith(this.fsPath)
|
|
|
})
|
|
|
+
|
|
|
+ it('returns the entity id and rev', function () {
|
|
|
+ expect(this.mergeUpdateResult.entityId).to.be.instanceOf(ObjectId)
|
|
|
+ expect(this.mergeUpdateResult.rev).to.equal(6)
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('file updates for an existing doc', function () {
|
|
|
beforeEach(async function () {
|
|
|
this.FileTypeManager.promises.getType.resolves({ binary: true })
|
|
|
- await this.UpdateMerger.promises.mergeUpdate(
|
|
|
+ this.mergeUpdateResult = await this.UpdateMerger.promises.mergeUpdate(
|
|
|
this.userId,
|
|
|
this.projectId,
|
|
|
this.existingDocPath,
|
|
|
@@ -284,12 +304,17 @@ describe('UpdateMerger :', function () {
|
|
|
it('removes the temp file from disk', function () {
|
|
|
expect(this.fsPromises.unlink).to.have.been.calledWith(this.fsPath)
|
|
|
})
|
|
|
+
|
|
|
+ it('returns the entity id and rev', function () {
|
|
|
+ expect(this.mergeUpdateResult.entityId).to.be.instanceOf(ObjectId)
|
|
|
+ expect(this.mergeUpdateResult.rev).to.equal(6)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('doc updates for an existing file', function () {
|
|
|
beforeEach(async function () {
|
|
|
this.FileTypeManager.promises.getType.resolves({ binary: true })
|
|
|
- await this.UpdateMerger.promises.mergeUpdate(
|
|
|
+ this.mergeUpdateResult = await this.UpdateMerger.promises.mergeUpdate(
|
|
|
this.userId,
|
|
|
this.projectId,
|
|
|
this.existingFilePath,
|
|
|
@@ -323,11 +348,16 @@ describe('UpdateMerger :', function () {
|
|
|
it('removes the temp file from disk', function () {
|
|
|
expect(this.fsPromises.unlink).to.have.been.calledWith(this.fsPath)
|
|
|
})
|
|
|
+
|
|
|
+ it('returns the entity id and rev', function () {
|
|
|
+ expect(this.mergeUpdateResult.entityId).to.be.instanceOf(ObjectId)
|
|
|
+ expect(this.mergeUpdateResult.rev).to.equal(6)
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe('deleteUpdate', function () {
|
|
|
beforeEach(async function () {
|
|
|
- await this.UpdateMerger.promises.deleteUpdate(
|
|
|
+ this.deleteUpdateResult = await this.UpdateMerger.promises.deleteUpdate(
|
|
|
this.userId,
|
|
|
this.projectId,
|
|
|
this.docPath,
|
|
|
@@ -335,6 +365,10 @@ describe('UpdateMerger :', function () {
|
|
|
)
|
|
|
})
|
|
|
|
|
|
+ afterEach(function () {
|
|
|
+ delete this.deleteUpdateResult
|
|
|
+ })
|
|
|
+
|
|
|
it('should delete the entity in the editor controller', function () {
|
|
|
expect(
|
|
|
this.EditorController.promises.deleteEntityWithPath
|
|
|
@@ -345,5 +379,9 @@ describe('UpdateMerger :', function () {
|
|
|
this.userId
|
|
|
)
|
|
|
})
|
|
|
+
|
|
|
+ it('returns the entity id', function () {
|
|
|
+ expect(this.deleteUpdateResult).to.be.instanceOf(ObjectId)
|
|
|
+ })
|
|
|
})
|
|
|
})
|