Revert "Upgrade to mocha 5.0.1"

This commit is contained in:
Alasdair Smith 2018-02-27 12:25:42 +00:00 committed by GitHub
parent 4524b3c9f6
commit 315587605c
20 changed files with 117 additions and 233 deletions

View file

@ -1,4 +1,4 @@
#!/bin/bash
set -e;
MOCHA="node_modules/.bin/mocha --exit --recursive --reporter spec --timeout 15000"
MOCHA="node_modules/.bin/mocha --recursive --reporter spec --timeout 15000"
$MOCHA "$@"

View file

@ -1,7 +1,7 @@
#!/bin/bash
set -e;
MOCHA="node_modules/.bin/mocha --exit --recursive --reporter spec"
MOCHA="node_modules/.bin/mocha --recursive --reporter spec"
$MOCHA "$@" test/unit/js

View file

@ -1160,11 +1160,6 @@
}
}
},
"browser-stdout": {
"version": "1.3.0",
"from": "browser-stdout@1.3.0",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz"
},
"browserify": {
"version": "14.5.0",
"from": "browserify@>=14.5.0 <15.0.0",
@ -5086,59 +5081,7 @@
"version": "0.9.0",
"from": "grunt-mocha-test@0.9.0",
"resolved": "https://registry.npmjs.org/grunt-mocha-test/-/grunt-mocha-test-0.9.0.tgz",
"dev": true,
"dependencies": {
"commander": {
"version": "2.0.0",
"from": "commander@2.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.0.0.tgz",
"dev": true
},
"glob": {
"version": "3.2.3",
"from": "glob@3.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-3.2.3.tgz",
"dev": true
},
"graceful-fs": {
"version": "2.0.3",
"from": "graceful-fs@>=2.0.0 <2.1.0",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz",
"dev": true
},
"jade": {
"version": "0.26.3",
"from": "jade@0.26.3",
"resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz",
"dev": true,
"dependencies": {
"commander": {
"version": "0.6.1",
"from": "commander@0.6.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz",
"dev": true
},
"mkdirp": {
"version": "0.3.0",
"from": "mkdirp@0.3.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz",
"dev": true
}
}
},
"mkdirp": {
"version": "0.3.5",
"from": "mkdirp@0.3.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz",
"dev": true
},
"mocha": {
"version": "1.17.1",
"from": "mocha@>=1.17.1 <1.18.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-1.17.1.tgz",
"dev": true
}
}
"dev": true
},
"grunt-newer": {
"version": "1.3.0",
@ -5318,11 +5261,6 @@
"from": "hawk@>=6.0.2 <6.1.0",
"resolved": "https://registry.npmjs.org/hawk/-/hawk-6.0.2.tgz"
},
"he": {
"version": "1.1.1",
"from": "he@1.1.1",
"resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz"
},
"heapdump": {
"version": "0.3.9",
"from": "heapdump@>=0.3.7 <0.4.0",
@ -8060,49 +7998,46 @@
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz"
},
"mocha": {
"version": "5.0.1",
"from": "mocha@5.0.1",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.1.tgz",
"version": "1.17.1",
"from": "https://registry.npmjs.org/mocha/-/mocha-1.17.1.tgz",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-1.17.1.tgz",
"dependencies": {
"commander": {
"version": "2.11.0",
"from": "commander@2.11.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz"
},
"debug": {
"version": "3.1.0",
"from": "debug@3.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz"
},
"diff": {
"version": "3.3.1",
"from": "diff@3.3.1",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.3.1.tgz"
"version": "2.0.0",
"from": "commander@2.0.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.0.0.tgz"
},
"glob": {
"version": "7.1.2",
"from": "glob@7.1.2",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz"
"version": "3.2.3",
"from": "glob@3.2.3",
"resolved": "https://registry.npmjs.org/glob/-/glob-3.2.3.tgz"
},
"growl": {
"version": "1.10.3",
"from": "growl@1.10.3",
"resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz"
"graceful-fs": {
"version": "2.0.3",
"from": "graceful-fs@>=2.0.0 <2.1.0",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-2.0.3.tgz"
},
"has-flag": {
"version": "2.0.0",
"from": "has-flag@>=2.0.0 <3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz"
"jade": {
"version": "0.26.3",
"from": "jade@0.26.3",
"resolved": "https://registry.npmjs.org/jade/-/jade-0.26.3.tgz",
"dependencies": {
"commander": {
"version": "0.6.1",
"from": "commander@0.6.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-0.6.1.tgz"
},
"mkdirp": {
"version": "0.3.0",
"from": "mkdirp@0.3.0",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.0.tgz"
}
}
},
"minimatch": {
"version": "3.0.4",
"from": "minimatch@>=3.0.4 <4.0.0",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz"
},
"supports-color": {
"version": "4.4.0",
"from": "supports-color@4.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz"
"mkdirp": {
"version": "0.3.5",
"from": "mkdirp@0.3.5",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.3.5.tgz"
}
}
},

View file

@ -54,7 +54,7 @@
"method-override": "^2.3.3",
"metrics-sharelatex": "git+https://github.com/sharelatex/metrics-sharelatex.git#v1.7.1",
"mimelib": "0.2.14",
"mocha": "^5.0.1",
"mocha": "1.17.1",
"mongojs": "2.4.0",
"mongoose": "4.11.4",
"multer": "^0.1.8",

View file

@ -34,7 +34,6 @@ describe "ProjectStructureMongoLock", ->
namespace = ProjectEntityMongoUpdateHandler.LOCK_NAMESPACE
@lock_key = "lock:web:#{namespace}:#{project._id}"
LockManager._getLock @lock_key, namespace, done
return
after (done) ->
LockManager._releaseLock @lock_key, done

View file

@ -16,12 +16,6 @@ request = require "./helpers/request"
User = require "./helpers/User"
describe "ProjectStructureChanges", ->
example_project_id = null
example_doc_id = null
example_file_id = null
example_folder_id_1 = null
example_folder_id_2 = null
before (done) ->
@owner = new User()
@owner.login done
@ -31,11 +25,11 @@ describe "ProjectStructureChanges", ->
MockDocUpdaterApi.clearProjectStructureUpdates()
@owner.createProject "example-project", {template: "example"}, (error, project_id) =>
throw error if error?
example_project_id = project_id
@example_project_id = project_id
done()
it "should version creating a doc", ->
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).docUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(2)
_.each updates, (update) =>
expect(update.userId).to.equal(@owner._id)
@ -44,7 +38,7 @@ describe "ProjectStructureChanges", ->
expect(_.where(updates, pathname: "/references.bib").length).to.equal 1
it "should version creating a file", ->
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -54,9 +48,8 @@ describe "ProjectStructureChanges", ->
describe "duplicating a project", ->
before (done) ->
MockDocUpdaterApi.clearProjectStructureUpdates()
console.log(example_project_id)
@owner.request.post {
uri: "/Project/#{example_project_id}/clone",
uri: "/Project/#{@example_project_id}/clone",
json:
projectName: 'new.tex'
}, (error, res, body) =>
@ -87,10 +80,10 @@ describe "ProjectStructureChanges", ->
before (done) ->
MockDocUpdaterApi.clearProjectStructureUpdates()
ProjectGetter.getProject example_project_id, (error, project) =>
ProjectGetter.getProject @example_project_id, (error, project) =>
throw error if error?
@owner.request.post {
uri: "project/#{example_project_id}/doc",
uri: "project/#{@example_project_id}/doc",
json:
name: 'new.tex'
parent_folder_id: project.rootFolder[0]._id
@ -98,11 +91,11 @@ describe "ProjectStructureChanges", ->
throw error if error?
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to add doc #{res.statusCode}")
example_doc_id = body._id
@example_doc_id = body._id
done()
it "should version the doc added", ->
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).docUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -144,7 +137,7 @@ describe "ProjectStructureChanges", ->
describe "uploading a file", ->
before (done) ->
ProjectGetter.getProject example_project_id, (error, project) =>
ProjectGetter.getProject @example_project_id, (error, project) =>
throw error if error?
@root_folder_id = project.rootFolder[0]._id.toString()
done()
@ -156,7 +149,7 @@ describe "ProjectStructureChanges", ->
image_file = fs.createReadStream(Path.resolve(__dirname + '/../files/1pixel.png'))
req = @owner.request.post {
uri: "project/#{example_project_id}/upload",
uri: "project/#{@example_project_id}/upload",
qs:
folder_id: @root_folder_id
formData:
@ -170,9 +163,9 @@ describe "ProjectStructureChanges", ->
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to upload file #{res.statusCode}")
example_file_id = JSON.parse(body).entity_id
@example_file_id = JSON.parse(body).entity_id
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -186,7 +179,7 @@ describe "ProjectStructureChanges", ->
image_file = fs.createReadStream(Path.resolve(__dirname + '/../files/2pixel.png'))
req = @owner.request.post {
uri: "project/#{example_project_id}/upload",
uri: "project/#{@example_project_id}/upload",
qs:
folder_id: @root_folder_id
formData:
@ -200,7 +193,7 @@ describe "ProjectStructureChanges", ->
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to upload file #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -212,12 +205,12 @@ describe "ProjectStructureChanges", ->
describe "moving entities", ->
before (done) ->
@owner.request.post {
uri: "project/#{example_project_id}/folder",
uri: "project/#{@example_project_id}/folder",
formData:
name: 'foo'
}, (error, res, body) =>
throw error if error?
example_folder_id_1 = JSON.parse(body)._id
@example_folder_id_1 = JSON.parse(body)._id
done()
beforeEach () ->
@ -225,15 +218,15 @@ describe "ProjectStructureChanges", ->
it "should version moving a doc", (done) ->
@owner.request.post {
uri: "project/#{example_project_id}/Doc/#{example_doc_id}/move",
uri: "project/#{@example_project_id}/Doc/#{@example_doc_id}/move",
json:
folder_id: example_folder_id_1
folder_id: @example_folder_id_1
}, (error, res, body) =>
throw error if error?
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to move doc #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).docUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -244,15 +237,15 @@ describe "ProjectStructureChanges", ->
it "should version moving a file", (done) ->
@owner.request.post {
uri: "project/#{example_project_id}/File/#{example_file_id}/move",
uri: "project/#{@example_project_id}/File/#{@example_file_id}/move",
json:
folder_id: example_folder_id_1
folder_id: @example_folder_id_1
}, (error, res, body) =>
throw error if error?
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to move file #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -263,30 +256,30 @@ describe "ProjectStructureChanges", ->
it "should version moving a folder", (done) ->
@owner.request.post {
uri: "project/#{example_project_id}/folder",
uri: "project/#{@example_project_id}/folder",
formData:
name: 'bar'
}, (error, res, body) =>
throw error if error?
example_folder_id_2 = JSON.parse(body)._id
@example_folder_id_2 = JSON.parse(body)._id
@owner.request.post {
uri: "project/#{example_project_id}/Folder/#{example_folder_id_1}/move",
uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_1}/move",
json:
folder_id: example_folder_id_2
folder_id: @example_folder_id_2
}, (error, res, body) =>
throw error if error?
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to move folder #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).docUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
expect(update.pathname).to.equal("/foo/new.tex")
expect(update.newPathname).to.equal("/bar/foo/new.tex")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -301,7 +294,7 @@ describe "ProjectStructureChanges", ->
it "should version renaming a doc", (done) ->
@owner.request.post {
uri: "project/#{example_project_id}/Doc/#{example_doc_id}/rename",
uri: "project/#{@example_project_id}/Doc/#{@example_doc_id}/rename",
json:
name: 'new_renamed.tex'
}, (error, res, body) =>
@ -309,7 +302,7 @@ describe "ProjectStructureChanges", ->
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to move doc #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).docUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -320,7 +313,7 @@ describe "ProjectStructureChanges", ->
it "should version renaming a file", (done) ->
@owner.request.post {
uri: "project/#{example_project_id}/File/#{example_file_id}/rename",
uri: "project/#{@example_project_id}/File/#{@example_file_id}/rename",
json:
name: '1pixel_renamed.png'
}, (error, res, body) =>
@ -328,7 +321,7 @@ describe "ProjectStructureChanges", ->
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to move file #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -339,7 +332,7 @@ describe "ProjectStructureChanges", ->
it "should version renaming a folder", (done) ->
@owner.request.post {
uri: "project/#{example_project_id}/Folder/#{example_folder_id_1}/rename",
uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_1}/rename",
json:
name: 'foo_renamed'
}, (error, res, body) =>
@ -347,14 +340,14 @@ describe "ProjectStructureChanges", ->
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to move folder #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).docUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
expect(update.pathname).to.equal("/bar/foo/new_renamed.tex")
expect(update.newPathname).to.equal("/bar/foo_renamed/new_renamed.tex")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
@ -369,20 +362,20 @@ describe "ProjectStructureChanges", ->
it "should version deleting a folder", (done) ->
@owner.request.delete {
uri: "project/#{example_project_id}/Folder/#{example_folder_id_2}",
uri: "project/#{@example_project_id}/Folder/#{@example_folder_id_2}",
}, (error, res, body) =>
throw error if error?
if res.statusCode < 200 || res.statusCode >= 300
throw new Error("failed to delete folder #{res.statusCode}")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).docUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).docUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)
expect(update.pathname).to.equal("/bar/foo_renamed/new_renamed.tex")
expect(update.newPathname).to.equal("")
updates = MockDocUpdaterApi.getProjectStructureUpdates(example_project_id).fileUpdates
updates = MockDocUpdaterApi.getProjectStructureUpdates(@example_project_id).fileUpdates
expect(updates.length).to.equal(1)
update = updates[0]
expect(update.userId).to.equal(@owner._id)

