From b6c93c718d77e0cba2ad96b6e4445afe8a772bdd Mon Sep 17 00:00:00 2001 From: James Allen Date: Thu, 1 Dec 2016 16:50:55 +0000 Subject: [PATCH] Update TrackChangesManagerTests -> HistoryManagerTests --- .../HistoryManagerTests.coffee} | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) rename services/document-updater/test/unit/coffee/{TrackChangesManager/TrackChangesManagerTests.coffee => HistoryManager/HistoryManagerTests.coffee} (68%) diff --git a/services/document-updater/test/unit/coffee/TrackChangesManager/TrackChangesManagerTests.coffee b/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee similarity index 68% rename from services/document-updater/test/unit/coffee/TrackChangesManager/TrackChangesManagerTests.coffee rename to services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee index 03106e2c2e..c33a18d4e6 100644 --- a/services/document-updater/test/unit/coffee/TrackChangesManager/TrackChangesManagerTests.coffee +++ b/services/document-updater/test/unit/coffee/HistoryManager/HistoryManagerTests.coffee @@ -1,11 +1,11 @@ SandboxedModule = require('sandboxed-module') sinon = require('sinon') require('chai').should() -modulePath = require('path').join __dirname, '../../../../app/js/TrackChangesManager' +modulePath = require('path').join __dirname, '../../../../app/js/HistoryManager' -describe "TrackChangesManager", -> +describe "HistoryManager", -> beforeEach -> - @TrackChangesManager = SandboxedModule.require modulePath, requires: + @HistoryManager = SandboxedModule.require modulePath, requires: "request": @request = {} "settings-sharelatex": @Settings = {} "logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub() } @@ -22,7 +22,7 @@ describe "TrackChangesManager", -> describe "successfully", -> beforeEach -> @request.post = sinon.stub().callsArgWith(1, null, statusCode: 204) - @TrackChangesManager.flushDocChanges @project_id, @doc_id, @callback + @HistoryManager.flushDocChanges @project_id, @doc_id, @callback it "should send a request to the track changes api", -> @request.post @@ -35,7 +35,7 @@ describe "TrackChangesManager", -> describe "when the track changes api returns an error", -> beforeEach -> @request.post = sinon.stub().callsArgWith(1, null, statusCode: 500) - @TrackChangesManager.flushDocChanges @project_id, @doc_id, @callback + @HistoryManager.flushDocChanges @project_id, @doc_id, @callback it "should return the callback with an error", -> @callback.calledWith(new Error("track changes api return non-success code: 500")).should.equal true @@ -43,12 +43,12 @@ describe "TrackChangesManager", -> describe "pushUncompressedHistoryOps", -> beforeEach -> @ops = ["mock-ops"] - @TrackChangesManager.flushDocChanges = sinon.stub().callsArg(2) + @HistoryManager.flushDocChanges = sinon.stub().callsArg(2) describe "pushing the op", -> beforeEach -> @WebRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1) - @TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback + @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback it "should push the ops into redis", -> @WebRedisManager.pushUncompressedHistoryOps @@ -59,16 +59,16 @@ describe "TrackChangesManager", -> @callback.called.should.equal true it "should not try to flush the op", -> - @TrackChangesManager.flushDocChanges.called.should.equal false + @HistoryManager.flushDocChanges.called.should.equal false describe "when we hit a multiple of FLUSH_EVERY_N_OPS ops", -> beforeEach -> @WebRedisManager.pushUncompressedHistoryOps = - sinon.stub().callsArgWith(3, null, 2 * @TrackChangesManager.FLUSH_EVERY_N_OPS) - @TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback + sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS) + @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback it "should tell the track changes api to flush", -> - @TrackChangesManager.flushDocChanges + @HistoryManager.flushDocChanges .calledWith(@project_id, @doc_id) .should.equal true @@ -76,20 +76,20 @@ describe "TrackChangesManager", -> beforeEach -> @ops = ["op1", "op2", "op3"] @WebRedisManager.pushUncompressedHistoryOps = - sinon.stub().callsArgWith(3, null, 2 * @TrackChangesManager.FLUSH_EVERY_N_OPS + 1) - @TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback + sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS + 1) + @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback it "should tell the track changes api to flush", -> - @TrackChangesManager.flushDocChanges + @HistoryManager.flushDocChanges .calledWith(@project_id, @doc_id) .should.equal true - describe "when TrackChangesManager errors", -> + describe "when HistoryManager errors", -> beforeEach -> @WebRedisManager.pushUncompressedHistoryOps = - sinon.stub().callsArgWith(3, null, 2 * @TrackChangesManager.FLUSH_EVERY_N_OPS) - @TrackChangesManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops")) - @TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback + sinon.stub().callsArgWith(3, null, 2 * @HistoryManager.FLUSH_EVERY_N_OPS) + @HistoryManager.flushDocChanges = sinon.stub().callsArgWith(2, @error = new Error("oops")) + @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, @ops, @callback it "should log out the error", -> @logger.error @@ -104,7 +104,7 @@ describe "TrackChangesManager", -> describe "with no ops", -> beforeEach -> @WebRedisManager.pushUncompressedHistoryOps = sinon.stub().callsArgWith(3, null, 1) - @TrackChangesManager.pushUncompressedHistoryOps @project_id, @doc_id, [], @callback + @HistoryManager.pushUncompressedHistoryOps @project_id, @doc_id, [], @callback it "should not call WebRedisManager.pushUncompressedHistoryOps", -> @WebRedisManager.pushUncompressedHistoryOps.called.should.equal false