|
@@ -12,6 +12,7 @@ describe "ClsiStateManager", ->
|
|
|
"../Project/ProjectEntityHandler": @ProjectEntityHandler = {}
|
|
"../Project/ProjectEntityHandler": @ProjectEntityHandler = {}
|
|
|
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub(), warn: sinon.stub() }
|
|
"logger-sharelatex": @logger = { log: sinon.stub(), error: sinon.stub(), warn: sinon.stub() }
|
|
|
@project = "project"
|
|
@project = "project"
|
|
|
|
|
+ @options = {"draft":true,"isAutoCompile":false}
|
|
|
@callback = sinon.stub()
|
|
@callback = sinon.stub()
|
|
|
|
|
|
|
|
describe "computeHash", ->
|
|
describe "computeHash", ->
|
|
@@ -25,24 +26,24 @@ describe "ClsiStateManager", ->
|
|
|
{path: "/folder/fig2.pdf", file: {_id: "file-id-2", rev: 456, created: "bbbbbb"}}
|
|
{path: "/folder/fig2.pdf", file: {_id: "file-id-2", rev: 456, created: "bbbbbb"}}
|
|
|
]
|
|
]
|
|
|
@ProjectEntityHandler.getAllEntitiesFromProject = sinon.stub().callsArgWith(1, null, @docs, @files)
|
|
@ProjectEntityHandler.getAllEntitiesFromProject = sinon.stub().callsArgWith(1, null, @docs, @files)
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash0 = hash
|
|
@hash0 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
|
describe "with a sample project", ->
|
|
describe "with a sample project", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
- @ClsiStateManager.computeHash @project, @callback
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, @callback
|
|
|
|
|
|
|
|
it "should call the callback with a hash value", ->
|
|
it "should call the callback with a hash value", ->
|
|
|
@callback
|
|
@callback
|
|
|
- .calledWith(null, "9c2c2428e4147db63cacabf6f357af483af6551d")
|
|
|
|
|
|
|
+ .calledWith(null, "21b1ab73aa3892bec452baf8ffa0956179e1880f")
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
describe "when the files and docs are in a different order", ->
|
|
describe "when the files and docs are in a different order", ->
|
|
|
beforeEach ->
|
|
beforeEach ->
|
|
|
[@docs[0], @docs[1]] = [@docs[1], @docs[0]]
|
|
[@docs[0], @docs[1]] = [@docs[1], @docs[0]]
|
|
|
[@files[0], @files[1]] = [@files[1], @files[0]]
|
|
[@files[0], @files[1]] = [@files[1], @files[0]]
|
|
|
- @ClsiStateManager.computeHash @project, @callback
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, @callback
|
|
|
|
|
|
|
|
it "should call the callback with the same hash value", ->
|
|
it "should call the callback with the same hash value", ->
|
|
|
@callback
|
|
@callback
|
|
@@ -52,7 +53,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a doc is renamed", ->
|
|
describe "when a doc is renamed", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@docs[0].path = "/new.tex"
|
|
@docs[0].path = "/new.tex"
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -64,7 +65,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a file is renamed", ->
|
|
describe "when a file is renamed", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@files[0].path = "/newfigure.pdf"
|
|
@files[0].path = "/newfigure.pdf"
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -76,7 +77,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a doc is added", ->
|
|
describe "when a doc is added", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@docs.push { path: "/newdoc.tex", doc: {_id: "newdoc-id"}}
|
|
@docs.push { path: "/newdoc.tex", doc: {_id: "newdoc-id"}}
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -88,7 +89,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a file is added", ->
|
|
describe "when a file is added", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@files.push { path: "/newfile.tex", file: {_id: "newfile-id", rev: 123}}
|
|
@files.push { path: "/newfile.tex", file: {_id: "newfile-id", rev: 123}}
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -100,7 +101,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a doc is removed", ->
|
|
describe "when a doc is removed", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@docs.pop()
|
|
@docs.pop()
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -112,7 +113,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a file is removed", ->
|
|
describe "when a file is removed", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@files.pop()
|
|
@files.pop()
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -124,7 +125,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a file's revision is updated", ->
|
|
describe "when a file's revision is updated", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@files[0].file.rev++
|
|
@files[0].file.rev++
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -137,7 +138,7 @@ describe "ClsiStateManager", ->
|
|
|
describe "when a file's date is updated", ->
|
|
describe "when a file's date is updated", ->
|
|
|
beforeEach (done) ->
|
|
beforeEach (done) ->
|
|
|
@files[0].file.created = "zzzzzz"
|
|
@files[0].file.created = "zzzzzz"
|
|
|
- @ClsiStateManager.computeHash @project, (err, hash) =>
|
|
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
@hash1 = hash
|
|
@hash1 = hash
|
|
|
done()
|
|
done()
|
|
|
|
|
|
|
@@ -146,3 +147,25 @@ describe "ClsiStateManager", ->
|
|
|
.neverCalledWith(null, @hash0)
|
|
.neverCalledWith(null, @hash0)
|
|
|
.should.equal true
|
|
.should.equal true
|
|
|
|
|
|
|
|
|
|
+ describe "when the compile options are changed", ->
|
|
|
|
|
+ beforeEach (done) ->
|
|
|
|
|
+ @options.draft = !@options.draft
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, (err, hash) =>
|
|
|
|
|
+ @hash1 = hash
|
|
|
|
|
+ done()
|
|
|
|
|
+
|
|
|
|
|
+ it "should call the callback with a different hash value", ->
|
|
|
|
|
+ @callback
|
|
|
|
|
+ .neverCalledWith(null, @hash0)
|
|
|
|
|
+ .should.equal true
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ describe "when the isAutoCompile option is changed", ->
|
|
|
|
|
+ beforeEach () ->
|
|
|
|
|
+ @options.isAutoCompile = !@options.isAutoCompile
|
|
|
|
|
+ @ClsiStateManager.computeHash @project, @options, @callback
|
|
|
|
|
+
|
|
|
|
|
+ it "should call the callback with the same hash value", ->
|
|
|
|
|
+ @callback
|
|
|
|
|
+ .calledWith(null, @hash0)
|
|
|
|
|
+ .should.equal true
|