describe('linenumbering', function () { beforeEach(module('OpenSlidesApp.motions.lineNumbering')); var lineNumberingService, brMarkup = function (no) { return '
' + ' '; }, noMarkup = function (no) { return ' '; }, longstr = function (length) { var outstr = ''; for (var i = 0; i < length; i++) { outstr += String.fromCharCode(65 + (i % 26)); } return outstr; }; beforeEach(inject(function (_lineNumberingService_) { lineNumberingService = _lineNumberingService_; })); describe('line numbering: test nodes', function () { it('breaks very short lines', function () { var textNode = document.createTextNode("0123"); lineNumberingService._currentInlineOffset = 0; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe('0123'); expect(lineNumberingService._currentInlineOffset).toBe(4); }); it('breaks simple lines', function () { var textNode = document.createTextNode("012345678901234567"); lineNumberingService._currentInlineOffset = 0; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe('01234' + brMarkup(1) + '56789' + brMarkup(2) + '01234' + brMarkup(3) + '567'); expect(lineNumberingService._currentInlineOffset).toBe(3); }); it('breaks simple lines with offset', function () { var textNode = document.createTextNode("012345678901234567"); lineNumberingService._currentInlineOffset = 2; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe('012' + brMarkup(1) + '34567' + brMarkup(2) + '89012' + brMarkup(3) + '34567'); expect(lineNumberingService._currentInlineOffset).toBe(5); }); it('breaks simple lines with offset equaling to length', function () { var textNode = document.createTextNode("012345678901234567"); lineNumberingService._currentInlineOffset = 5; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe(brMarkup(1) + '01234' + brMarkup(2) + '56789' + brMarkup(3) + '01234' + brMarkup(4) + '567'); expect(lineNumberingService._currentInlineOffset).toBe(3); }); it('breaks simple lines with spaces (1)', function () { var textNode = document.createTextNode("0123 45 67 89012 34 567"); lineNumberingService._currentInlineOffset = 0; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe('0123 ' + brMarkup(1) + '45 67 ' + brMarkup(2) + '89012 ' + brMarkup(3) + '34 ' + brMarkup(4) + '567'); expect(lineNumberingService._currentInlineOffset).toBe(3); }); it('breaks simple lines with spaces (2)', function () { var textNode = document.createTextNode("0123 45 67 89012tes 344 "); lineNumberingService._currentInlineOffset = 0; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe('0123 ' + brMarkup(1) + '45 67 ' + brMarkup(2) + '89012' + brMarkup(3) + 'tes ' + brMarkup(4) + '344 '); expect(lineNumberingService._currentInlineOffset).toBe(4); }); it('breaks simple lines with spaces (3)', function () { var textNode = document.createTextNode("I'm a Demo-Text"); lineNumberingService._currentInlineOffset = 0; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe('I\'m a ' + brMarkup(1) + 'Demo-' + brMarkup(2) + 'Text'); expect(lineNumberingService._currentInlineOffset).toBe(4); }); it('breaks simple lines with spaces (4)', function () { var textNode = document.createTextNode("I'm a LongDemo-Text"); lineNumberingService._currentInlineOffset = 0; lineNumberingService._currentLineNumber = 1; var out = lineNumberingService._textNodeToLines(textNode, 5); var outHtml = lineNumberingService._nodesToHtml(out); expect(outHtml).toBe('I\'m a ' + brMarkup(1) + 'LongD' + brMarkup(2) + 'emo-' + brMarkup(3) + 'Text'); expect(lineNumberingService._currentInlineOffset).toBe(4); }); }); describe('line numbering: inline nodes', function () { it('leaves a simple SPAN untouched', function () { var inHtml = "Test"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 5); expect(outHtml).toBe(noMarkup(1) + 'Test'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('breaks lines in a simple SPAN', function () { var inHtml = "Lorem ipsum dolorsit amet"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 5); expect(outHtml).toBe(noMarkup(1) + 'Lorem ' + brMarkup(2) + 'ipsum ' + brMarkup(3) + 'dolor' + brMarkup(4) + 'sit ' + brMarkup(5) + 'amet'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('breaks lines in nested inline elements', function () { var inHtml = "Lorem ipsum dolorsit amet"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 5); expect(outHtml).toBe(noMarkup(1) + 'Lorem ' + brMarkup(2) + 'ipsum ' + brMarkup(3) + 'dolor' + brMarkup(4) + 'sit ' + brMarkup(5) + 'amet'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('counts within DEL nodes', function () { var inHtml = "1234 1234 1234 1234"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 10); expect(outHtml).toBe(noMarkup(1) + '1234 1234 ' + brMarkup(2) + '1234 1234'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('handles STRIKE-tags', function () { var inHtml = '

et accusam et justo duo dolores et ea rebum Inserted Text. Stet clita kasd gubergren,

'; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe('

' + noMarkup(1) + 'et accusam et justo duo dolores et ea rebum Inserted Text. Stet clita kasd ' + brMarkup(2) + 'gubergren,

'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); }); describe('line numbering: block nodes', function () { it('leaves a simple DIV untouched', function () { var inHtml = "
Test
"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 5); expect(outHtml).toBe('
' + noMarkup(1) + 'Test
'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('breaks a DIV containing only inline elements', function () { var inHtml = "
Test Test12345678 Test
"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 5); expect(outHtml).toBe('
' + noMarkup(1) + 'Test ' + brMarkup(2) + 'Test1' + brMarkup(3) + '23456' + brMarkup(4) + '78 ' + brMarkup(5) + 'Test
'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('handles a DIV within a DIV correctly', function () { var inHtml = "
Te
Te Test
Test
"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 5); expect(outHtml).toBe('
' + noMarkup(1) + 'Te
' + noMarkup(2) + 'Te ' + brMarkup(3) + 'Test
' + noMarkup(4) + 'Test
'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('ignores white spaces between block element tags', function () { var inHtml = ""; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe("'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); }); describe('indentation for block elements', function () { it('indents LI-elements', function () { var inHtml = '
' +longstr(100) + '' + longstr(100) + '
'; var expected = '
' + noMarkup(1) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB' + brMarkup(2) + 'CDEFGHIJKLMNOPQRSTUV' + '' + noMarkup(5) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB' + brMarkup(6) + 'CDEFGHIJKLMNOPQRSTUV
'; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe(expected); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('indents BLOCKQUOTE-elements', function () { var inHtml = '
' +longstr(100) + '
' + longstr(100) + '
' + longstr(100) + '
'; var expected = '
' + noMarkup(1) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB' + brMarkup(2) + 'CDEFGHIJKLMNOPQRSTUV' + '
' + noMarkup(3) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH' + brMarkup(4) + 'IJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV' + '
' + noMarkup(5) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB' + brMarkup(6) + 'CDEFGHIJKLMNOPQRSTUV
'; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe(expected); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('shortens the line for H1-elements by 1/2', function () { var inHtml = '

' + longstr(80) + '

'; var expected = '

' + noMarkup(1) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMN' + brMarkup(2) + 'OPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB

'; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe(expected); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('shortens the line for H2-elements by 2/3', function () { var inHtml = '

' + longstr(80) + '

'; var expected = '

' + noMarkup(1) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZA' + brMarkup(2) + 'BCDEFGHIJKLMNOPQRSTUVWXYZAB

'; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe(expected); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('indents Ps with 30px-padding by 6 characters', function () { var inHtml = '
' + longstr(80) + '
'; var expected = '
' + noMarkup(1) + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV' + brMarkup(2) + 'WXYZAB
'; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe(expected); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('breaks before an inline element, if the first word of the new inline element is longer than the remaining line (1)', function () { var inHtml = "

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio.

"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe('

' + noMarkup(1) + 'Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie ' + brMarkup(2) + 'consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan ' + brMarkup(3) + 'et iusto odio.

'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('breaks before an inline element, if the first word of the new inline element is longer than the remaining line (2)', function () { var inHtml = "

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio.

"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe('

' + noMarkup(1) + 'Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie ' + brMarkup(2) + 'consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan ' + brMarkup(3) + 'et iusto odio.

'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('does not fail in a weird case', function () { var inHtml = "seid Noch

Test 123

"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe(noMarkup(1) + 'seid Noch

' + noMarkup(2) + 'Test 123

'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); }); describe('line numbering in regard to the inline diff', function() { it('does not count within INS nodes', function () { var inHtml = "1234 1234 1234 1234"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 10); expect(outHtml).toBe(noMarkup(1) + '1234 1234 1234 ' + brMarkup(2) + '1234'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('does not create a new line for a trailing INS', function () { var inHtml = "

et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, conseteturdsfsdf23

"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe('

' + noMarkup(1) + 'et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata ' + brMarkup(2) + 'sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, conseteturdsfsdf23

'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('inserts the line number before the INS, if INS is the first element of the paragraph', function() { var inHtml = "

lauthals 'liebe Kinder, ich will hinaus in den Wald, seid auf der Hut vor dem Wolf!' Und noch etwas mehr Text bis zur nächsten Zeile

"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe("

" + noMarkup(1) + "lauthals 'liebe Kinder, ich will hinaus in den Wald, seid auf der Hut vor dem Wolf!' Und " + brMarkup(2) + "noch etwas mehr Text bis zur nächsten Zeile

"); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); }); describe('line breaking without adding line numbers', function() { var plainBr = '
'; it('breaks a DIV containing only inline elements', function () { var inHtml = "
Test Test12345678 Test
"; var outHtml = lineNumberingService.insertLineBreaksWithoutNumbers(inHtml, 5); expect(outHtml).toBe('
Test ' + plainBr + 'Test1' + plainBr + '23456' + plainBr + '78 ' + plainBr + 'Test
'); expect(lineNumberingService.stripLineNumbers(outHtml)).toBe(inHtml); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('indents BLOCKQUOTE-elements', function () { var inHtml = '
' + longstr(100) + '
' + longstr(100) + '
' + longstr(100) + '
'; var expected = '
' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB' + plainBr + 'CDEFGHIJKLMNOPQRSTUV' + '
' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGH' + plainBr + 'IJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUV' + '
' + 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZAB' + plainBr + 'CDEFGHIJKLMNOPQRSTUV
'; var outHtml = lineNumberingService.insertLineBreaksWithoutNumbers(inHtml, 80); expect(outHtml).toBe(expected); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('DOES count within INS nodes', function () { var inHtml = "1234 1234 1234 1234"; var outHtml = lineNumberingService.insertLineBreaksWithoutNumbers(inHtml, 10, true); expect(outHtml).toBe('1234 1234 ' + plainBr + '1234 1234'); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('does not create a new line for a trailing INS', function () { var inHtml = "

et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, conseteturdsfsdf23

"; var outHtml = lineNumberingService.insertLineBreaksWithoutNumbers(inHtml, 80, true); expect(outHtml).toBe('

et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata ' + plainBr + 'sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur' + plainBr + 'dsfsdf23

'); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); it('ignores witespaces by previously added line numbers', function () { var inHtml = "

" + noMarkup(1) + longstr(10) + "

"; var outHtml = lineNumberingService.insertLineBreaksWithoutNumbers(inHtml, 10, true); expect(outHtml).toBe("

" + noMarkup(1) + longstr(10) + "

"); expect(lineNumberingService.insertLineBreaksWithoutNumbers(outHtml, 80)).toBe(outHtml); }); }); describe('behavior regarding ckeditor', function() { it('does not count empty lines, case 1', function () { var inHtml = "

Line 1

\n\n

Line 2

"; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe('

' + noMarkup(1) + 'Line 1

' + "\n\n" + '

' + noMarkup(2) + 'Line 2

'); }); it('does not count empty lines, case 2', function () { var inHtml = ""; var outHtml = lineNumberingService.insertLineNumbers(inHtml, 80); expect(outHtml).toBe(""); }); }); describe('line highlighting', function() { it('highlights a simple line', function () { var inHtml = lineNumberingService.insertLineNumbers("Lorem ipsum dolorsit amet", 5); var highlighted = lineNumberingService.highlightLine(inHtml, 2); expect(highlighted).toBe(noMarkup(1) + 'Lorem ' + brMarkup(2) + 'ipsum ' + brMarkup(3) + 'dolor' + brMarkup(4) + 'sit ' + brMarkup(5) + 'amet'); }); it('highlights a simple line with formattings', function () { var inHtml = lineNumberingService.insertLineNumbers("Lorem ipsum dolorsit amet Lorem ipsum dolorsit amet Lorem ipsum dolorsit amet", 20); expect(inHtml).toBe(noMarkup(1) + 'Lorem ipsum dolorsit ' + brMarkup(2) + 'amet Lorem ipsum ' + brMarkup(3) + 'dolorsit amet Lorem ' + brMarkup(4) + 'ipsum dolorsit amet'); var highlighted = lineNumberingService.highlightLine(inHtml, 2); expect(highlighted).toBe(noMarkup(1) + 'Lorem ipsum dolorsit ' + brMarkup(2) + 'amet Lorem ipsum ' + brMarkup(3) + 'dolorsit amet Lorem ' + brMarkup(4) + 'ipsum dolorsit amet'); }); it('highlights the last line', function () { var inHtml = lineNumberingService.insertLineNumbers("Lorem ipsum dolorsit amet", 5); var highlighted = lineNumberingService.highlightLine(inHtml, 5); expect(highlighted).toBe(noMarkup(1) + 'Lorem ' + brMarkup(2) + 'ipsum ' + brMarkup(3) + 'dolor' + brMarkup(4) + 'sit ' + brMarkup(5) + 'amet'); }); it('highlights the first line', function () { var inHtml = lineNumberingService.insertLineNumbers("Lorem ipsum dolorsit amet", 5); var highlighted = lineNumberingService.highlightLine(inHtml, 1); expect(highlighted).toBe(noMarkup(1) + 'Lorem ' + brMarkup(2) + 'ipsum ' + brMarkup(3) + 'dolor' + brMarkup(4) + 'sit ' + brMarkup(5) + 'amet'); }); it('does not change the string if the line number is not found', function () { var inHtml = lineNumberingService.insertLineNumbers("Lorem ipsum dolorsit amet", 5); var highlighted = lineNumberingService.highlightLine(inHtml, 8); expect(highlighted).toBe(noMarkup(1) + 'Lorem ' + brMarkup(2) + 'ipsum ' + brMarkup(3) + 'dolor' + brMarkup(4) + 'sit ' + brMarkup(5) + 'amet'); }); }); describe('caching', function() { it('caches based on line length', function () { var inHtml = '

' +longstr(100) + '

'; var outHtml80 = lineNumberingService.insertLineNumbers(inHtml, 80); var outHtml70 = lineNumberingService.insertLineNumbers(inHtml, 70); expect(outHtml70).not.toBe(outHtml80); }); }); });