View file

@ -99,7 +99,6 @@ describe "AuthenticationController", ->
@req.session.save = sinon.stub().callsArgWith(0, null)
@req.sessionStore = {generate: sinon.stub()}
@passport.authenticate.callsArgWith(1, null, @user, @info)
@err = new Error('woops')
it 'should call passport.authenticate', () ->
@AuthenticationController.passportLogin @req, @res, @next
@ -108,6 +107,7 @@ describe "AuthenticationController", ->
describe 'when authenticate produces an error', ->
beforeEach ->
@err = new Error('woops')
@passport.authenticate.callsArgWith(1, @err)
it 'should return next with an error', () ->

View file

@ -108,7 +108,6 @@ describe "CollaboratorsInviteController", ->
}
@LimitationsManager.canAddXCollaborators = sinon.stub().callsArgWith(2, null, true)
@CollaboratorsInviteHandler.inviteToProject = sinon.stub().callsArgWith(4, null, @invite)
@err = new Error('woops')
@callback = sinon.stub()
@next = sinon.stub()
@ -164,6 +163,7 @@ describe "CollaboratorsInviteController", ->
beforeEach ->
@CollaboratorsInviteController._checkShouldInviteEmail = sinon.stub().callsArgWith(1, null, true)
@CollaboratorsInviteController._checkRateLimit = sinon.stub().yields(null, true)
@err = new Error('woops')
@LimitationsManager.canAddXCollaborators = sinon.stub().callsArgWith(2, @err)
@CollaboratorsInviteController.inviteToProject @req, @res, @next

