diff --git a/spec/Chapter.spec.js b/spec/Chapter.spec.js deleted file mode 100644 index f082948..0000000 --- a/spec/Chapter.spec.js +++ /dev/null @@ -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) - }) -}) diff --git a/spec/findPivot.spec.js b/spec/findPivot.spec.js deleted file mode 100644 index e69de29..0000000 diff --git a/spec/index.spec.js b/spec/index.spec.js deleted file mode 100644 index 6b91b84..0000000 --- a/spec/index.spec.js +++ /dev/null @@ -1,3 +0,0 @@ -import './Chapter.spec.js' -import './findPivot.spec.js' -import './parseText.spec.js' diff --git a/spec/parseText.spec.js b/spec/parseText.spec.js deleted file mode 100644 index fc68ec7..0000000 --- a/spec/parseText.spec.js +++ /dev/null @@ -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))) - }) -})