describe('linenumbering', function () { beforeEach(module('OpenSlidesApp.motions.diff')); var diffService, baseHtmlDom1, baseHtmlDom2, brMarkup = function (no) { return '
' + ' '; }, noMarkup = function (no) { return ' '; }; beforeEach(inject(function (_diffService_) { diffService = _diffService_; baseHtmlDom1 = diffService.htmlToFragment('

' + noMarkup(1) + 'Line 1 ' + brMarkup(2) + 'Line 2' + brMarkup(3) + 'Line 3
' + noMarkup(4) + 'Line 4 ' + brMarkup(5) + 'Line
5

' + '' + '

' + noMarkup(10) + 'Line 10 ' + brMarkup(11) + 'Line 11

'); baseHtmlDom2 = diffService.htmlToFragment('

 Single text line

\

 sdfsdfsdfsdf dsfsdfsdfdsflkewjrl ksjfl ksdjf klnlkjBavaria ipsum dolor sit amet Biazelt Auffisteign
 Schorsch mim Radl foahn Ohrwaschl Steckerleis wann griagd ma nacha wos z’dringa glacht Mamalad,
' + ' muass? I bin a woschechta Bayer sowos oamoi und sei und glei wirds no fui lustiga: Jo mei khkhis des
 schee middn ognudelt, Trachtnhuat Biawambn gscheid: Griasd eich midnand etza nix Gwiass woass ma ned
' + ' owe. Dahoam gscheckate middn Spuiratz des is a gmahde Wiesn. Des is schee so Obazda san da, Haferl
 pfenningguat schoo griasd eich midnand.

\ \

 I waar soweid Blosmusi es nomoi. Broadwurschtbudn des is a gmahde Wiesn Kirwa mogsd a Bussal
 Guglhupf schüds nei. Luja i moan oiwei Baamwach Watschnbaam, wiavui baddscher! Biakriagal a fescha
' + ' 1Bua Semmlkneedl iabaroi oba um Godds wujn Ledahosn wui Greichats. Geh um Godds wujn luja heid
 greaßt eich nachad woaß Breihaus eam! De om auf’n Gipfe auf gehds beim Schichtl mehra Baamwach a
 bissal wos gehd ollaweil gscheid:

\
\

 Scheans Schdarmbeaga See i hob di narrisch gean i jo mei is des schee! Nia eam
 hod vasteh i sog ja nix, i red ja bloß sammawiedaguad, umma eana obandeln! Zwoa
 jo mei scheans amoi, san und hoggd Milli barfuaßat gscheit. Foidweg vui huift
' + ' vui singan, mehra Biakriagal om auf’n Gipfe! Ozapfa sodala Charivari greaßt eich
 nachad Broadwurschtbudn do middn liberalitas Bavariae sowos Leonhardifahrt:

\
\

 Wui helfgod Wiesn, ognudelt schaugn: Dahoam gelbe Rüam Schneid singan wo hi sauba i moan scho aa no
 a Maß a Maß und no a Maß nimma. Is umananda a ganze Hoiwe zwoa, Schneid. Vui huift vui Brodzeid kumm
' + ' geh naa i daad vo de allerweil, gor. Woaß wia Gams, damischa. A ganze Hoiwe Ohrwaschl Greichats
 iabaroi Prosd Engelgwand nix Reiwadatschi.Weibaleid ognudelt Ledahosn noch da Giasinga Heiwog i daad
' + ' Almrausch, Ewig und drei Dog nackata wea ko, dea ko. Meidromml Graudwiggal nois dei, nackata. No
 Diandldrahn nix Gwiass woass ma ned hod boarischer: Samma sammawiedaguad wos, i hoam Brodzeid. Jo
' + ' mei Sepp Gaudi, is ma Wuascht do Hendl Xaver Prosd eana an a bravs. Sauwedda an Brezn, abfieseln.

'); diffService._insertInternalLineMarkers(baseHtmlDom1); diffService._insertInternalLineMarkers(baseHtmlDom2); })); describe('extraction of lines', function () { it('locates line number nodes', function() { var lineNumberNode = diffService.getLineNumberNode(baseHtmlDom1, 4); expect(lineNumberNode.parentNode.nodeName).toBe('STRONG'); lineNumberNode = diffService.getLineNumberNode(baseHtmlDom1, 9); expect(lineNumberNode.parentNode.nodeName).toBe('UL'); lineNumberNode = diffService.getLineNumberNode(baseHtmlDom1, 15); expect(lineNumberNode).toBe(null); }); it('finds the common ancestor', function() { var fromLineNode, toLineNode, commonAncestor; fromLineNode = diffService.getLineNumberNode(baseHtmlDom1, 6); toLineNode = diffService.getLineNumberNode(baseHtmlDom1, 7); commonAncestor = diffService._getCommonAncestor(fromLineNode, toLineNode); expect(commonAncestor.commonAncestor.nodeName).toBe("#document-fragment"); fromLineNode = diffService.getLineNumberNode(baseHtmlDom1, 6); toLineNode = diffService.getLineNumberNode(baseHtmlDom1, 8); commonAncestor = diffService._getCommonAncestor(fromLineNode, toLineNode); expect(commonAncestor.commonAncestor.nodeName).toBe("#document-fragment"); fromLineNode = diffService.getLineNumberNode(baseHtmlDom1, 6); toLineNode = diffService.getLineNumberNode(baseHtmlDom1, 10); commonAncestor = diffService._getCommonAncestor(fromLineNode, toLineNode); expect(commonAncestor.commonAncestor.nodeName).toBe("#document-fragment"); }); it('renders DOMs correctly (1)', function() { var lineNo = diffService.getLineNumberNode(baseHtmlDom1, 7), greatParent = lineNo.parentNode.parentNode, lineTrace = [lineNo.parentNode, lineNo]; var pre = diffService._serializePartialDomToChild(greatParent, lineTrace, true); expect(pre).toBe(''); }); it('renders DOMs correctly (2)', function() { var lineNo = diffService.getLineNumberNode(baseHtmlDom1, 9), greatParent = lineNo.parentNode.parentNode, lineTrace = [lineNo.parentNode, lineNo]; var pre = diffService._serializePartialDomToChild(greatParent, lineTrace, true); expect(pre).toBe('
  • '); expect(diff.followingHtmlStartSnippet).toBe('