View file

@ -74,10 +74,11 @@ describe "FileStoreController", ->
describe "with a '#{extension}' file extension", ->
beforeEach ->
@user_agent = 'A generic browser'
@file.name = "bad#{extension}"
@req.get = (key) =>
if key == 'User-Agent'
return 'A generic browser'
@user_agent
describe "from a non-ios browser", ->
@ -90,9 +91,7 @@ describe "FileStoreController", ->
describe "from an iPhone", ->
beforeEach ->
@req.get = (key) =>
if key == 'User-Agent'
return "An iPhone browser"
@user_agent = "An iPhone browser"
it "should set Content-Type to 'text/plain'", (done) ->
@stream.pipe = (des) =>
@ -103,9 +102,7 @@ describe "FileStoreController", ->
describe "from an iPad", ->
beforeEach ->
@req.get = (key) =>
if key == 'User-Agent'
return "An iPad browser"
@user_agent = "An iPad browser"
it "should set Content-Type to 'text/plain'", (done) ->
@stream.pipe = (des) =>

View file

@ -11,7 +11,7 @@ describe "FileStoreHandler", ->
@fs =
createReadStream : sinon.stub()
lstat: sinon.stub().callsArgWith(1, null, {
isFile:=> true
isFile:=> @isSafeOnFileSystem
isDirectory:-> return false
})
@writeStream =
@ -35,6 +35,7 @@ describe "FileStoreHandler", ->
describe "uploadFileFromDisk", ->
beforeEach ->
@request.returns(@writeStream)
@isSafeOnFileSystem = true
it "should create read stream", (done)->
@fs.createReadStream.returns
@ -90,13 +91,8 @@ describe "FileStoreHandler", ->
done()
describe "symlink", ->
beforeEach ->
@fs.lstat = sinon.stub().callsArgWith(1, null, {
isFile:=> false
isDirectory:-> return false
})
it "should not read file if it is symlink", (done)->
@isSafeOnFileSystem = false
@handler.uploadFileFromDisk @project_id, @file_id, @fsPath, =>
@fs.createReadStream.called.should.equal false
done()

