Merge pull request #12219 from overleaf/em-camel-case-web
Camel case variables in web GitOrigin-RevId: 28e61b759b27f71265f33ab64f588374dba610e0
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
no-unused-vars,
|
||||
@@ -18,7 +17,7 @@ const modulePath = '../../../../app/src/Features/Project/ProjectHistoryHandler'
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('ProjectHistoryHandler', function () {
|
||||
const project_id = '4eecb1c1bffa66588e0000a1'
|
||||
const projectId = '4eecb1c1bffa66588e0000a1'
|
||||
const userId = 1234
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -30,7 +29,7 @@ describe('ProjectHistoryHandler', function () {
|
||||
}
|
||||
|
||||
constructor(options) {
|
||||
this._id = project_id
|
||||
this._id = projectId
|
||||
this.name = 'project_name_here'
|
||||
this.rev = 0
|
||||
}
|
||||
@@ -71,20 +70,20 @@ describe('ProjectHistoryHandler', function () {
|
||||
beforeEach(function () {
|
||||
this.ProjectDetailsHandler.getDetails = sinon
|
||||
.stub()
|
||||
.withArgs(project_id)
|
||||
.withArgs(projectId)
|
||||
.callsArgWith(1, null, this.project)
|
||||
this.ProjectModel.updateOne = sinon
|
||||
.stub()
|
||||
.callsArgWith(2, null, { matchedCount: 1 })
|
||||
return this.ProjectHistoryHandler.ensureHistoryExistsForProject(
|
||||
project_id,
|
||||
projectId,
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
|
||||
it('should get any existing history id for the project', function () {
|
||||
return this.ProjectDetailsHandler.getDetails
|
||||
.calledWith(project_id)
|
||||
.calledWith(projectId)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
@@ -95,7 +94,7 @@ describe('ProjectHistoryHandler', function () {
|
||||
it('should set the new history id on the project', function () {
|
||||
return this.ProjectModel.updateOne
|
||||
.calledWith(
|
||||
{ _id: project_id, 'overleaf.history.id': { $exists: false } },
|
||||
{ _id: projectId, 'overleaf.history.id': { $exists: false } },
|
||||
{ 'overleaf.history.id': this.historyId }
|
||||
)
|
||||
.should.equal(true)
|
||||
@@ -103,13 +102,13 @@ describe('ProjectHistoryHandler', function () {
|
||||
|
||||
it('should resync the project history', function () {
|
||||
return this.ProjectEntityUpdateHandler.resyncProjectHistory
|
||||
.calledWith(project_id)
|
||||
.calledWith(projectId)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
it('should flush the project history', function () {
|
||||
return this.HistoryManager.flushProject
|
||||
.calledWith(project_id)
|
||||
.calledWith(projectId)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
@@ -123,18 +122,18 @@ describe('ProjectHistoryHandler', function () {
|
||||
this.project.overleaf = { history: { id: 1234 } }
|
||||
this.ProjectDetailsHandler.getDetails = sinon
|
||||
.stub()
|
||||
.withArgs(project_id)
|
||||
.withArgs(projectId)
|
||||
.callsArgWith(1, null, this.project)
|
||||
this.ProjectModel.updateOne = sinon.stub()
|
||||
return this.ProjectHistoryHandler.ensureHistoryExistsForProject(
|
||||
project_id,
|
||||
projectId,
|
||||
this.callback
|
||||
)
|
||||
})
|
||||
|
||||
it('should get any existing history id for the project', function () {
|
||||
return this.ProjectDetailsHandler.getDetails
|
||||
.calledWith(project_id)
|
||||
.calledWith(projectId)
|
||||
.should.equal(true)
|
||||
})
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
n/handle-callback-err,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
@@ -20,7 +19,7 @@ const modulePath =
|
||||
const SandboxedModule = require('sandboxed-module')
|
||||
|
||||
describe('ProjectOptionsHandler', function () {
|
||||
const project_id = '4eecaffcbffa66588e000008'
|
||||
const projectId = '4eecaffcbffa66588e000008'
|
||||
|
||||
beforeEach(function () {
|
||||
let Project
|
||||
@@ -49,16 +48,16 @@ describe('ProjectOptionsHandler', function () {
|
||||
|
||||
describe('Setting the compiler', function () {
|
||||
it('should perform and update on mongo', function (done) {
|
||||
this.handler.setCompiler(project_id, 'xeLaTeX', err => {
|
||||
this.handler.setCompiler(projectId, 'xeLaTeX', err => {
|
||||
const args = this.projectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
args[1].compiler.should.equal('xelatex')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not perform and update on mongo if it is not a recognised compiler', function (done) {
|
||||
this.handler.setCompiler(project_id, 'something', err => {
|
||||
this.handler.setCompiler(projectId, 'something', err => {
|
||||
this.projectModel.updateOne.called.should.equal(false)
|
||||
done()
|
||||
})
|
||||
@@ -66,7 +65,7 @@ describe('ProjectOptionsHandler', function () {
|
||||
|
||||
describe('when called without arg', function () {
|
||||
it('should callback with null', function (done) {
|
||||
this.handler.setCompiler(project_id, null, err => {
|
||||
this.handler.setCompiler(projectId, null, err => {
|
||||
expect(err).to.be.undefined
|
||||
this.projectModel.updateOne.callCount.should.equal(0)
|
||||
done()
|
||||
@@ -80,7 +79,7 @@ describe('ProjectOptionsHandler', function () {
|
||||
})
|
||||
|
||||
it('should callback with error', function (done) {
|
||||
this.handler.setCompiler(project_id, 'xeLaTeX', err => {
|
||||
this.handler.setCompiler(projectId, 'xeLaTeX', err => {
|
||||
err.should.equal('error')
|
||||
done()
|
||||
})
|
||||
@@ -90,16 +89,16 @@ describe('ProjectOptionsHandler', function () {
|
||||
|
||||
describe('Setting the imageName', function () {
|
||||
it('should perform and update on mongo', function (done) {
|
||||
this.handler.setImageName(project_id, 'texlive-1234.5', err => {
|
||||
this.handler.setImageName(projectId, 'texlive-1234.5', err => {
|
||||
const args = this.projectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
args[1].imageName.should.equal('docker-repo/subdir/texlive-1234.5')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not perform and update on mongo if it is not a reconised compiler', function (done) {
|
||||
this.handler.setImageName(project_id, 'something', err => {
|
||||
this.handler.setImageName(projectId, 'something', err => {
|
||||
this.projectModel.updateOne.called.should.equal(false)
|
||||
done()
|
||||
})
|
||||
@@ -107,7 +106,7 @@ describe('ProjectOptionsHandler', function () {
|
||||
|
||||
describe('when called without arg', function () {
|
||||
it('should callback with null', function (done) {
|
||||
this.handler.setImageName(project_id, null, err => {
|
||||
this.handler.setImageName(projectId, null, err => {
|
||||
expect(err).to.be.undefined
|
||||
this.projectModel.updateOne.callCount.should.equal(0)
|
||||
done()
|
||||
@@ -121,7 +120,7 @@ describe('ProjectOptionsHandler', function () {
|
||||
})
|
||||
|
||||
it('should callback with error', function (done) {
|
||||
this.handler.setImageName(project_id, 'texlive-1234.5', err => {
|
||||
this.handler.setImageName(projectId, 'texlive-1234.5', err => {
|
||||
err.should.equal('error')
|
||||
done()
|
||||
})
|
||||
@@ -131,23 +130,23 @@ describe('ProjectOptionsHandler', function () {
|
||||
|
||||
describe('setting the spellCheckLanguage', function () {
|
||||
it('should perform and update on mongo', function (done) {
|
||||
this.handler.setSpellCheckLanguage(project_id, 'fr', err => {
|
||||
this.handler.setSpellCheckLanguage(projectId, 'fr', err => {
|
||||
const args = this.projectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
args[1].spellCheckLanguage.should.equal('fr')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not perform and update on mongo if it is not a reconised compiler', function (done) {
|
||||
this.handler.setSpellCheckLanguage(project_id, 'no a lang', err => {
|
||||
this.handler.setSpellCheckLanguage(projectId, 'no a lang', err => {
|
||||
this.projectModel.updateOne.called.should.equal(false)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should perform and update on mongo if the language is blank (means turn it off)', function (done) {
|
||||
this.handler.setSpellCheckLanguage(project_id, '', err => {
|
||||
this.handler.setSpellCheckLanguage(projectId, '', err => {
|
||||
this.projectModel.updateOne.called.should.equal(true)
|
||||
done()
|
||||
})
|
||||
@@ -159,7 +158,7 @@ describe('ProjectOptionsHandler', function () {
|
||||
})
|
||||
|
||||
it('should callback with error', function (done) {
|
||||
this.handler.setSpellCheckLanguage(project_id, 'fr', err => {
|
||||
this.handler.setSpellCheckLanguage(projectId, 'fr', err => {
|
||||
err.should.equal('error')
|
||||
done()
|
||||
})
|
||||
@@ -169,23 +168,23 @@ describe('ProjectOptionsHandler', function () {
|
||||
|
||||
describe('setting the brandVariationId', function () {
|
||||
it('should perform and update on mongo', function (done) {
|
||||
this.handler.setBrandVariationId(project_id, '123', err => {
|
||||
this.handler.setBrandVariationId(projectId, '123', err => {
|
||||
const args = this.projectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
args[1].brandVariationId.should.equal('123')
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not perform and update on mongo if there is no brand variation', function (done) {
|
||||
this.handler.setBrandVariationId(project_id, null, err => {
|
||||
this.handler.setBrandVariationId(projectId, null, err => {
|
||||
this.projectModel.updateOne.called.should.equal(false)
|
||||
done()
|
||||
})
|
||||
})
|
||||
|
||||
it('should not perform and update on mongo if brand variation is an empty string', function (done) {
|
||||
this.handler.setBrandVariationId(project_id, '', err => {
|
||||
this.handler.setBrandVariationId(projectId, '', err => {
|
||||
this.projectModel.updateOne.called.should.equal(false)
|
||||
done()
|
||||
})
|
||||
@@ -197,7 +196,7 @@ describe('ProjectOptionsHandler', function () {
|
||||
})
|
||||
|
||||
it('should callback with error', function (done) {
|
||||
this.handler.setBrandVariationId(project_id, '123', err => {
|
||||
this.handler.setBrandVariationId(projectId, '123', err => {
|
||||
err.should.equal('error')
|
||||
done()
|
||||
})
|
||||
@@ -207,9 +206,9 @@ describe('ProjectOptionsHandler', function () {
|
||||
|
||||
describe('unsetting the brandVariationId', function () {
|
||||
it('should perform and update on mongo', function (done) {
|
||||
this.handler.unsetBrandVariationId(project_id, err => {
|
||||
this.handler.unsetBrandVariationId(projectId, err => {
|
||||
const args = this.projectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
expect(args[1]).to.deep.equal({ $unset: { brandVariationId: 1 } })
|
||||
done()
|
||||
})
|
||||
@@ -221,7 +220,7 @@ describe('ProjectOptionsHandler', function () {
|
||||
})
|
||||
|
||||
it('should callback with error', function (done) {
|
||||
this.handler.unsetBrandVariationId(project_id, err => {
|
||||
this.handler.unsetBrandVariationId(projectId, err => {
|
||||
err.should.equal('error')
|
||||
done()
|
||||
})
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
/* eslint-disable
|
||||
camelcase,
|
||||
n/handle-callback-err,
|
||||
max-len,
|
||||
no-return-assign,
|
||||
@@ -83,10 +82,10 @@ describe('ProjectUpdateHandler', function () {
|
||||
|
||||
describe('markAsOpened', function () {
|
||||
it('should send an update to mongo', function (done) {
|
||||
const project_id = 'project_id'
|
||||
return this.handler.markAsOpened(project_id, err => {
|
||||
const projectId = 'project_id'
|
||||
return this.handler.markAsOpened(projectId, err => {
|
||||
const args = this.ProjectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
const date = args[1].lastOpened + ''
|
||||
const now = Date.now() + ''
|
||||
date.substring(0, 5).should.equal(now.substring(0, 5))
|
||||
@@ -97,10 +96,10 @@ describe('ProjectUpdateHandler', function () {
|
||||
|
||||
describe('markAsInactive', function () {
|
||||
it('should send an update to mongo', function (done) {
|
||||
const project_id = 'project_id'
|
||||
return this.handler.markAsInactive(project_id, err => {
|
||||
const projectId = 'project_id'
|
||||
return this.handler.markAsInactive(projectId, err => {
|
||||
const args = this.ProjectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
args[1].active.should.equal(false)
|
||||
return done()
|
||||
})
|
||||
@@ -109,10 +108,10 @@ describe('ProjectUpdateHandler', function () {
|
||||
|
||||
describe('markAsActive', function () {
|
||||
it('should send an update to mongo', function (done) {
|
||||
const project_id = 'project_id'
|
||||
return this.handler.markAsActive(project_id, err => {
|
||||
const projectId = 'project_id'
|
||||
return this.handler.markAsActive(projectId, err => {
|
||||
const args = this.ProjectModel.updateOne.args[0]
|
||||
args[0]._id.should.equal(project_id)
|
||||
args[0]._id.should.equal(projectId)
|
||||
args[1].active.should.equal(true)
|
||||
return done()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user