Delete old spec files

This commit is contained in:
Alfred Melch 2019-12-14 23:37:00 +01:00
parent b5903bfca7
commit 764839d62a
4 changed files with 0 additions and 102 deletions

View File

@ -1,52 +0,0 @@
import { Chapter, _privates } from '../src/Chapter.js'
const { getNextBiggerNumber } = _privates
describe('Chapter', function() {
const demoText =
'Hello World. Foo bar baz. Lorem ipsum dolor sit. Worttrennungsalgorithmus.'
it('Iterates through segments', function() {
let chapter = new Chapter(demoText, 7)
let i = 1
while (chapter.next()) i++
expect(i).toBe(13)
})
it('Iterates through words', function() {
let chapter = new Chapter(demoText, 7)
let i = 1
while (chapter.nextWord()) i++
expect(i).toBe(10)
})
it('Iterates through sentences', function() {
let chapter = new Chapter(demoText)
let i = 1
while (chapter.nextSentence()) i++
expect(i).toBe(4)
})
it('Iterators return null on finish', function() {
let chapter = new Chapter(demoText, 7)
let cur
while ((cur = chapter.next())) {}
expect(cur).toBe(null)
while ((cur = chapter.prev())) {}
expect(cur).toBe(null)
while ((cur = chapter.nextWord())) {}
expect(cur).toBe(null)
while ((cur = chapter.prevWord())) {}
expect(cur).toBe(null)
while ((cur = chapter.nextSentence())) {}
expect(cur).toBe(null)
while ((cur = chapter.prevSentence())) {}
expect(cur).toBe(null)
})
})
describe('nextBiggerNumber', function() {
it('Returns a the next bigger number', function() {
expect(getNextBiggerNumber(5, [1, 4, 6])).toBe(6)
})
})

View File

View File

@ -1,3 +0,0 @@
import './Chapter.spec.js'
import './findPivot.spec.js'
import './parseText.spec.js'

View File

@ -1,47 +0,0 @@
import { parseText, _privates } from '../src/textProcessing/parseText.js'
const { splitLongWord } = _privates
describe('parseText', function() {
it('returns an object with expected properties', function() {
let parsed = parseText('Hello World. Test Sentence.')
expect(parsed.segments).toEqual(['Hello', 'World.', 'Test', 'Sentence.'])
expect(parsed.words).toEqual([0, 1, 2, 3])
expect(parsed.sentences).toEqual([0, 2])
})
})
describe('splitLongWord', function() {
it('returns an array', function() {
expect(Array.isArray(splitLongWord('asdf'))).toBeTruthy()
})
it('returns the single word by default', function() {
expect(splitLongWord('asdf')).toEqual(['asdf'])
})
it('returns small words unmodified', function() {
expect(splitLongWord('asdf', 5)).toEqual(['asdf'])
expect(splitLongWord('asdf', 4)).toEqual(['asdf'])
})
it('splits long words', function() {
expect(splitLongWord('asdf', 3)).toEqual(['as', 'df'])
})
it('split into even parts', function() {
expect(splitLongWord('1234567890', 9)).toEqual(['12345', '67890'])
})
it('corner case: uneven length', function() {
expect(splitLongWord('123456789', 8)).toEqual(['1234', '56789'])
})
it('corner case: multiple uneven parts', function() {
let word = '1234567890123'
let segments = splitLongWord(word, 3)
expect(segments.reduce((x, y) => x + y, '')).toBe(word)
expect(Math.max(...segments.map(seg => seg.length))).toBe(3)
expect(Math.min(...segments.map(seg => seg.length)))
})
})