View file

@ -296,7 +296,7 @@ describe 'ProjectLocator', ->
it "should not crash with a null", (done)->
path = "/other.tex"
@locator.findElementByPath {project_id: project._id, path}, (err, element)->
@locator.findElementByPath {project_id: @project._id, path}, (err, element)->
expect(err).to.exist
done()

View file

@ -142,15 +142,13 @@ describe "ReferencesController", ->
describe 'index', ->
beforeEach ->
@call = (callback) =>
@controller.index @req, @res
callback()
describe 'with docIds as an array and shouldBroadcast as false', ->
beforeEach ->
@ReferencesHandler.index.callsArgWith(2, null, @fakeResponseData)
@call = (callback) =>
@controller.index @req, @res
callback()
it 'should call ReferencesHandler.index', (done) ->
@call () =>

View file

@ -78,16 +78,19 @@ describe "LimitationsManager", ->
@callback.calledWith(null, @user.features.collaborators).should.equal true
describe "canAddXCollaborators", ->
beforeEach ->
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager,
"allowedNumberOfCollaboratorsInProject",
(project_id, callback) => callback(null, @allowed_number)
@callback = sinon.stub()
describe "when the project has fewer collaborators than allowed", ->
beforeEach ->
@current_number = 1
@allowed_number = 2
@invite_count = 0
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager, "allowedNumberOfCollaboratorsInProject", (project_id, callback) =>
callback(null, @allowed_number)
@callback = sinon.stub()
@LimitationsManager.canAddXCollaborators(@project_id, 1, @callback)
it "should return true", ->
@ -98,11 +101,6 @@ describe "LimitationsManager", ->
@current_number = 1
@allowed_number = 4
@invite_count = 1
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager, "allowedNumberOfCollaboratorsInProject", (project_id, callback) =>
callback(null, @allowed_number)
@callback = sinon.stub()
@LimitationsManager.canAddXCollaborators(@project_id, 1, @callback)
it "should return true", ->
@ -113,11 +111,6 @@ describe "LimitationsManager", ->
@current_number = 1
@allowed_number = 2
@invite_count = 0
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager, "allowedNumberOfCollaboratorsInProject", (project_id, callback) =>
callback(null, @allowed_number)
@callback = sinon.stub()
@LimitationsManager.canAddXCollaborators(@project_id, 2, @callback)
it "should return false", ->
@ -128,11 +121,6 @@ describe "LimitationsManager", ->
@current_number = 3
@allowed_number = 2
@invite_count = 0
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager, "allowedNumberOfCollaboratorsInProject", (project_id, callback) =>
callback(null, @allowed_number)
@callback = sinon.stub()
@LimitationsManager.canAddXCollaborators(@project_id, 1, @callback)
it "should return false", ->
@ -143,11 +131,6 @@ describe "LimitationsManager", ->
@current_number = 100
@allowed_number = -1
@invite_count = 0
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager, "allowedNumberOfCollaboratorsInProject", (project_id, callback) =>
callback(null, @allowed_number)
@callback = sinon.stub()
@LimitationsManager.canAddXCollaborators(@project_id, 1, @callback)
it "should return true", ->
@ -158,11 +141,6 @@ describe "LimitationsManager", ->
@current_number = 0
@allowed_number = 2
@invite_count = 2
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager, "allowedNumberOfCollaboratorsInProject", (project_id, callback) =>
callback(null, @allowed_number)
@callback = sinon.stub()
@LimitationsManager.canAddXCollaborators(@project_id, 1, @callback)
it "should return false", ->
@ -173,11 +151,6 @@ describe "LimitationsManager", ->
@current_number = 1
@allowed_number = 2
@invite_count = 1
@CollaboratorsHandler.getInvitedCollaboratorCount = (project_id, callback) => callback(null, @current_number)
@CollaboratorsInviteHandler.getInviteCount = (project_id, callback) => callback(null, @invite_count)
sinon.stub @LimitationsManager, "allowedNumberOfCollaboratorsInProject", (project_id, callback) =>
callback(null, @allowed_number)
@callback = sinon.stub()
@LimitationsManager.canAddXCollaborators(@project_id, 1, @callback)
it "should return false", ->

