|
|
@@ -31,7 +31,7 @@ describe('ClsiStateManager', function () {
|
|
|
})
|
|
|
|
|
|
describe('computeHash', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.docs = [
|
|
|
{ path: '/main.tex', doc: { _id: 'doc-id-1' } },
|
|
|
{ path: '/folder/sub.tex', doc: { _id: 'doc-id-2' } },
|
|
|
@@ -48,30 +48,17 @@ describe('ClsiStateManager', function () {
|
|
|
]
|
|
|
this.ProjectEntityHandler.getAllEntitiesFromProject = sinon
|
|
|
.stub()
|
|
|
- .callsArgWith(1, null, this.docs, this.files)
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash0 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
+ .returns({ docs: this.docs, files: this.files })
|
|
|
+ this.hash0 = this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
})
|
|
|
|
|
|
describe('with a sample project', function () {
|
|
|
- beforeEach(function () {
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- this.callback
|
|
|
- )
|
|
|
- })
|
|
|
+ beforeEach(function () {})
|
|
|
|
|
|
- it('should call the callback with a hash value', function () {
|
|
|
- return this.callback
|
|
|
- .calledWith(null, '21b1ab73aa3892bec452baf8ffa0956179e1880f')
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).to.equal('21b1ab73aa3892bec452baf8ffa0956179e1880f')
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -82,213 +69,135 @@ describe('ClsiStateManager', function () {
|
|
|
this.files[1],
|
|
|
this.files[0],
|
|
|
])
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- this.callback
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with the same hash value', function () {
|
|
|
- return this.callback.calledWith(null, this.hash0).should.equal(true)
|
|
|
+ it('should return the same hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when a doc is renamed', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.docs[0].path = '/new.tex'
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when a file is renamed', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.files[0].path = '/newfigure.pdf'
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when a doc is added', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.docs.push({ path: '/newdoc.tex', doc: { _id: 'newdoc-id' } })
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when a file is added', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.files.push({
|
|
|
path: '/newfile.tex',
|
|
|
file: { _id: 'newfile-id', rev: 123 },
|
|
|
})
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when a doc is removed', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.docs.pop()
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when a file is removed', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.files.pop()
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe("when a file's revision is updated", function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.files[0].file.rev++
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe("when a file's date is updated", function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.files[0].file.created = 'zzzzzz'
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the compile options are changed', function () {
|
|
|
- beforeEach(function (done) {
|
|
|
+ beforeEach(function () {
|
|
|
this.options.draft = !this.options.draft
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- (err, hash) => {
|
|
|
- this.hash1 = hash
|
|
|
- return done()
|
|
|
- }
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with a different hash value', function () {
|
|
|
- return this.callback
|
|
|
- .neverCalledWith(null, this.hash0)
|
|
|
- .should.equal(true)
|
|
|
+ it('should return a different hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).not.to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe('when the isAutoCompile option is changed', function () {
|
|
|
beforeEach(function () {
|
|
|
this.options.isAutoCompile = !this.options.isAutoCompile
|
|
|
- return this.ClsiStateManager.computeHash(
|
|
|
- this.project,
|
|
|
- this.options,
|
|
|
- this.callback
|
|
|
- )
|
|
|
})
|
|
|
|
|
|
- it('should call the callback with the same hash value', function () {
|
|
|
- return this.callback.calledWith(null, this.hash0).should.equal(true)
|
|
|
+ it('should return the same hash value', function () {
|
|
|
+ expect(
|
|
|
+ this.ClsiStateManager.computeHash(this.project, this.options)
|
|
|
+ ).to.equal(this.hash0)
|
|
|
})
|
|
|
})
|
|
|
})
|