mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
Merge pull request #3495 from overleaf/ae-prettier-2
Upgrade Prettier to v2 GitOrigin-RevId: 85aa3fa1acb6332c4f58c46165a43d1a51471f33
This commit is contained in:
+27
-27
@@ -11,8 +11,8 @@
|
||||
*/
|
||||
import SpellCheckManager from '../../../../../../frontend/js/ide/editor/directives/aceEditor/spell-check/SpellCheckManager'
|
||||
|
||||
export default describe('SpellCheckManager', function() {
|
||||
beforeEach(function(done) {
|
||||
export default describe('SpellCheckManager', function () {
|
||||
beforeEach(function (done) {
|
||||
this.timelord = sinon.useFakeTimers()
|
||||
window.user = { id: 1 }
|
||||
window.csrfToken = 'token'
|
||||
@@ -48,11 +48,11 @@ export default describe('SpellCheckManager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
return this.timelord.restore()
|
||||
})
|
||||
|
||||
it('adds an highlight when a misspelling is found', function() {
|
||||
it('adds an highlight when a misspelling is found', function () {
|
||||
this.$httpBackend.when('POST', '/spelling/check').respond({
|
||||
misspellings: [
|
||||
{
|
||||
@@ -68,8 +68,8 @@ export default describe('SpellCheckManager', function() {
|
||||
expect(this.highlightedWordManager.addHighlight).to.have.been.called
|
||||
})
|
||||
|
||||
describe('runSpellCheck', function() {
|
||||
beforeEach(function() {
|
||||
describe('runSpellCheck', function () {
|
||||
beforeEach(function () {
|
||||
this.adapter.getLineCount.returns(10)
|
||||
this.adapter.getFirstVisibleRowNum.returns(3)
|
||||
this.adapter.getLastVisibleRowNum.returns(5)
|
||||
@@ -87,16 +87,16 @@ export default describe('SpellCheckManager', function() {
|
||||
]
|
||||
})
|
||||
})
|
||||
describe('when doing the first check', function() {
|
||||
beforeEach(function() {
|
||||
describe('when doing the first check', function () {
|
||||
beforeEach(function () {
|
||||
this.spellCheckManager.init()
|
||||
})
|
||||
it('initially flags all lines as dirty ', function() {
|
||||
it('initially flags all lines as dirty ', function () {
|
||||
expect(this.spellCheckManager.changedLines)
|
||||
.to.have.lengthOf(10)
|
||||
.and.to.not.include(false)
|
||||
})
|
||||
it('checks beyond the currently visible viewport', function() {
|
||||
it('checks beyond the currently visible viewport', function () {
|
||||
this.timelord.tick(500)
|
||||
this.$httpBackend.flush()
|
||||
expect(this.adapter.getLinesByRows).to.have.been.calledWith([
|
||||
@@ -113,20 +113,20 @@ export default describe('SpellCheckManager', function() {
|
||||
])
|
||||
})
|
||||
})
|
||||
describe('after the initial check', function() {
|
||||
beforeEach(function() {
|
||||
describe('after the initial check', function () {
|
||||
beforeEach(function () {
|
||||
this.spellCheckManager.init()
|
||||
this.spellCheckManager.firstCheck = false
|
||||
})
|
||||
|
||||
it('only checks visible lines', function() {
|
||||
it('only checks visible lines', function () {
|
||||
this.spellCheckManager.runSpellCheck()
|
||||
this.spellCheckManager.timeoutId = null
|
||||
this.$httpBackend.flush()
|
||||
expect(this.adapter.getLinesByRows).to.have.been.calledWith([3, 4, 5])
|
||||
})
|
||||
|
||||
it('flags checked lines as non-dirty', function() {
|
||||
it('flags checked lines as non-dirty', function () {
|
||||
this.spellCheckManager.runSpellCheck()
|
||||
this.spellCheckManager.timeoutId = null
|
||||
this.$httpBackend.flush()
|
||||
@@ -137,7 +137,7 @@ export default describe('SpellCheckManager', function() {
|
||||
expect(this.spellCheckManager.changedLines[6]).to.equal(true)
|
||||
})
|
||||
|
||||
it('ignores updated lines', function() {
|
||||
it('ignores updated lines', function () {
|
||||
this.spellCheckManager.changedLines[4] = false
|
||||
this.spellCheckManager.runSpellCheck()
|
||||
this.spellCheckManager.timeoutId = null
|
||||
@@ -145,7 +145,7 @@ export default describe('SpellCheckManager', function() {
|
||||
expect(this.adapter.getLinesByRows).to.have.been.calledWith([3, 5])
|
||||
})
|
||||
|
||||
it('clears highlights for changed lines', function() {
|
||||
it('clears highlights for changed lines', function () {
|
||||
this.spellCheckManager.runSpellCheck()
|
||||
this.spellCheckManager.timeoutId = null
|
||||
this.$httpBackend.flush()
|
||||
@@ -162,8 +162,8 @@ export default describe('SpellCheckManager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('cache', function() {
|
||||
beforeEach(function() {
|
||||
describe('cache', function () {
|
||||
beforeEach(function () {
|
||||
this.adapter.getLineCount.returns(1)
|
||||
this.adapter.getFirstVisibleRowNum.returns(1)
|
||||
this.adapter.getLastVisibleRowNum.returns(1)
|
||||
@@ -178,7 +178,7 @@ export default describe('SpellCheckManager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('adds already checked words to the spellchecker cache', function() {
|
||||
it('adds already checked words to the spellchecker cache', function () {
|
||||
expect(this.spellCheckManager.cache.info().size).to.equal(0)
|
||||
this.spellCheckManager.init()
|
||||
this.timelord.tick(500)
|
||||
@@ -186,7 +186,7 @@ export default describe('SpellCheckManager', function() {
|
||||
expect(this.spellCheckManager.cache.info().size).to.equal(3)
|
||||
})
|
||||
|
||||
it('adds misspeled word suggestions to the cache', function() {
|
||||
it('adds misspeled word suggestions to the cache', function () {
|
||||
this.spellCheckManager.init()
|
||||
this.timelord.tick(500)
|
||||
this.$httpBackend.flush()
|
||||
@@ -198,7 +198,7 @@ export default describe('SpellCheckManager', function() {
|
||||
).to.eql(['foobarbaz'])
|
||||
})
|
||||
|
||||
it('adds non-misspeled words to the cache as a boolean', function() {
|
||||
it('adds non-misspeled words to the cache as a boolean', function () {
|
||||
this.spellCheckManager.init()
|
||||
this.timelord.tick(500)
|
||||
this.$httpBackend.flush()
|
||||
@@ -210,15 +210,15 @@ export default describe('SpellCheckManager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('backend', function() {
|
||||
beforeEach(function() {
|
||||
describe('backend', function () {
|
||||
beforeEach(function () {
|
||||
this.adapter.getLineCount.returns(1)
|
||||
this.adapter.getFirstVisibleRowNum.returns(1)
|
||||
this.adapter.getLastVisibleRowNum.returns(1)
|
||||
this.adapter.getLinesByRows.returns(['Lorem ipsum dolor'])
|
||||
})
|
||||
|
||||
it('hits the backend with all words at startup', function() {
|
||||
it('hits the backend with all words at startup', function () {
|
||||
this.$httpBackend
|
||||
.expect('POST', '/spelling/check', {
|
||||
language: this.scope.spellCheckLanguage,
|
||||
@@ -239,7 +239,7 @@ export default describe('SpellCheckManager', function() {
|
||||
this.$httpBackend.flush()
|
||||
})
|
||||
|
||||
it('does not hit the backend when all words are already in the cache', function() {
|
||||
it('does not hit the backend when all words are already in the cache', function () {
|
||||
this.$httpBackend
|
||||
.expect('POST', '/spelling/check', {
|
||||
language: this.scope.spellCheckLanguage,
|
||||
@@ -262,7 +262,7 @@ export default describe('SpellCheckManager', function() {
|
||||
this.timelord.tick(500)
|
||||
})
|
||||
|
||||
it('hits the backend only with non-cached words', function() {
|
||||
it('hits the backend only with non-cached words', function () {
|
||||
this.$httpBackend
|
||||
.expect('POST', '/spelling/check', {
|
||||
language: this.scope.spellCheckLanguage,
|
||||
@@ -303,7 +303,7 @@ export default describe('SpellCheckManager', function() {
|
||||
this.$httpBackend.flush()
|
||||
})
|
||||
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
this.$httpBackend.verifyNoOutstandingRequest()
|
||||
this.$httpBackend.verifyNoOutstandingExpectation()
|
||||
})
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
*/
|
||||
import HistoryV2Manager from '../../../../frontend/js/ide/history/HistoryV2Manager'
|
||||
|
||||
export default describe('HistoryV2Manager', function() {
|
||||
beforeEach(function(done) {
|
||||
export default describe('HistoryV2Manager', function () {
|
||||
beforeEach(function (done) {
|
||||
this.defaultHistoryScope = {
|
||||
isV2: true,
|
||||
updates: [],
|
||||
@@ -167,11 +167,11 @@ export default describe('HistoryV2Manager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
it('should setup the history scope on initialization', function() {
|
||||
it('should setup the history scope on initialization', function () {
|
||||
expect(this.$scope.history).to.deep.equal(this.defaultHistoryScope)
|
||||
})
|
||||
|
||||
it('should keep history updates after performing a soft reset', function() {
|
||||
it('should keep history updates after performing a soft reset', function () {
|
||||
let historyScopeWithUpdates = Object.assign({}, this.defaultHistoryScope, {
|
||||
updates: this.sampleUpdates
|
||||
})
|
||||
@@ -180,18 +180,18 @@ export default describe('HistoryV2Manager', function() {
|
||||
expect(this.$scope.history).to.deep.equal(historyScopeWithUpdates)
|
||||
})
|
||||
|
||||
it('should discard history updates after performing a hard reset', function() {
|
||||
it('should discard history updates after performing a hard reset', function () {
|
||||
this.$scope.history.updates = this.sampleUpdates
|
||||
this.historyManager.hardReset()
|
||||
expect(this.$scope.history).to.deep.equal(this.defaultHistoryScope)
|
||||
})
|
||||
|
||||
it('should setup history with full access to the feature if the project has versioning', function() {
|
||||
it('should setup history with full access to the feature if the project has versioning', function () {
|
||||
this.$scope.$digest()
|
||||
expect(this.$scope.history.userHasFullFeature).to.equal(true)
|
||||
})
|
||||
|
||||
it('should setup history without full access to the feature if the project does not have versioning', function() {
|
||||
it('should setup history without full access to the feature if the project does not have versioning', function () {
|
||||
this.$scope.project.features.versioning = false
|
||||
this.historyManager = new HistoryV2Manager(
|
||||
this.ide,
|
||||
@@ -202,7 +202,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
expect(this.$scope.history.userHasFullFeature).to.equal(false)
|
||||
})
|
||||
|
||||
it('should setup history with full access to the feature for admin users even if the project does not have versioning', function() {
|
||||
it('should setup history with full access to the feature for admin users even if the project does not have versioning', function () {
|
||||
this.$scope.project.features.versioning = false
|
||||
this.$scope.user.isAdmin = true
|
||||
this.historyManager = new HistoryV2Manager(
|
||||
@@ -214,9 +214,9 @@ export default describe('HistoryV2Manager', function() {
|
||||
expect(this.$scope.history.userHasFullFeature).to.equal(true)
|
||||
})
|
||||
|
||||
describe('autoSelectFile', function() {
|
||||
describe('for compare mode', function() {
|
||||
beforeEach(function() {
|
||||
describe('autoSelectFile', function () {
|
||||
describe('for compare mode', function () {
|
||||
beforeEach(function () {
|
||||
this.mockedFilesList = [
|
||||
{
|
||||
pathname: 'main.tex'
|
||||
@@ -260,8 +260,8 @@ export default describe('HistoryV2Manager', function() {
|
||||
this.$scope.history.selection.files = this.mockedFilesList
|
||||
})
|
||||
|
||||
describe('with a previously selected file', function() {
|
||||
it('should prefer the previously selected file if it is available and has operations', function() {
|
||||
describe('with a previously selected file', function () {
|
||||
it('should prefer the previously selected file if it is available and has operations', function () {
|
||||
this.historyManager._previouslySelectedPathname = this.mockedAddedFile.pathname
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file).to.deep.equal(
|
||||
@@ -269,13 +269,13 @@ export default describe('HistoryV2Manager', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer a file with ops if the previously selected file is available but has no operations', function() {
|
||||
it('should prefer a file with ops if the previously selected file is available but has no operations', function () {
|
||||
this.historyManager._previouslySelectedPathname = this.mockedReferencesFile.pathname
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file.operation).to.exist
|
||||
})
|
||||
|
||||
it('should ignore the previously selected file if it is not available', function() {
|
||||
it('should ignore the previously selected file if it is not available', function () {
|
||||
this.historyManager._previouslySelectedPathname = 'non/existent.file'
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file.pathname).to.not.equal(
|
||||
@@ -284,15 +284,15 @@ export default describe('HistoryV2Manager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('without a previously selected file, with a list of files containing operations', function() {
|
||||
it('should prefer edited files', function() {
|
||||
describe('without a previously selected file, with a list of files containing operations', function () {
|
||||
it('should prefer edited files', function () {
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file).to.deep.equal(
|
||||
this.mockedEditedFile
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer added files if no edited files are present', function() {
|
||||
it('should prefer added files if no edited files are present', function () {
|
||||
const indexOfEditedFile = this.$scope.history.selection.files.indexOf(
|
||||
this.mockedEditedFile
|
||||
)
|
||||
@@ -303,7 +303,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer renamed files if no edited or added files are present', function() {
|
||||
it('should prefer renamed files if no edited or added files are present', function () {
|
||||
const indexOfEditedFile = this.$scope.history.selection.files.indexOf(
|
||||
this.mockedEditedFile
|
||||
)
|
||||
@@ -318,7 +318,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer removed files if no edited, added or renamed files are present', function() {
|
||||
it('should prefer removed files if no edited, added or renamed files are present', function () {
|
||||
const indexOfEditedFile = this.$scope.history.selection.files.indexOf(
|
||||
this.mockedEditedFile
|
||||
)
|
||||
@@ -338,8 +338,8 @@ export default describe('HistoryV2Manager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('without a previously selected file, with a list of files without operations', function() {
|
||||
beforeEach(function() {
|
||||
describe('without a previously selected file, with a list of files without operations', function () {
|
||||
beforeEach(function () {
|
||||
this.mockedFilesListWithNoOps = [
|
||||
{
|
||||
pathname: 'main.tex'
|
||||
@@ -361,14 +361,14 @@ export default describe('HistoryV2Manager', function() {
|
||||
this.$scope.history.selection.files = this.mockedFilesListWithNoOps
|
||||
})
|
||||
|
||||
it('should prefer main.tex if it exists', function() {
|
||||
it('should prefer main.tex if it exists', function () {
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file).to.deep.equal(
|
||||
this.mockedMainTex
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer another tex file if main.tex does not exist', function() {
|
||||
it('should prefer another tex file if main.tex does not exist', function () {
|
||||
const indexOfMainTex = this.$scope.history.selection.files.indexOf(
|
||||
this.mockedMainTex
|
||||
)
|
||||
@@ -379,7 +379,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should pick the first available file if no tex files are available', function() {
|
||||
it('should pick the first available file if no tex files are available', function () {
|
||||
const indexOfMainTex = this.$scope.history.selection.files.indexOf(
|
||||
this.mockedMainTex
|
||||
)
|
||||
@@ -396,8 +396,8 @@ export default describe('HistoryV2Manager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('for point-in-time mode', function() {
|
||||
beforeEach(function() {
|
||||
describe('for point-in-time mode', function () {
|
||||
beforeEach(function () {
|
||||
this.$scope.history.viewMode = 'point_in_time'
|
||||
this.sampleUpdates[0] = {
|
||||
fromV: 4,
|
||||
@@ -468,8 +468,8 @@ export default describe('HistoryV2Manager', function() {
|
||||
this.$scope.history.selection.files = this.mockedFilesList
|
||||
})
|
||||
|
||||
describe('with a previously selected file', function() {
|
||||
it('should prefer the previously selected file if it is available and has operations', function() {
|
||||
describe('with a previously selected file', function () {
|
||||
it('should prefer the previously selected file if it is available and has operations', function () {
|
||||
this.historyManager._previouslySelectedPathname = 'main.tex'
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file.pathname).to.equal(
|
||||
@@ -477,7 +477,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer a file with ops if the previously selected file is available but has no operations', function() {
|
||||
it('should prefer a file with ops if the previously selected file is available but has no operations', function () {
|
||||
this.historyManager._previouslySelectedPathname = 'main.tex'
|
||||
this.sampleUpdates[0].pathnames = []
|
||||
this.historyManager.autoSelectFile()
|
||||
@@ -486,7 +486,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should ignore the previously selected file if it is not available', function() {
|
||||
it('should ignore the previously selected file if it is not available', function () {
|
||||
this.historyManager._previouslySelectedPathname = 'non/existent.file'
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file.pathname).to.not.equal(
|
||||
@@ -495,15 +495,15 @@ export default describe('HistoryV2Manager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('without a previously selected file, with a list of files containing operations', function() {
|
||||
it('should prefer edited files', function() {
|
||||
describe('without a previously selected file, with a list of files containing operations', function () {
|
||||
it('should prefer edited files', function () {
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file.pathname).to.equal(
|
||||
this.sampleUpdateEditedFile
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer added files if no edited files are present', function() {
|
||||
it('should prefer added files if no edited files are present', function () {
|
||||
this.sampleUpdates[0].pathnames = []
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file.pathname).to.equal(
|
||||
@@ -511,7 +511,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer renamed files if no edited or added files are present', function() {
|
||||
it('should prefer renamed files if no edited or added files are present', function () {
|
||||
this.sampleUpdates[0].pathnames = []
|
||||
this.sampleUpdates[0].project_ops.shift()
|
||||
this.historyManager.autoSelectFile()
|
||||
@@ -521,22 +521,22 @@ export default describe('HistoryV2Manager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('without a previously selected file, with a list of files without operations', function() {
|
||||
beforeEach(function() {
|
||||
describe('without a previously selected file, with a list of files without operations', function () {
|
||||
beforeEach(function () {
|
||||
this.sampleUpdates[0].pathnames = []
|
||||
this.sampleUpdates[0].project_ops = []
|
||||
this.mockedMainTex = this.mockedFilesList[0]
|
||||
this.mockedReferencesFile = this.mockedFilesList[1]
|
||||
})
|
||||
|
||||
it('should prefer main.tex if it exists', function() {
|
||||
it('should prefer main.tex if it exists', function () {
|
||||
this.historyManager.autoSelectFile()
|
||||
expect(this.$scope.history.selection.file.pathname).to.equal(
|
||||
this.mockedMainTex.pathname
|
||||
)
|
||||
})
|
||||
|
||||
it('should prefer another tex file if main.tex does not exist', function() {
|
||||
it('should prefer another tex file if main.tex does not exist', function () {
|
||||
const indexOfMainTex = this.$scope.history.selection.files.indexOf(
|
||||
this.mockedMainTex
|
||||
)
|
||||
@@ -547,8 +547,8 @@ export default describe('HistoryV2Manager', function() {
|
||||
})
|
||||
})
|
||||
|
||||
describe('_loadLabels', function() {
|
||||
it('should return labels list as is if there is a label for the last version', function() {
|
||||
describe('_loadLabels', function () {
|
||||
it('should return labels list as is if there is a label for the last version', function () {
|
||||
const labels = [
|
||||
{
|
||||
id: '1',
|
||||
@@ -576,7 +576,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
expect(labelsResult).to.have.members(labels)
|
||||
})
|
||||
|
||||
it('should return a labels list with a pseudo current state label if there is no label for the last version', function() {
|
||||
it('should return a labels list with a pseudo current state label if there is no label for the last version', function () {
|
||||
const labels = [
|
||||
{
|
||||
id: '1',
|
||||
@@ -606,7 +606,7 @@ export default describe('HistoryV2Manager', function() {
|
||||
expect(labelsResult[0].version).to.equal(5)
|
||||
})
|
||||
|
||||
it('should keep pseudo label when deleting label', function() {
|
||||
it('should keep pseudo label when deleting label', function () {
|
||||
this.historyManager.$scope.history.labels = [
|
||||
{
|
||||
id: '1',
|
||||
|
||||
Reference in New Issue
Block a user