View file

@ -38,8 +38,8 @@ describe 'SubscriptionViewModelBuilder', ->
@builder = SandboxedModule.require modulePath, requires:
"settings-sharelatex": { apis: { recurly: { subdomain: "example.com" }}}
"./RecurlyWrapper": @RecurlyWrapper
"./PlansLocator": @PlansLocator = {}
"./SubscriptionLocator": @SubscriptionLocator = {}
"./PlansLocator": @PlansLocator
"./SubscriptionLocator": @SubscriptionLocator
"./SubscriptionFormatters": @SubscriptionFormatters
"./LimitationsManager": {}
"logger-sharelatex":

View file

@ -105,12 +105,6 @@ describe 'SudoModeMiddlewear', ->
describe 'when external auth is being used', ->
beforeEach ->
@externalAuth = true
@call = (cb) =>
@req = {externalAuthenticationSystemUsed: sinon.stub().returns(@externalAuth)}
@res = {redirect: sinon.stub()}
@next = sinon.stub()
@SudoModeMiddlewear.protectPage @req, @res, @next
cb()
it 'should immediately return next with no args', (done) ->
@call () =>

View file

@ -26,12 +26,12 @@ describe "ArchiveManager", ->
"metrics-sharelatex": @metrics
"fs": @fs = {}
"fs-extra": @fse = {}
@callback = sinon.stub()
describe "extractZipArchive", ->
beforeEach ->
@source = "/path/to/zip/source.zip"
@destination = "/path/to/zip/destination"
@callback = sinon.stub()
@ArchiveManager._isZipTooLarge = sinon.stub().callsArgWith(1, null, false)
describe "successfully", ->

