mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
format:fix
This commit is contained in:
parent
562f14455c
commit
803ed1607c
8 changed files with 35 additions and 34 deletions
|
@ -89,7 +89,7 @@ class ASpellRunner {
|
|||
|
||||
// update the cache after processing all words, to avoid cache
|
||||
// changing while we use it
|
||||
for (let k in addToCache) {
|
||||
for (const k in addToCache) {
|
||||
const v = addToCache[k]
|
||||
cache.set(k, v)
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ class ASpellRunner {
|
|||
getSuggestions(language, output) {
|
||||
const lines = output.split('\n')
|
||||
const suggestions = {}
|
||||
for (let line of Array.from(lines)) {
|
||||
for (const line of Array.from(lines)) {
|
||||
var parts, word
|
||||
if (line[0] === '&') {
|
||||
// Suggestions found
|
||||
|
@ -149,7 +149,7 @@ class ASpellRunner {
|
|||
callback = () => {}
|
||||
}
|
||||
const newWord = {}
|
||||
for (let word of Array.from(words)) {
|
||||
for (const word of Array.from(words)) {
|
||||
if (!newWord[word] && !cache.has(language + ':' + word)) {
|
||||
newWord[word] = true
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@ module.exports = {
|
|||
internal: {
|
||||
spelling: {
|
||||
port: 3005,
|
||||
host: process.env['LISTEN_ADDRESS'] || 'localhost'
|
||||
host: process.env.LISTEN_ADDRESS || 'localhost'
|
||||
}
|
||||
},
|
||||
|
||||
mongo: {
|
||||
url:
|
||||
process.env['MONGO_CONNECTION_STRING'] ||
|
||||
`mongodb://${process.env['MONGO_HOST'] || 'localhost'}/sharelatex`
|
||||
process.env.MONGO_CONNECTION_STRING ||
|
||||
`mongodb://${process.env.MONGO_HOST || 'localhost'}/sharelatex`
|
||||
},
|
||||
|
||||
cacheDir: Path.resolve('cache'),
|
||||
|
|
|
@ -16,15 +16,15 @@ describe('checking words', function() {
|
|||
let response
|
||||
|
||||
describe('on successful response', function() {
|
||||
beforeEach(async function () {
|
||||
beforeEach(async function() {
|
||||
response = await checkWord(['anather'])
|
||||
})
|
||||
|
||||
it('should return status 200', async function () {
|
||||
it('should return status 200', async function() {
|
||||
expect(response.statusCode).to.equal(200)
|
||||
})
|
||||
|
||||
it('should return the list of misspellings', async function () {
|
||||
it('should return the list of misspellings', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
expect(body).to.deep.equal({
|
||||
misspellings: [{ index: 0, suggestions: ['anther', 'another'] }]
|
||||
|
@ -33,22 +33,22 @@ describe('checking words', function() {
|
|||
})
|
||||
|
||||
describe('when multiple words are submitted', function() {
|
||||
beforeEach(async function () {
|
||||
beforeEach(async function() {
|
||||
response = await checkWord(['anather', 'anather', 'theorie'])
|
||||
})
|
||||
|
||||
it('should return the misspellings for all the words', async function () {
|
||||
it('should return the misspellings for all the words', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
expect(body.misspellings.length).to.equal(3)
|
||||
})
|
||||
|
||||
it('should have misspelling suggestions with consecutive indexes', async function () {
|
||||
it('should have misspelling suggestions with consecutive indexes', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
const indexes = body.misspellings.map(mspl => mspl.index)
|
||||
expect(indexes).to.deep.equal([0, 1, 2])
|
||||
})
|
||||
|
||||
it('should return identical suggestions for the same entry', async function () {
|
||||
it('should return identical suggestions for the same entry', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
expect(body.misspellings[0].suggestions).to.deep.equal(
|
||||
body.misspellings[1].suggestions
|
||||
|
@ -57,20 +57,20 @@ describe('checking words', function() {
|
|||
})
|
||||
|
||||
describe('when a very long list of words if submitted', function() {
|
||||
beforeEach(async function () {
|
||||
let words = []
|
||||
beforeEach(async function() {
|
||||
const words = []
|
||||
for (let i = 0; i <= 20000; i++) {
|
||||
words.push('anather')
|
||||
}
|
||||
response = await checkWord(words)
|
||||
})
|
||||
|
||||
it('should return misspellings for the first 10K results only', async function () {
|
||||
it('should return misspellings for the first 10K results only', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
expect(body.misspellings.length).to.equal(10000)
|
||||
})
|
||||
|
||||
it('should have misspelling suggestions with consecutive indexes', async function () {
|
||||
it('should have misspelling suggestions with consecutive indexes', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
const indexList = body.misspellings.map(mspl => mspl.index)
|
||||
expect(indexList.length).to.equal(10000) // avoid testing over an incorrect array
|
||||
|
@ -81,20 +81,20 @@ describe('checking words', function() {
|
|||
})
|
||||
|
||||
describe('when a very long list of words with utf8 responses', function() {
|
||||
beforeEach(async function () {
|
||||
let words = []
|
||||
beforeEach(async function() {
|
||||
const words = []
|
||||
for (let i = 0; i <= 20000; i++) {
|
||||
words.push('anéther')
|
||||
}
|
||||
response = await checkWord(words, 'bg') // use Bulgarian to generate utf8 response
|
||||
})
|
||||
|
||||
it('should return misspellings for the first 10K results only', async function () {
|
||||
it('should return misspellings for the first 10K results only', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
expect(body.misspellings.length).to.equal(10000)
|
||||
})
|
||||
|
||||
it('should have misspelling suggestions with consecutive indexes', async function () {
|
||||
it('should have misspelling suggestions with consecutive indexes', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
const indexList = body.misspellings.map(mspl => mspl.index)
|
||||
expect(indexList.length).to.equal(10000) // avoid testing over an incorrect array
|
||||
|
@ -105,22 +105,22 @@ describe('checking words', function() {
|
|||
})
|
||||
|
||||
describe('when multiple words with utf8 are submitted', function() {
|
||||
beforeEach(async function () {
|
||||
beforeEach(async function() {
|
||||
response = await checkWord(['mneá', 'meniésn', 'meônoi', 'mneá'], 'pt_BR')
|
||||
})
|
||||
|
||||
it('should return the misspellings for all the words', async function () {
|
||||
it('should return the misspellings for all the words', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
expect(body.misspellings.length).to.equal(4)
|
||||
})
|
||||
|
||||
it('should have misspelling suggestions with consecutive indexes', async function () {
|
||||
it('should have misspelling suggestions with consecutive indexes', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
const indexes = body.misspellings.map(mspl => mspl.index)
|
||||
expect(indexes).to.deep.equal([0, 1, 2, 3])
|
||||
})
|
||||
|
||||
it('should return identical suggestions for the same entry', async function () {
|
||||
it('should return identical suggestions for the same entry', async function() {
|
||||
const body = JSON.parse(response.body)
|
||||
expect(body.misspellings[0].suggestions).to.deep.equal(
|
||||
body.misspellings[3].suggestions
|
||||
|
|
|
@ -2,7 +2,7 @@ const { expect } = require('chai')
|
|||
const request = require('./helpers/request')
|
||||
|
||||
describe('/health_check', function() {
|
||||
it('should return 200', async function () {
|
||||
it('should return 200', async function() {
|
||||
const response = await request.get('/health_check')
|
||||
expect(response.statusCode).to.equal(200)
|
||||
})
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
const App = require('../../../app.js')
|
||||
const { PORT } = require('./helpers/request')
|
||||
|
||||
before(function(done) { return App.listen(PORT, 'localhost', done); })
|
||||
before(function(done) {
|
||||
return App.listen(PORT, 'localhost', done)
|
||||
})
|
||||
|
|
|
@ -2,7 +2,7 @@ const { expect } = require('chai')
|
|||
const request = require('./helpers/request')
|
||||
|
||||
describe('/status', function() {
|
||||
it('should return 200', async function () {
|
||||
it('should return 200', async function() {
|
||||
const response = await request.get('/health_check')
|
||||
expect(response.statusCode).to.equal(200)
|
||||
})
|
||||
|
|
|
@ -2,8 +2,7 @@ const { promisify } = require('util')
|
|||
|
||||
const PORT = 3005
|
||||
|
||||
const BASE_URL = `http://${process.env['HTTP_TEST_HOST'] ||
|
||||
'localhost'}:${PORT}`
|
||||
const BASE_URL = `http://${process.env.HTTP_TEST_HOST || 'localhost'}:${PORT}`
|
||||
|
||||
const request = require('request').defaults({
|
||||
baseUrl: BASE_URL,
|
||||
|
|
|
@ -30,7 +30,7 @@ describe('ASpell', function() {
|
|||
}
|
||||
}))
|
||||
})
|
||||
afterEach(function () {
|
||||
afterEach(function() {
|
||||
clearInterval(this.ASpell.cacheDump)
|
||||
})
|
||||
|
||||
|
@ -138,9 +138,9 @@ describe('ASpell', function() {
|
|||
})
|
||||
|
||||
function __range__(left, right, inclusive) {
|
||||
let range = []
|
||||
let ascending = left < right
|
||||
let end = !inclusive ? right : ascending ? right + 1 : right - 1
|
||||
const range = []
|
||||
const ascending = left < right
|
||||
const end = !inclusive ? right : ascending ? right + 1 : right - 1
|
||||
for (let i = left; ascending ? i < end : i > end; ascending ? i++ : i--) {
|
||||
range.push(i)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue