Merge pull request #1899 from overleaf/spd-implicit-return-tests

Decaf cleanup: Remove implicit return from 'it' and 'describe' in tests

GitOrigin-RevId: f297820e6212dddc0d60697a2fe1612ef27403b6
This commit is contained in:
Simon Detheridge
2019-06-21 13:58:57 +00:00
committed by sharelatex
parent 6fc507aea3
commit 757ae39487
170 changed files with 1691 additions and 1691 deletions
@@ -71,7 +71,7 @@ describe('AuthorizationManager', function() {
)
})
return it("should return the user's privilege level", function() {
it("should return the user's privilege level", function() {
return this.callback
.calledWith(null, 'readOnly', false, false)
.should.equal(true)
@@ -94,7 +94,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -117,14 +117,14 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the user as an owner', function() {
it('should return the user as an owner', function() {
return this.callback
.calledWith(null, 'owner', false, true)
.should.equal(true)
})
})
return describe('with no user (anonymous)', function() {
describe('with no user (anonymous)', function() {
describe('when the token is not valid', function() {
beforeEach(function() {
this.TokenAccessHandler.isValidToken = sinon
@@ -157,7 +157,7 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -198,14 +198,14 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should deny access', function() {
it('should deny access', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
})
})
return describe('when read-write-sharing is enabled', function() {
describe('when read-write-sharing is enabled', function() {
beforeEach(function() {
this.TokenAccessHandler.ANONYMOUS_READ_AND_WRITE_ENABLED = true
this.TokenAccessHandler.isValidToken = sinon
@@ -238,7 +238,7 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should give read-write access', function() {
it('should give read-write access', function() {
return this.callback
.calledWith(null, 'readAndWrite', false)
.should.equal(true)
@@ -246,7 +246,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('when the token is valid for read-only', function() {
describe('when the token is valid for read-only', function() {
beforeEach(function() {
this.TokenAccessHandler.isValidToken = sinon
.stub()
@@ -278,7 +278,7 @@ describe('AuthorizationManager', function() {
.should.equal(true)
})
return it('should give read-only access', function() {
it('should give read-only access', function() {
return this.callback
.calledWith(null, 'readOnly', false)
.should.equal(true)
@@ -310,7 +310,7 @@ describe('AuthorizationManager', function() {
)
})
return it("should return the user's privilege level", function() {
it("should return the user's privilege level", function() {
return this.callback
.calledWith(null, 'readOnly', false, false)
.should.equal(true)
@@ -333,7 +333,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -356,14 +356,14 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the user as an owner', function() {
it('should return the user as an owner', function() {
return this.callback
.calledWith(null, 'owner', false, true)
.should.equal(true)
})
})
return describe('with no user (anonymous)', function() {
describe('with no user (anonymous)', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject(
null,
@@ -385,7 +385,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return false', function() {
it('should return false', function() {
return this.callback
.calledWith(null, false, false, false)
.should.equal(true)
@@ -416,7 +416,7 @@ describe('AuthorizationManager', function() {
)
})
return it("should return the user's privilege level", function() {
it("should return the user's privilege level", function() {
return this.callback
.calledWith(null, 'readOnly', false)
.should.equal(true)
@@ -439,7 +439,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the public privilege level', function() {
it('should return the public privilege level', function() {
return this.callback
.calledWith(null, 'readAndWrite', true)
.should.equal(true)
@@ -462,14 +462,14 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the user as an owner', function() {
it('should return the user as an owner', function() {
return this.callback
.calledWith(null, 'owner', false)
.should.equal(true)
})
})
return describe('with no user (anonymous)', function() {
describe('with no user (anonymous)', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject(
null,
@@ -491,7 +491,7 @@ describe('AuthorizationManager', function() {
)
})
return it('should return the public privilege level', function() {
it('should return the public privilege level', function() {
return this.callback
.calledWith(null, 'readAndWrite', true)
.should.equal(true)
@@ -506,7 +506,7 @@ describe('AuthorizationManager', function() {
.yields(null, null)
})
return it('should return a NotFoundError', function() {
it('should return a NotFoundError', function() {
return this.AuthorizationManager.getPrivilegeLevelForProject(
this.user_id,
this.project_id,
@@ -516,7 +516,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('when the project id is not valid', function() {
describe('when the project id is not valid', function() {
beforeEach(function() {
this.AuthorizationManager.isUserSiteAdmin
.withArgs(this.user_id)
@@ -526,7 +526,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly')
})
return it('should return a error', function(done) {
it('should return a error', function(done) {
return this.AuthorizationManager.getPrivilegeLevelForProject(
undefined,
'not project id',
@@ -553,7 +553,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -573,7 +573,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -593,7 +593,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -606,14 +606,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserReadProject(
this.user_id,
this.project_id,
@@ -639,7 +639,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -659,7 +659,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -679,7 +679,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -692,14 +692,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectContent(
this.user_id,
this.project_id,
@@ -725,7 +725,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -745,7 +745,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -765,7 +765,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', true)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -785,7 +785,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -798,14 +798,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserWriteProjectSettings(
this.user_id,
this.project_id,
@@ -831,7 +831,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'owner', false)
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -851,7 +851,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readAndWrite', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -871,7 +871,7 @@ describe('AuthorizationManager', function() {
.yields(null, 'readOnly', false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -884,14 +884,14 @@ describe('AuthorizationManager', function() {
})
})
return describe('when user has no access', function() {
describe('when user has no access', function() {
beforeEach(function() {
return this.AuthorizationManager.getPrivilegeLevelForProject
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false, false)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.canUserAdminProject(
this.user_id,
this.project_id,
@@ -905,7 +905,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('isUserSiteAdmin', function() {
describe('isUserSiteAdmin', function() {
beforeEach(function() {
return (this.User.findOne = sinon.stub())
})
@@ -917,7 +917,7 @@ describe('AuthorizationManager', function() {
.yields(null, { isAdmin: true })
})
return it('should return true', function(done) {
it('should return true', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(this.user_id, function(
error,
isAdmin
@@ -935,7 +935,7 @@ describe('AuthorizationManager', function() {
.yields(null, { isAdmin: false })
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(this.user_id, function(
error,
isAdmin
@@ -953,7 +953,7 @@ describe('AuthorizationManager', function() {
.yields(null, null)
})
return it('should return false', function(done) {
it('should return false', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(this.user_id, function(
error,
isAdmin
@@ -964,7 +964,7 @@ describe('AuthorizationManager', function() {
})
})
return describe('when no user is passed', () =>
describe('when no user is passed', () =>
it('should return false', function(done) {
return this.AuthorizationManager.isUserSiteAdmin(
null,
@@ -85,7 +85,7 @@ describe('AuthorizationMiddleware', function() {
)
})
return it('should fall back to null', function(done) {
it('should fall back to null', function(done) {
this.AuthenticationController.getLoggedInUserId = sinon
.stub()
.returns(null)
@@ -122,7 +122,7 @@ describe('AuthorizationMiddleware', function() {
return (this.req.params = {})
})
return it('should return an error to next', function() {
it('should return an error to next', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -146,7 +146,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -156,14 +156,14 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
return this.AuthorizationManager[managerMethod]
.withArgs(this.user_id, this.project_id, this.token)
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -186,7 +186,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -196,7 +196,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
return this.AuthorizationManager[managerMethod]
@@ -204,7 +204,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -218,13 +218,13 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('with malformed project id', function() {
describe('with malformed project id', function() {
beforeEach(function() {
this.req.params = { project_id: 'blah' }
return (this.ObjectId.isValid = sinon.stub().returns(false))
})
return it('should return a not found error', function(done) {
it('should return a not found error', function(done) {
return this.AuthorizationMiddleware[middlewareMethod](
this.req,
this.res,
@@ -258,7 +258,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -268,14 +268,14 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
return this.AuthorizationManager.isUserSiteAdmin
.withArgs(this.user_id)
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -289,7 +289,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('with anonymous user', function() {
describe('with anonymous user', function() {
describe('when user has permission', function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
@@ -298,7 +298,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -308,7 +308,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission", function() {
describe("when user doesn't have permission", function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
return this.AuthorizationManager.isUserSiteAdmin
@@ -316,7 +316,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserIsSiteAdmin(
this.req,
this.res,
@@ -331,7 +331,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('ensureUserCanReadMultipleProjects', function() {
describe('ensureUserCanReadMultipleProjects', function() {
beforeEach(function() {
this.AuthorizationManager.canUserReadProject = sinon.stub()
this.AuthorizationMiddleware.redirectToRestricted = sinon.stub()
@@ -355,7 +355,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,
@@ -365,7 +365,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission to access one of the projects", function() {
describe("when user doesn't have permission to access one of the projects", function() {
beforeEach(function() {
this.AuthorizationManager.canUserReadProject
.withArgs(this.user_id, 'project1', this.token)
@@ -375,7 +375,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,
@@ -389,7 +389,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe('with anonymous user', () =>
describe('with anonymous user', () =>
describe('when user has permission', function() {
describe('when user has permission to access all projects', function() {
beforeEach(function() {
@@ -402,7 +402,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, true)
})
return it('should return next', function() {
it('should return next', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,
@@ -412,7 +412,7 @@ describe('AuthorizationMiddleware', function() {
})
})
return describe("when user doesn't have permission to access one of the projects", function() {
describe("when user doesn't have permission to access one of the projects", function() {
beforeEach(function() {
this.AuthenticationController.getLoggedInUserId.returns(null)
this.AuthorizationManager.canUserReadProject
@@ -423,7 +423,7 @@ describe('AuthorizationMiddleware', function() {
.yields(null, false)
})
return it('should redirect to redirectToRestricted', function() {
it('should redirect to redirectToRestricted', function() {
this.AuthorizationMiddleware.ensureUserCanReadMultipleProjects(
this.req,
this.res,