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

' + 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

'; baseHtmlDom1 = diffService.htmlToFragment(baseHtml1); baseHtml2 = '

' + noMarkup(1) + 'Single text line

\

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

\ \

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

\
\

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

\
\

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

'; baseHtmlDom2 = diffService.htmlToFragment(baseHtml2); baseHtml3 = '
    ' + '
  1. ' + noMarkup(1) + 'Line 1
  2. ' + '
  3. ' + noMarkup(2) + 'Line 2
  4. ' + '
    1. ' + '
    2. ' + noMarkup(3) + 'Line 3.1
    3. ' + '
    4. ' + noMarkup(4) + 'Line 3.2
    5. ' + '
    6. ' + noMarkup(5) + 'Line 3.3
    7. ' + '
  5. ' + '
  6. ' + noMarkup(6) + ' Line 4
'; baseHtmlDom3 = diffService.htmlToFragment(baseHtml3); 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('