|
@@ -16,15 +16,15 @@ describe('checking words', function() {
|
|
|
let response
|
|
let response
|
|
|
|
|
|
|
|
describe('on successful response', function() {
|
|
describe('on successful response', function() {
|
|
|
- beforeEach(async function () {
|
|
|
|
|
|
|
+ beforeEach(async function() {
|
|
|
response = await checkWord(['anather'])
|
|
response = await checkWord(['anather'])
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- it('should return status 200', async function () {
|
|
|
|
|
|
|
+ it('should return status 200', async function() {
|
|
|
expect(response.statusCode).to.equal(200)
|
|
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)
|
|
const body = JSON.parse(response.body)
|
|
|
expect(body).to.deep.equal({
|
|
expect(body).to.deep.equal({
|
|
|
misspellings: [{ index: 0, suggestions: ['anther', 'another'] }]
|
|
misspellings: [{ index: 0, suggestions: ['anther', 'another'] }]
|
|
@@ -33,22 +33,22 @@ describe('checking words', function() {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('when multiple words are submitted', function() {
|
|
describe('when multiple words are submitted', function() {
|
|
|
- beforeEach(async function () {
|
|
|
|
|
|
|
+ beforeEach(async function() {
|
|
|
response = await checkWord(['anather', 'anather', 'theorie'])
|
|
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)
|
|
const body = JSON.parse(response.body)
|
|
|
expect(body.misspellings.length).to.equal(3)
|
|
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 body = JSON.parse(response.body)
|
|
|
const indexes = body.misspellings.map(mspl => mspl.index)
|
|
const indexes = body.misspellings.map(mspl => mspl.index)
|
|
|
expect(indexes).to.deep.equal([0, 1, 2])
|
|
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)
|
|
const body = JSON.parse(response.body)
|
|
|
expect(body.misspellings[0].suggestions).to.deep.equal(
|
|
expect(body.misspellings[0].suggestions).to.deep.equal(
|
|
|
body.misspellings[1].suggestions
|
|
body.misspellings[1].suggestions
|
|
@@ -57,20 +57,20 @@ describe('checking words', function() {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
describe('when a very long list of words if submitted', 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++) {
|
|
for (let i = 0; i <= 20000; i++) {
|
|
|
words.push('anather')
|
|
words.push('anather')
|
|
|
}
|
|
}
|
|
|
response = await checkWord(words)
|
|
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)
|
|
const body = JSON.parse(response.body)
|
|
|
expect(body.misspellings.length).to.equal(10000)
|
|
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 body = JSON.parse(response.body)
|
|
|
const indexList = body.misspellings.map(mspl => mspl.index)
|
|
const indexList = body.misspellings.map(mspl => mspl.index)
|
|
|
expect(indexList.length).to.equal(10000) // avoid testing over an incorrect array
|
|
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() {
|
|
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++) {
|
|
for (let i = 0; i <= 20000; i++) {
|
|
|
words.push('anéther')
|
|
words.push('anéther')
|
|
|
}
|
|
}
|
|
|
response = await checkWord(words, 'bg') // use Bulgarian to generate utf8 response
|
|
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)
|
|
const body = JSON.parse(response.body)
|
|
|
expect(body.misspellings.length).to.equal(10000)
|
|
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 body = JSON.parse(response.body)
|
|
|
const indexList = body.misspellings.map(mspl => mspl.index)
|
|
const indexList = body.misspellings.map(mspl => mspl.index)
|
|
|
expect(indexList.length).to.equal(10000) // avoid testing over an incorrect array
|
|
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() {
|
|
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')
|
|
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)
|
|
const body = JSON.parse(response.body)
|
|
|
expect(body.misspellings.length).to.equal(4)
|
|
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 body = JSON.parse(response.body)
|
|
|
const indexes = body.misspellings.map(mspl => mspl.index)
|
|
const indexes = body.misspellings.map(mspl => mspl.index)
|
|
|
expect(indexes).to.deep.equal([0, 1, 2, 3])
|
|
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)
|
|
const body = JSON.parse(response.body)
|
|
|
expect(body.misspellings[0].suggestions).to.deep.equal(
|
|
expect(body.misspellings[0].suggestions).to.deep.equal(
|
|
|
body.misspellings[3].suggestions
|
|
body.misspellings[3].suggestions
|