View file

@ -102,7 +102,7 @@ describe "ProjectUploadController", ->
@project_id = "project-id-123"
@folder_id = "folder-id-123"
@path = "/path/to/file/on/disk.png"
@name = "filename.png"
@filename = "filename.png"
@req.files =
qqfile:
path: @path

View file

@ -24,16 +24,21 @@ describe "RateLimiter", ->
@RedisWrapper =
client: sinon.stub().returns(@rclient)
@limiterFn = sinon.stub()
@RollingRateLimiter = (opts) =>
return @limiterFn
@limiter = SandboxedModule.require modulePath, requires:
"rolling-rate-limiter": @RollingRateLimiter
"settings-sharelatex":@settings
"logger-sharelatex" : @logger = {log:sinon.stub(), err:sinon.stub()}
"./RedisWrapper": @RedisWrapper
@endpointName = "compiles"
@subject = "some-project-id"
@timeInterval = 20
@throttleLimit = 5
@requires =
"settings-sharelatex":@settings
"logger-sharelatex" : @logger = {log:sinon.stub(), err:sinon.stub()}
"./RedisWrapper": @RedisWrapper
@details =
endpointName: @endpointName
subjectName: @subject
@ -47,9 +52,7 @@ describe "RateLimiter", ->
describe 'when action is permitted', ->
beforeEach ->
@requires["rolling-rate-limiter"] = (opts) =>
return sinon.stub().callsArgWith(1, null, 0, 22)
@limiter = SandboxedModule.require modulePath, requires: @requires
@limiterFn = sinon.stub().callsArgWith(1, null, 0, 22)
it 'should not produce and error', (done) ->
@limiter.addCount {}, (err, should) ->
@ -64,9 +67,7 @@ describe "RateLimiter", ->
describe 'when action is not permitted', ->
beforeEach ->
@requires["rolling-rate-limiter"] = (opts) =>
return sinon.stub().callsArgWith(1, null, 4000, 0)
@limiter = SandboxedModule.require modulePath, requires: @requires
@limiterFn = sinon.stub().callsArgWith(1, null, 4000, 0)
it 'should not produce and error', (done) ->
@limiter.addCount {}, (err, should) ->
@ -81,9 +82,7 @@ describe "RateLimiter", ->
describe 'when limiter produces an error', ->
beforeEach ->
@requires["rolling-rate-limiter"] = (opts) =>
return sinon.stub().callsArgWith(1, new Error('woops'))
@limiter = SandboxedModule.require modulePath, requires: @requires
@limiterFn = sinon.stub().callsArgWith(1, new Error('woops'))
it 'should produce and error', (done) ->
@limiter.addCount {}, (err, should) ->

View file

@ -13,12 +13,12 @@ define ['ide/editor/directives/cmEditor'], () ->
}
it 'inits Rich Text', () ->
inject ($compile, $rootScope) =>
inject ($compile, $rootScope) ->
$compile('<div cm-editor></div>')($rootScope)
expect(@richTextInit).to.have.been.called
it 'attaches to CM', () ->
inject ($compile, $rootScope, $browser) =>
inject ($compile, $rootScope, $browser) ->
getSnapshot = sinon.stub()
detachFromCM = sinon.stub()
attachToCM = sinon.stub()
@ -40,7 +40,7 @@ define ['ide/editor/directives/cmEditor'], () ->
expect(attachToCM).to.have.been.called
it 'detaches from CM when destroyed', () ->
inject ($compile, $rootScope) =>
inject ($compile, $rootScope) ->
@richTextInit.returns({ setValue: sinon.stub() })
detachFromCM = sinon.stub()
$rootScope.sharejsDoc = {

View file

@ -3,7 +3,7 @@
tests = []
for file of window.__karma__.files
if window.__karma__.files.hasOwnProperty(file)
if /test\/unit_frontend\/js.+Tests.js$/.test(file)
if /Tests\.js$/.test(file)
tests.push(file)
requirejs.config