Update tests for new design improvements

This commit is contained in:
Rodrigo Fernandes 2016-05-21 01:34:03 +01:00
parent f32c6c9f67
commit fa9bdebe4c
No known key found for this signature in database
GPG key ID: 08E3C5F38969078E
11 changed files with 582 additions and 302 deletions

View file

@ -38,7 +38,7 @@
fileIcon: fileIconTemplate, fileIcon: fileIconTemplate,
fileTag: fileTagTemplate fileTag: fileTagTemplate
}) })
}) });
}; };
LineByLinePrinter.prototype.makeLineByLineHtmlWrapper = function(content) { LineByLinePrinter.prototype.makeLineByLineHtmlWrapper = function(content) {
@ -203,6 +203,7 @@
LineByLinePrinter.prototype._generateEmptyDiff = function() { LineByLinePrinter.prototype._generateEmptyDiff = function() {
return hoganUtils.render(genericTemplatesPath, 'empty-diff', { return hoganUtils.render(genericTemplatesPath, 'empty-diff', {
contentClass: 'd2h-code-line',
diffParser: diffParser diffParser: diffParser
}); });
}; };

View file

@ -236,6 +236,7 @@
fileHtml.right = ''; fileHtml.right = '';
fileHtml.left = hoganUtils.render(genericTemplatesPath, 'empty-diff', { fileHtml.left = hoganUtils.render(genericTemplatesPath, 'empty-diff', {
contentClass: 'd2h-code-side-line',
diffParser: diffParser diffParser: diffParser
}); });

View file

@ -1,9 +1,9 @@
(function() { (function() {
if (!!!global.browserTemplates) global.browserTemplates = {}; if (!!!global.browserTemplates) global.browserTemplates = {};
var Hogan = require("hogan.js");global.browserTemplates["file-summary-line"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<li class=\"d2h-file-list-line\">");t.b("\n" + i);t.b(" <span class=\"d2h-file-name-wrapper\">");t.b("\n" + i);t.b(" <span>");t.b(t.rp("<fileIcon0",c,p,""));t.b("</span>");t.b("\n" + i);t.b(" <a href=\"");t.b(t.v(t.f("fileHtmlId",c,p,0)));t.b("\" class=\"d2h-file-name\">");t.b(t.v(t.f("fileName",c,p,0)));t.b("</a>");t.b("\n" + i);t.b(" <span class=\"d2h-file-stats\">");t.b("\n" + i);t.b(" <span class=\"d2h-lines-added\">");t.b(t.v(t.f("addedLines",c,p,0)));t.b("</span>");t.b("\n" + i);t.b(" <span class=\"d2h-lines-deleted\">");t.b(t.v(t.f("deletedLines",c,p,0)));t.b("</span>");t.b("\n" + i);t.b(" </span>");t.b("\n" + i);t.b(" </span>");t.b("\n" + i);t.b("</li>");return t.fl(); },partials: {"<fileIcon0":{name:"fileIcon", partials: {}, subs: { }}}, subs: { }}); var Hogan = require("hogan.js");global.browserTemplates["file-summary-line"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<li class=\"d2h-file-list-line\">");t.b("\n" + i);t.b(" <span class=\"d2h-file-name-wrapper\">");t.b("\n" + i);t.b(" <span>");t.b(t.rp("<fileIcon0",c,p,""));t.b("</span>");t.b("\n" + i);t.b(" <a href=\"#");t.b(t.v(t.f("fileHtmlId",c,p,0)));t.b("\" class=\"d2h-file-name\">");t.b(t.v(t.f("fileName",c,p,0)));t.b("</a>");t.b("\n" + i);t.b(" <span class=\"d2h-file-stats\">");t.b("\n" + i);t.b(" <span class=\"d2h-lines-added\">");t.b(t.v(t.f("addedLines",c,p,0)));t.b("</span>");t.b("\n" + i);t.b(" <span class=\"d2h-lines-deleted\">");t.b(t.v(t.f("deletedLines",c,p,0)));t.b("</span>");t.b("\n" + i);t.b(" </span>");t.b("\n" + i);t.b(" </span>");t.b("\n" + i);t.b("</li>");return t.fl(); },partials: {"<fileIcon0":{name:"fileIcon", partials: {}, subs: { }}}, subs: { }});
global.browserTemplates["file-summary-wrapper"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<div class=\"d2h-file-list-wrapper\">");t.b("\n" + i);t.b(" <div class=\"d2h-file-list-header\">");t.b("\n" + i);t.b(" <span class=\"d2h-file-list-title\">Files changed (");t.b(t.v(t.f("filesNumber",c,p,0)));t.b(")</span>");t.b("\n" + i);t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>");t.b("\n" + i);t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" <ol class=\"d2h-file-list\">");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("files",c,p,0)));t.b("\n" + i);t.b(" </ol>");t.b("\n" + i);t.b("</div>");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["file-summary-wrapper"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<div class=\"d2h-file-list-wrapper\">");t.b("\n" + i);t.b(" <div class=\"d2h-file-list-header\">");t.b("\n" + i);t.b(" <span class=\"d2h-file-list-title\">Files changed (");t.b(t.v(t.f("filesNumber",c,p,0)));t.b(")</span>");t.b("\n" + i);t.b(" <a class=\"d2h-file-switch d2h-hide\">hide</a>");t.b("\n" + i);t.b(" <a class=\"d2h-file-switch d2h-show\">show</a>");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" <ol class=\"d2h-file-list\">");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("files",c,p,0)));t.b("\n" + i);t.b(" </ol>");t.b("\n" + i);t.b("</div>");return t.fl(); },partials: {}, subs: { }});
global.browserTemplates["generic-column-line-number"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<tr>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.f("lineClass",c,p,0)));t.b(" ");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\"></td>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" <div class=\"");t.b(t.v(t.f("contentClass",c,p,0)));t.b(" ");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b(t.t(t.f("blockHeader",c,p,0)));t.b("</div>");t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b("</tr>");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["generic-column-line-number"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<tr>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.f("lineClass",c,p,0)));t.b(" ");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\"></td>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" <div class=\"");t.b(t.v(t.f("contentClass",c,p,0)));t.b(" ");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b(t.t(t.f("blockHeader",c,p,0)));t.b("</div>");t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b("</tr>");return t.fl(); },partials: {}, subs: { }});
global.browserTemplates["generic-empty-diff"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<tr>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" <div class=\"d2h-code-line ");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" File without changes");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b("</tr>");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["generic-empty-diff"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<tr>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" <div class=\"");t.b(t.v(t.f("contentClass",c,p,0)));t.b(" ");t.b(t.v(t.d("diffParser.LINE_TYPE.INFO",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" File without changes");t.b("\n" + i);t.b(" </div>");t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b("</tr>");return t.fl(); },partials: {}, subs: { }});
global.browserTemplates["generic-file-path"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<span class=\"d2h-file-name-wrapper\">");t.b("\n" + i);t.b(" <span class=\"d2h-icon-wrapper\">");t.b(t.rp("<fileIcon0",c,p,""));t.b("</span>");t.b("\n" + i);t.b(" <span class=\"d2h-file-name\">");t.b(t.v(t.f("fileDiffName",c,p,0)));t.b("</span>");t.b("\n" + i);t.b(t.rp("<fileTag1",c,p," "));t.b("</span>");return t.fl(); },partials: {"<fileIcon0":{name:"fileIcon", partials: {}, subs: { }},"<fileTag1":{name:"fileTag", partials: {}, subs: { }}}, subs: { }}); global.browserTemplates["generic-file-path"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<span class=\"d2h-file-name-wrapper\">");t.b("\n" + i);t.b(" <span class=\"d2h-icon-wrapper\">");t.b(t.rp("<fileIcon0",c,p,""));t.b("</span>");t.b("\n" + i);t.b(" <span class=\"d2h-file-name\">");t.b(t.v(t.f("fileDiffName",c,p,0)));t.b("</span>");t.b("\n" + i);t.b(t.rp("<fileTag1",c,p," "));t.b("</span>");return t.fl(); },partials: {"<fileIcon0":{name:"fileIcon", partials: {}, subs: { }},"<fileTag1":{name:"fileTag", partials: {}, subs: { }}}, subs: { }});
global.browserTemplates["generic-line"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<tr>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.f("lineClass",c,p,0)));t.b(" ");t.b(t.v(t.f("type",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("lineNumber",c,p,0)));t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.f("type",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" <div class=\"");t.b(t.v(t.f("contentClass",c,p,0)));t.b(" ");t.b(t.v(t.f("type",c,p,0)));t.b("\">");t.b("\n" + i);if(t.s(t.f("prefix",c,p,1),c,p,0,171,247,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" <span class=\"d2h-code-line-prefix\">");t.b(t.t(t.f("prefix",c,p,0)));t.b("</span>");t.b("\n" + i);});c.pop();}if(t.s(t.f("content",c,p,1),c,p,0,279,353,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" <span class=\"d2h-code-line-ctn\">");t.b(t.t(t.f("content",c,p,0)));t.b("</span>");t.b("\n" + i);});c.pop();}t.b(" </div>");t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b("</tr>");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["generic-line"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<tr>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.f("lineClass",c,p,0)));t.b(" ");t.b(t.v(t.f("type",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("lineNumber",c,p,0)));t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b(" <td class=\"");t.b(t.v(t.f("type",c,p,0)));t.b("\">");t.b("\n" + i);t.b(" <div class=\"");t.b(t.v(t.f("contentClass",c,p,0)));t.b(" ");t.b(t.v(t.f("type",c,p,0)));t.b("\">");t.b("\n" + i);if(t.s(t.f("prefix",c,p,1),c,p,0,171,247,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" <span class=\"d2h-code-line-prefix\">");t.b(t.t(t.f("prefix",c,p,0)));t.b("</span>");t.b("\n" + i);});c.pop();}if(t.s(t.f("content",c,p,1),c,p,0,279,353,"{{ }}")){t.rs(c,p,function(c,p,t){t.b(" <span class=\"d2h-code-line-ctn\">");t.b(t.t(t.f("content",c,p,0)));t.b("</span>");t.b("\n" + i);});c.pop();}t.b(" </div>");t.b("\n" + i);t.b(" </td>");t.b("\n" + i);t.b("</tr>");return t.fl(); },partials: {}, subs: { }});
global.browserTemplates["generic-wrapper"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<div class=\"d2h-wrapper\">");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("content",c,p,0)));t.b("\n" + i);t.b("</div>");return t.fl(); },partials: {}, subs: { }}); global.browserTemplates["generic-wrapper"] = new Hogan.Template({code: function (c,p,i) { var t=this;t.b(i=i||"");t.b("<div class=\"d2h-wrapper\">");t.b("\n" + i);t.b(" ");t.b(t.t(t.f("content",c,p,0)));t.b("\n" + i);t.b("</div>");return t.fl(); },partials: {}, subs: { }});

View file

@ -1,7 +1,7 @@
<li class="d2h-file-list-line"> <li class="d2h-file-list-line">
<span class="d2h-file-name-wrapper"> <span class="d2h-file-name-wrapper">
<span>{{>fileIcon}}</span> <span>{{>fileIcon}}</span>
<a href="{{fileHtmlId}}" class="d2h-file-name">{{fileName}}</a> <a href="#{{fileHtmlId}}" class="d2h-file-name">{{fileName}}</a>
<span class="d2h-file-stats"> <span class="d2h-file-stats">
<span class="d2h-lines-added">{{addedLines}}</span> <span class="d2h-lines-added">{{addedLines}}</span>
<span class="d2h-lines-deleted">{{deletedLines}}</span> <span class="d2h-lines-deleted">{{deletedLines}}</span>

View file

@ -1,6 +1,6 @@
<tr> <tr>
<td class="{{diffParser.LINE_TYPE.INFO}}"> <td class="{{diffParser.LINE_TYPE.INFO}}">
<div class="d2h-code-line {{diffParser.LINE_TYPE.INFO}}"> <div class="{{contentClass}} {{diffParser.LINE_TYPE.INFO}}">
File without changes File without changes
</div> </div>
</td> </td>

View file

@ -304,6 +304,7 @@
font-size: 10px; font-size: 10px;
margin-left: 5px; margin-left: 5px;
padding: 0 2px; padding: 0 2px;
background-color: #fff;
} }
.d2h-deleted-tag { .d2h-deleted-tag {

View file

@ -43,40 +43,39 @@ var jsonExample1 =
var filesExample1 = var filesExample1 =
'<div class="d2h-file-list-wrapper">\n' + '<div class="d2h-file-list-wrapper">\n' +
' <div class="d2h-file-list-header">\n' + ' <div class="d2h-file-list-header">\n' +
' <span class="d2h-file-list-title">Files changed (1)&nbsp&nbsp</span>\n' + ' <span class="d2h-file-list-title">Files changed (1)</span>\n' +
' <a class="d2h-file-switch d2h-hide">hide</a>\n' + ' <a class="d2h-file-switch d2h-hide">hide</a>\n' +
' <a class="d2h-file-switch d2h-show">show</a>\n' + ' <a class="d2h-file-switch d2h-show">show</a>\n' +
' </div>\n' + ' </div>\n' +
' <table class="d2h-file-list">\n' + ' <ol class="d2h-file-list">\n' +
' <tr class="d2h-file-list-line">\n' + ' <li class="d2h-file-list-line">\n' +
' <td class="d2h-lines-added">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span>+1</span>\n' + ' <span><svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"\n' +
' </td>\n' + ' viewBox="0 0 14 16" width="14">\n' +
' <td class="d2h-lines-deleted">\n' + ' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>\n' +
' <span>-1</span>\n' + '</svg></span>\n' +
' </td>\n' + ' <a href="#d2h-675094" class="d2h-file-name">sample</a>\n' +
' <td class="d2h-file-name-wrapper">\n' + ' <span class="d2h-file-stats">\n' +
' <a href="#d2h-675094" class="d2h-file-name">&nbsp;sample </a>\n' + ' <span class="d2h-lines-added">+1</span>\n' +
' </td>\n' + ' <span class="d2h-lines-deleted">-1</span>\n' +
' </tr>\n' + ' </span>\n' +
'</table></div>\n'; ' </span>\n' +
'</li>\n' +
' </ol>\n' +
'</div>';
var htmlLineExample1 = var htmlLineExample1 =
'<div class="d2h-wrapper">\n' + '<div class="d2h-wrapper">\n' +
' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="">\n' + ' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="">\n' +
' <div class="d2h-file-header">\n' + ' <div class="d2h-file-header">\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">\n' +
' <span>+1</span>\n' +
' </span>\n' +
' <span class="d2h-lines-deleted">\n' +
' <span>-1</span>\n' +
' </span>\n' +
' </span>\n' +
' <span class="d2h-file-name-wrapper">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-file-name">&nbsp;sample</span>\n' + ' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' </span>\n' + ' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
'</svg></span>\n' +
' <span class="d2h-file-name">sample</span>\n' +
' <span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>\n' +
' </div>\n' + ' </div>\n' +
' <div class="d2h-file-diff">\n' + ' <div class="d2h-file-diff">\n' +
' <div class="d2h-code-wrapper">\n' + ' <div class="d2h-code-wrapper">\n' +
@ -85,12 +84,12 @@ var htmlLineExample1 =
' <tr>\n' + ' <tr>\n' +
' <td class="d2h-code-linenumber d2h-info"></td>\n' + ' <td class="d2h-code-linenumber d2h-info"></td>\n' +
' <td class="d2h-info">\n' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-line d2h-info"></div>\n' + ' <div class="d2h-code-line d2h-info">@@ -1 +1 @@</div>\n' +
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-del">\n' + ' <td class="d2h-code-linenumber d2h-del">\n' +
' <div class="line-num1">1</div>\n' + ' <div class="line-num1">1</div>\n' +
' <div class="line-num2"></div>\n' + '<div class="line-num2"></div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-del">\n' + ' <td class="d2h-del">\n' +
' <div class="d2h-code-line d2h-del">\n' + ' <div class="d2h-code-line d2h-del">\n' +
@ -100,8 +99,8 @@ var htmlLineExample1 =
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">1</div>\n' + '<div class="line-num2">1</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +
@ -121,60 +120,67 @@ var htmlLineExample1WithFilesSummary = filesExample1 + htmlLineExample1;
var htmlSideExample1 = var htmlSideExample1 =
'<div class="d2h-wrapper">\n' + '<div class="d2h-wrapper">\n' +
'<div id="d2h-675094" class="d2h-file-wrapper" data-lang="undefined">\n' + ' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="">\n' +
' <div class="d2h-file-header">\n' + ' <div class="d2h-file-header">\n' +
' <span class="d2h-file-stats">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-lines-added">\n' + ' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' <span>+1</span>\n' + ' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
' </span>\n' + '</svg></span>\n' +
' <span class="d2h-lines-deleted">\n' + ' <span class="d2h-file-name">sample</span>\n' +
' <span>-1</span>\n' + ' <span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>\n' +
' </span>\n' + ' </div>\n' +
' </span>\n' + ' <div class="d2h-files-diff">\n' +
' <span class="d2h-file-name-wrapper">\n' + ' <div class="d2h-file-side-diff">\n' +
' <span class="d2h-file-name">sample</span>\n' + ' <div class="d2h-code-wrapper">\n' +
' </span>\n' + ' <table class="d2h-diff-table">\n' +
' </div>\n' + ' <tbody class="d2h-diff-tbody">\n' +
' <div class="d2h-files-diff">\n' + ' <tr>\n' +
' <div class="d2h-file-side-diff">\n' + ' <td class="d2h-code-side-linenumber d2h-info"></td>\n' +
' <div class="d2h-code-wrapper">\n' + ' <td class="d2h-info">\n' +
' <table class="d2h-diff-table">\n' + ' <div class="d2h-code-side-line d2h-info">@@ -1 +1 @@</div>\n' +
' <tbody class="d2h-diff-tbody">\n' + ' </td>\n' +
' <tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-side-linenumber d2h-info"></td>\n' + ' <td class="d2h-code-side-linenumber d2h-del">\n' +
' <td class="d2h-info">\n' + ' 1\n' +
' <div class="d2h-code-side-line d2h-info">@@ -1 +1 @@</div>\n' + ' </td>\n' +
' </td>\n' + ' <td class="d2h-del">\n' +
' <div class="d2h-code-side-line d2h-del">\n' +
' <span class="d2h-code-line-prefix">-</span>\n' +
' <span class="d2h-code-line-ctn"><del>test</del></span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>\n' + '</tr>\n' +
'<tr>\n' + ' </tbody>\n' +
' <td class="d2h-code-side-linenumber d2h-del">1</td>\n' + ' </table>\n' +
' <td class="d2h-del"> <div class="d2h-code-side-line d2h-del"><span class="d2h-code-line-prefix">-</span><span class="d2h-code-line-ctn"><del>test</del></span></div> </td>\n' + ' </div>\n' +
' </tr>\n' + ' </div>\n' +
' </tbody>\n' + ' <div class="d2h-file-side-diff">\n' +
' </table>\n' + ' <div class="d2h-code-wrapper">\n' +
' </div>\n' + ' <table class="d2h-diff-table">\n' +
' </div>\n' + ' <tbody class="d2h-diff-tbody">\n' +
' <div class="d2h-file-side-diff">\n' + ' <tr>\n' +
' <div class="d2h-code-wrapper">\n' + ' <td class="d2h-code-side-linenumber d2h-info"></td>\n' +
' <table class="d2h-diff-table">\n' + ' <td class="d2h-info">\n' +
' <tbody class="d2h-diff-tbody">\n' + ' <div class="d2h-code-side-line d2h-info"></div>\n' +
' <tr>\n' + ' </td>\n' +
' <td class="d2h-code-side-linenumber d2h-info"></td>\n' + '</tr><tr>\n' +
' <td class="d2h-info">\n' + ' <td class="d2h-code-side-linenumber d2h-ins">\n' +
' <div class="d2h-code-side-line d2h-info"></div>\n' + ' 1\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' +
' <div class="d2h-code-side-line d2h-ins">\n' +
' <span class="d2h-code-line-prefix">+</span>\n' +
' <span class="d2h-code-line-ctn"><ins>test1</ins></span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>\n' + '</tr>\n' +
'<tr>\n' + ' </tbody>\n' +
' <td class="d2h-code-side-linenumber d2h-ins">1</td>\n' + ' </table>\n' +
' <td class="d2h-ins"> <div class="d2h-code-side-line d2h-ins"><span class="d2h-code-line-prefix">+</span><span class="d2h-code-line-ctn"><ins>test1</ins></span></div> </td>\n' + ' </div>\n' +
' </tr>\n' + ' </div>\n' +
' </tbody>\n' + ' </div>\n' +
' </table>\n' + '</div>\n' +
' </div>\n' + '</div>';
' </div>\n' +
' </div>\n' +
' </div>\n' +
'</div>\n';
var htmlSideExample1WithFilesSummary = filesExample1 + htmlSideExample1; var htmlSideExample1WithFilesSummary = filesExample1 + htmlSideExample1;

View file

@ -0,0 +1,105 @@
var assert = require('assert');
var fileListPrinter = require('../src/file-list-printer.js').FileListPrinter;
describe('FileListPrinter', function() {
describe('generateFileList', function() {
it('should work for all kinds of files', function() {
var files = [{
addedLines: 12,
deletedLines: 41,
language: 'js',
oldName: 'my/file/name.js',
newName: 'my/file/name.js'
}, {
addedLines: 12,
deletedLines: 41,
language: 'js',
oldName: 'my/file/name1.js',
newName: 'my/file/name2.js'
}, {
addedLines: 12,
deletedLines: 0,
language: 'js',
oldName: 'dev/null',
newName: 'my/file/name.js',
isNew: true
}, {
addedLines: 0,
deletedLines: 41,
language: 'js',
oldName: 'my/file/name.js',
newName: 'dev/null',
isDeleted: true
}];
var fileHtml = fileListPrinter.generateFileList(files);
var expected =
'<div class="d2h-file-list-wrapper">\n' +
' <div class="d2h-file-list-header">\n' +
' <span class="d2h-file-list-title">Files changed (4)</span>\n' +
' <a class="d2h-file-switch d2h-hide">hide</a>\n' +
' <a class="d2h-file-switch d2h-show">show</a>\n' +
' </div>\n' +
' <ol class="d2h-file-list">\n' +
' <li class="d2h-file-list-line">\n' +
' <span class="d2h-file-name-wrapper">\n' +
' <span><svg aria-hidden="true" class="d2h-icon d2h-changed" height="16" title="modified" version="1.1"\n' +
' viewBox="0 0 14 16" width="14">\n' +
' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM4 8c0-1.66 1.34-3 3-3s3 1.34 3 3-1.34 3-3 3-3-1.34-3-3z"></path>\n' +
'</svg></span>\n' +
' <a href="#d2h-781444" class="d2h-file-name">my/file/name.js</a>\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">+12</span>\n' +
' <span class="d2h-lines-deleted">-41</span>\n' +
' </span>\n' +
' </span>\n' +
'</li>\n' +
'<li class="d2h-file-list-line">\n' +
' <span class="d2h-file-name-wrapper">\n' +
' <span><svg aria-hidden="true" class="d2h-icon d2h-moved" height="16" title="renamed" version="1.1"\n' +
' viewBox="0 0 14 16" width="14">\n' +
' <path d="M6 9H3V7h3V4l5 4-5 4V9z m8-7v12c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h12c0.55 0 1 0.45 1 1z m-1 0H1v12h12V2z"></path>\n' +
'</svg></span>\n' +
' <a href="#d2h-662683" class="d2h-file-name">my/file/{name1.js → name2.js}</a>\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">+12</span>\n' +
' <span class="d2h-lines-deleted">-41</span>\n' +
' </span>\n' +
' </span>\n' +
'</li>\n' +
'<li class="d2h-file-list-line">\n' +
' <span class="d2h-file-name-wrapper">\n' +
' <span><svg aria-hidden="true" class="d2h-icon d2h-added" height="16" title="added" version="1.1" viewBox="0 0 14 16"\n' +
' width="14">\n' +
' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM6 9H3V7h3V4h2v3h3v2H8v3H6V9z"></path>\n' +
'</svg></span>\n' +
' <a href="#d2h-781444" class="d2h-file-name">my/file/name.js</a>\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">+12</span>\n' +
' <span class="d2h-lines-deleted">-0</span>\n' +
' </span>\n' +
' </span>\n' +
'</li>\n' +
'<li class="d2h-file-list-line">\n' +
' <span class="d2h-file-name-wrapper">\n' +
' <span><svg aria-hidden="true" class="d2h-icon d2h-deleted" height="16" title="removed" version="1.1"\n' +
' viewBox="0 0 14 16" width="14">\n' +
' <path d="M13 1H1C0.45 1 0 1.45 0 2v12c0 0.55 0.45 1 1 1h12c0.55 0 1-0.45 1-1V2c0-0.55-0.45-1-1-1z m0 13H1V2h12v12zM11 9H3V7h8v2z"></path>\n' +
'</svg></span>\n' +
' <a href="#d2h-781444" class="d2h-file-name">my/file/name.js</a>\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">+0</span>\n' +
' <span class="d2h-lines-deleted">-41</span>\n' +
' </span>\n' +
' </span>\n' +
'</li>\n' +
' </ol>\n' +
'</div>';
assert.equal(expected, fileHtml);
});
});
});

View file

@ -1,28 +1,35 @@
var assert = require('assert'); var assert = require('assert');
var HoganJsUtils = require('../src/hoganjs-utils.js').HoganJsUtils; var HoganJsUtils = require('../src/hoganjs-utils.js').HoganJsUtils;
var diffParser = require('../src/diff-parser.js').DiffParser;
describe('HoganJsUtils', function() { describe('HoganJsUtils', function() {
describe('render', function() { describe('render', function() {
var emptyDiffHtml = var emptyDiffHtml =
'<tr>\n' + '<tr>\n' +
' <td class="">\n' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-line ">\n' + ' <div class="d2h-code-line d2h-info">\n' +
' File without changes\n' + ' File without changes\n' +
' </div>\n' + ' </div>\n' +
' </td>\n' + ' </td>\n' +
'</tr>'; '</tr>';
it('should render view', function() { it('should render view', function() {
var result = HoganJsUtils.render('line-by-line', 'empty-diff', {}); var result = HoganJsUtils.render('generic', 'empty-diff', {
contentClass: 'd2h-code-line',
diffParser: diffParser
});
assert.equal(emptyDiffHtml, result); assert.equal(emptyDiffHtml, result);
}); });
it('should render view without cache', function() { it('should render view without cache', function() {
var result = HoganJsUtils.render('line-by-line', 'empty-diff', {}, {noCache: true}); var result = HoganJsUtils.render('generic', 'empty-diff', {
contentClass: 'd2h-code-line',
diffParser: diffParser
}, {noCache: true});
assert.equal(emptyDiffHtml + '\n', result); assert.equal(emptyDiffHtml + '\n', result);
}); });
it('should return null if template is missing', function() { it('should return null if template is missing', function() {
var result = HoganJsUtils.render('line-by-line', 'missing-template', {}, {noCache: true}); var result = HoganJsUtils.render('generic', 'missing-template', {}, {noCache: true});
assert.equal(null, result); assert.equal(null, result);
}); });
}); });

View file

@ -31,8 +31,8 @@ describe('LineByLinePrinter', function() {
fileHtml = fileHtml.replace(/\n\n+/g, '\n'); fileHtml = fileHtml.replace(/\n\n+/g, '\n');
var expected = '<tr>\n' + var expected = '<tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">30</div>\n' + '<div class="line-num2">30</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +
@ -53,8 +53,8 @@ describe('LineByLinePrinter', function() {
fileHtml = fileHtml.replace(/\n\n+/g, '\n'); fileHtml = fileHtml.replace(/\n\n+/g, '\n');
var expected = '<tr>\n' + var expected = '<tr>\n' +
' <td class="d2h-code-linenumber d2h-del">\n' + ' <td class="d2h-code-linenumber d2h-del">\n' +
' <div class="line-num1">30</div>\n' + ' <div class="line-num1">30</div>\n' +
' <div class="line-num2"></div>\n' + '<div class="line-num2"></div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-del">\n' + ' <td class="d2h-del">\n' +
' <div class="d2h-code-line d2h-del">\n' + ' <div class="d2h-code-line d2h-del">\n' +
@ -75,8 +75,8 @@ describe('LineByLinePrinter', function() {
fileHtml = fileHtml.replace(/\n\n+/g, '\n'); fileHtml = fileHtml.replace(/\n\n+/g, '\n');
var expected = '<tr>\n' + var expected = '<tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">30</div>\n' + '<div class="line-num2">30</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +
@ -97,8 +97,8 @@ describe('LineByLinePrinter', function() {
fileHtml = fileHtml.replace(/\n\n+/g, '\n'); fileHtml = fileHtml.replace(/\n\n+/g, '\n');
var expected = '<tr>\n' + var expected = '<tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">30</div>\n' + '<div class="line-num2">30</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +
@ -119,8 +119,9 @@ describe('LineByLinePrinter', function() {
fileHtml = fileHtml.replace(/\n\n+/g, '\n'); fileHtml = fileHtml.replace(/\n\n+/g, '\n');
var expected = '<tr>\n' + var expected = '<tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">30</div>\n' + '' +
'<div class="line-num2">30</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +
@ -149,19 +150,129 @@ describe('LineByLinePrinter', function() {
var fileHtml = lineByLinePrinter.makeFileDiffHtml(file, diffs); var fileHtml = lineByLinePrinter.makeFileDiffHtml(file, diffs);
var expected = '<div id="d2h-781444" class="d2h-file-wrapper" data-lang="js">\n' + var expected =
'<div id="d2h-781444" class="d2h-file-wrapper" data-lang="js">\n' +
' <div class="d2h-file-header">\n' + ' <div class="d2h-file-header">\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">\n' +
' <span>+12</span>\n' +
' </span>\n' +
' <span class="d2h-lines-deleted">\n' +
' <span>-41</span>\n' +
' </span>\n' +
' </span>\n' +
' <span class="d2h-file-name-wrapper">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-file-name">&nbsp;my/file/name.js</span>\n' + ' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' </span>\n' + ' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
'</svg></span>\n' +
' <span class="d2h-file-name">my/file/name.js</span>\n' +
' <span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>\n' +
' </div>\n' +
' <div class="d2h-file-diff">\n' +
' <div class="d2h-code-wrapper">\n' +
' <table class="d2h-diff-table">\n' +
' <tbody class="d2h-diff-tbody">\n' +
' <span>Random Html</span>\n' +
' </tbody>\n' +
' </table>\n' +
' </div>\n' +
' </div>\n' +
'</div>';
assert.equal(expected, fileHtml);
});
it('should work for simple added file', function() {
var lineByLinePrinter = new LineByLinePrinter({});
var file = {
addedLines: 12,
deletedLines: 0,
language: 'js',
oldName: 'dev/null',
newName: 'my/file/name.js',
isNew: true
};
var diffs = '<span>Random Html</span>';
var fileHtml = lineByLinePrinter.makeFileDiffHtml(file, diffs);
var expected =
'<div id="d2h-781444" class="d2h-file-wrapper" data-lang="js">\n' +
' <div class="d2h-file-header">\n' +
' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
'</svg></span>\n' +
' <span class="d2h-file-name">my/file/name.js</span>\n' +
' <span class="d2h-tag d2h-added d2h-added-tag">ADDED</span></span>\n' +
' </div>\n' +
' <div class="d2h-file-diff">\n' +
' <div class="d2h-code-wrapper">\n' +
' <table class="d2h-diff-table">\n' +
' <tbody class="d2h-diff-tbody">\n' +
' <span>Random Html</span>\n' +
' </tbody>\n' +
' </table>\n' +
' </div>\n' +
' </div>\n' +
'</div>';
assert.equal(expected, fileHtml);
});
it('should work for simple deleted file', function() {
var lineByLinePrinter = new LineByLinePrinter({});
var file = {
addedLines: 0,
deletedLines: 41,
language: 'js',
oldName: 'my/file/name.js',
newName: 'dev/null',
isDeleted: true
};
var diffs = '<span>Random Html</span>';
var fileHtml = lineByLinePrinter.makeFileDiffHtml(file, diffs);
var expected =
'<div id="d2h-781444" class="d2h-file-wrapper" data-lang="js">\n' +
' <div class="d2h-file-header">\n' +
' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
'</svg></span>\n' +
' <span class="d2h-file-name">my/file/name.js</span>\n' +
' <span class="d2h-tag d2h-deleted d2h-deleted-tag">DELETED</span></span>\n' +
' </div>\n' +
' <div class="d2h-file-diff">\n' +
' <div class="d2h-code-wrapper">\n' +
' <table class="d2h-diff-table">\n' +
' <tbody class="d2h-diff-tbody">\n' +
' <span>Random Html</span>\n' +
' </tbody>\n' +
' </table>\n' +
' </div>\n' +
' </div>\n' +
'</div>';
assert.equal(expected, fileHtml);
});
it('should work for simple renamed file', function() {
var lineByLinePrinter = new LineByLinePrinter({});
var file = {
addedLines: 12,
deletedLines: 41,
language: 'js',
oldName: 'my/file/name1.js',
newName: 'my/file/name2.js',
isRename: true
};
var diffs = '<span>Random Html</span>';
var fileHtml = lineByLinePrinter.makeFileDiffHtml(file, diffs);
var expected =
'<div id="d2h-662683" class="d2h-file-wrapper" data-lang="js">\n' +
' <div class="d2h-file-header">\n' +
' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
'</svg></span>\n' +
' <span class="d2h-file-name">my/file/{name1.js → name2.js}</span>\n' +
' <span class="d2h-tag d2h-moved d2h-moved-tag">RENAMED</span></span>\n' +
' </div>\n' + ' </div>\n' +
' <div class="d2h-file-diff">\n' + ' <div class="d2h-file-diff">\n' +
' <div class="d2h-code-wrapper">\n' + ' <div class="d2h-code-wrapper">\n' +
@ -229,17 +340,12 @@ describe('LineByLinePrinter', function() {
'<div class="d2h-wrapper">\n' + '<div class="d2h-wrapper">\n' +
' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="">\n' + ' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="">\n' +
' <div class="d2h-file-header">\n' + ' <div class="d2h-file-header">\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">\n' +
' <span>+1</span>\n' +
' </span>\n' +
' <span class="d2h-lines-deleted">\n' +
' <span>-1</span>\n' +
' </span>\n' +
' </span>\n' +
' <span class="d2h-file-name-wrapper">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-file-name">&nbsp;sample</span>\n' + ' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' </span>\n' + ' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
'</svg></span>\n' +
' <span class="d2h-file-name">sample</span>\n' +
' <span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>\n' +
' </div>\n' + ' </div>\n' +
' <div class="d2h-file-diff">\n' + ' <div class="d2h-file-diff">\n' +
' <div class="d2h-code-wrapper">\n' + ' <div class="d2h-code-wrapper">\n' +
@ -248,12 +354,12 @@ describe('LineByLinePrinter', function() {
' <tr>\n' + ' <tr>\n' +
' <td class="d2h-code-linenumber d2h-info"></td>\n' + ' <td class="d2h-code-linenumber d2h-info"></td>\n' +
' <td class="d2h-info">\n' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-line d2h-info"></div>\n' + ' <div class="d2h-code-line d2h-info">@@ -1 +1 @@</div>\n' +
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-del d2h-change">\n' + ' <td class="d2h-code-linenumber d2h-del d2h-change">\n' +
' <div class="line-num1">1</div>\n' + ' <div class="line-num1">1</div>\n' +
' <div class="line-num2"></div>\n' + '<div class="line-num2"></div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-del d2h-change">\n' + ' <td class="d2h-del d2h-change">\n' +
' <div class="d2h-code-line d2h-del d2h-change">\n' + ' <div class="d2h-code-line d2h-del d2h-change">\n' +
@ -263,8 +369,8 @@ describe('LineByLinePrinter', function() {
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-ins d2h-change">\n' + ' <td class="d2h-code-linenumber d2h-ins d2h-change">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">1</div>\n' + '<div class="line-num2">1</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins d2h-change">\n' + ' <td class="d2h-ins d2h-change">\n' +
' <div class="d2h-code-line d2h-ins d2h-change">\n' + ' <div class="d2h-code-line d2h-ins d2h-change">\n' +
@ -300,17 +406,12 @@ describe('LineByLinePrinter', function() {
'<div class="d2h-wrapper">\n' + '<div class="d2h-wrapper">\n' +
' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="js">\n' + ' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="js">\n' +
' <div class="d2h-file-header">\n' + ' <div class="d2h-file-header">\n' +
' <span class="d2h-file-stats">\n' +
' <span class="d2h-lines-added">\n' +
' <span>+0</span>\n' +
' </span>\n' +
' <span class="d2h-lines-deleted">\n' +
' <span>-0</span>\n' +
' </span>\n' +
' </span>\n' +
' <span class="d2h-file-name-wrapper">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-file-name">&nbsp;sample</span>\n' + ' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' </span>\n' + ' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
'</svg></span>\n' +
' <span class="d2h-file-name">sample</span>\n' +
' <span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>\n' +
' </div>\n' + ' </div>\n' +
' <div class="d2h-file-diff">\n' + ' <div class="d2h-file-diff">\n' +
' <div class="d2h-code-wrapper">\n' + ' <div class="d2h-code-wrapper">\n' +
@ -356,8 +457,8 @@ describe('LineByLinePrinter', function() {
var expected = var expected =
'<tr>\n' + '<tr>\n' +
' <td class="d2h-code-linenumber d2h-del">\n' + ' <td class="d2h-code-linenumber d2h-del">\n' +
' <div class="line-num1">1</div>\n' + ' <div class="line-num1">1</div>\n' +
' <div class="line-num2"></div>\n' + '<div class="line-num2"></div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-del">\n' + ' <td class="d2h-del">\n' +
' <div class="d2h-code-line d2h-del">\n' + ' <div class="d2h-code-line d2h-del">\n' +
@ -366,8 +467,8 @@ describe('LineByLinePrinter', function() {
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">1</div>\n' + '<div class="line-num2">1</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +
@ -430,12 +531,12 @@ describe('LineByLinePrinter', function() {
'<tr>\n' + '<tr>\n' +
' <td class="d2h-code-linenumber d2h-info"></td>\n' + ' <td class="d2h-code-linenumber d2h-info"></td>\n' +
' <td class="d2h-info">\n' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-line d2h-info"></div>\n' + ' <div class="d2h-code-line d2h-info">@@ -1 +1 @@</div>\n' +
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-cntx">\n' + ' <td class="d2h-code-linenumber d2h-cntx">\n' +
' <div class="line-num1">1</div>\n' + ' <div class="line-num1">1</div>\n' +
' <div class="line-num2">1</div>\n' + '<div class="line-num2">1</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-cntx">\n' + ' <td class="d2h-cntx">\n' +
' <div class="d2h-code-line d2h-cntx">\n' + ' <div class="d2h-code-line d2h-cntx">\n' +
@ -444,8 +545,8 @@ describe('LineByLinePrinter', function() {
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-del">\n' + ' <td class="d2h-code-linenumber d2h-del">\n' +
' <div class="line-num1">2</div>\n' + ' <div class="line-num1">2</div>\n' +
' <div class="line-num2"></div>\n' + '<div class="line-num2"></div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-del">\n' + ' <td class="d2h-del">\n' +
' <div class="d2h-code-line d2h-del">\n' + ' <div class="d2h-code-line d2h-del">\n' +
@ -455,8 +556,8 @@ describe('LineByLinePrinter', function() {
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">2</div>\n' + '<div class="line-num2">2</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +
@ -466,8 +567,8 @@ describe('LineByLinePrinter', function() {
' </td>\n' + ' </td>\n' +
'</tr><tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-linenumber d2h-ins">\n' + ' <td class="d2h-code-linenumber d2h-ins">\n' +
' <div class="line-num1"></div>\n' + ' <div class="line-num1"></div>\n' +
' <div class="line-num2">3</div>\n' + '<div class="line-num2">3</div>\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins">\n' + ' <td class="d2h-ins">\n' +
' <div class="d2h-code-line d2h-ins">\n' + ' <div class="d2h-code-line d2h-ins">\n' +

View file

@ -10,11 +10,11 @@ describe('SideBySidePrinter', function() {
var fileHtml = sideBySidePrinter.generateEmptyDiff(); var fileHtml = sideBySidePrinter.generateEmptyDiff();
var expectedRight = ''; var expectedRight = '';
var expectedLeft = '<tr>\n' + var expectedLeft = '<tr>\n' +
' <td class="d2h-info">' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-side-line d2h-info">' + ' <div class="d2h-code-side-line d2h-info">\n' +
'File without changes' + ' File without changes\n' +
' </div>' + ' </div>\n' +
' </td>\n' + ' </td>\n' +
'</tr>\n'; '</tr>\n';
assert.equal(expectedRight, fileHtml.right); assert.equal(expectedRight, fileHtml.right);
@ -73,43 +73,78 @@ describe('SideBySidePrinter', function() {
var expectedLeft = var expectedLeft =
'<tr>\n' + '<tr>\n' +
' <td class="d2h-code-side-linenumber d2h-info"></td>\n' + ' <td class="d2h-code-side-linenumber d2h-info"></td>\n' +
' <td class="d2h-info">\n' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-side-line d2h-info">@@ -19,7 +19,7 @@</div>\n' + ' <div class="d2h-code-side-line d2h-info">@@ -19,7 +19,7 @@</div>\n' +
' </td>\n' + ' </td>\n' +
'</tr>\n' + '</tr><tr>\n' +
'<tr>\n' + ' <td class="d2h-code-side-linenumber d2h-cntx">\n' +
' <td class="d2h-code-side-linenumber d2h-cntx">19</td>\n' + ' 19\n' +
' <td class="d2h-cntx"> <div class="d2h-code-side-line d2h-cntx"><span class="d2h-code-line-prefix"> </span><span class="d2h-code-line-ctn">context</span></div> </td>\n' + ' </td>\n' +
' </tr>\n' + ' <td class="d2h-cntx">\n' +
'<tr>\n' + ' <div class="d2h-code-side-line d2h-cntx">\n' +
' <td class="d2h-code-side-linenumber d2h-del">20</td>\n' + ' <span class="d2h-code-line-prefix">&nbsp;</span>\n' +
' <td class="d2h-del"> <div class="d2h-code-side-line d2h-del"><span class="d2h-code-line-prefix">-</span><span class="d2h-code-line-ctn"><del>removed</del></span></div> </td>\n' + ' <span class="d2h-code-line-ctn">context</span>\n' +
' </tr>\n' + ' </div>\n' +
'<tr>\n' + ' </td>\n' +
' <td class="d2h-code-side-linenumber d2h-cntx"></td>\n' + '</tr><tr>\n' +
' <td class="d2h-cntx"> <div class="d2h-code-side-line d2h-cntx"></div> </td>\n' + ' <td class="d2h-code-side-linenumber d2h-del">\n' +
' </tr>\n'; ' 20\n' +
' </td>\n' +
' <td class="d2h-del">\n' +
' <div class="d2h-code-side-line d2h-del">\n' +
' <span class="d2h-code-line-prefix">-</span>\n' +
' <span class="d2h-code-line-ctn"><del>removed</del></span>\n' +
' </div>\n' +
' </td>\n' +
'</tr><tr>\n' +
' <td class="d2h-code-side-linenumber d2h-cntx">\n' +
' ' +
'\n' +
' </td>\n' +
' <td class="d2h-cntx">\n' +
' <div class="d2h-code-side-line d2h-cntx">\n' +
' </div>\n' +
' </td>\n' +
'</tr>';
var expectedRight = var expectedRight =
'<tr>\n' + '<tr>\n' +
' <td class="d2h-code-side-linenumber d2h-info"></td>\n' + ' <td class="d2h-code-side-linenumber d2h-info"></td>\n' +
' <td class="d2h-info">\n' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-side-line d2h-info"></div>\n' + ' <div class="d2h-code-side-line d2h-info"></div>\n' +
' </td>\n' + ' </td>\n' +
'</tr>\n' + '</tr><tr>\n' +
'<tr>\n' + ' <td class="d2h-code-side-linenumber d2h-cntx">\n' +
' <td class="d2h-code-side-linenumber d2h-cntx">19</td>\n' + ' 19\n' +
' <td class="d2h-cntx"> <div class="d2h-code-side-line d2h-cntx"><span class="d2h-code-line-prefix"> </span><span class="d2h-code-line-ctn">context</span></div> </td>\n' + ' </td>\n' +
' </tr>\n' + ' <td class="d2h-cntx">\n' +
'<tr>\n' + ' <div class="d2h-code-side-line d2h-cntx">\n' +
' <td class="d2h-code-side-linenumber d2h-ins">20</td>\n' + ' <span class="d2h-code-line-prefix">&nbsp;</span>\n' +
' <td class="d2h-ins"> <div class="d2h-code-side-line d2h-ins"><span class="d2h-code-line-prefix">+</span><span class="d2h-code-line-ctn"><ins>added</ins></span></div> </td>\n' + ' <span class="d2h-code-line-ctn">context</span>\n' +
' </tr>\n' + ' </div>\n' +
'<tr>\n' + ' </td>\n' +
' <td class="d2h-code-side-linenumber d2h-ins">21</td>\n' + '</tr><tr>\n' +
' <td class="d2h-ins"> <div class="d2h-code-side-line d2h-ins"><span class="d2h-code-line-prefix">+</span><span class="d2h-code-line-ctn">another added</span></div> </td>\n' + ' <td class="d2h-code-side-linenumber d2h-ins">\n' +
' </tr>\n'; ' 20\n' +
' </td>\n' +
' <td class="d2h-ins">\n' +
' <div class="d2h-code-side-line d2h-ins">\n' +
' <span class="d2h-code-line-prefix">+</span>\n' +
' <span class="d2h-code-line-ctn"><ins>added</ins></span>\n' +
' </div>\n' +
' </td>\n' +
'</tr><tr>\n' +
' <td class="d2h-code-side-linenumber d2h-ins">\n' +
' 21\n' +
' </td>\n' +
' <td class="d2h-ins">\n' +
' <div class="d2h-code-side-line d2h-ins">\n' +
' <span class="d2h-code-line-prefix">+</span>\n' +
' <span class="d2h-code-line-ctn">another&nbsp;added</span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>';
assert.equal(expectedLeft, fileHtml.left); assert.equal(expectedLeft, fileHtml.left);
assert.equal(expectedRight, fileHtml.right); assert.equal(expectedRight, fileHtml.right);
@ -124,11 +159,16 @@ describe('SideBySidePrinter', function() {
var fileHtml = sideBySidePrinter.generateSingleLineHtml( var fileHtml = sideBySidePrinter.generateSingleLineHtml(
diffParser.LINE_TYPE.INSERTS, 30, 'test', '+'); diffParser.LINE_TYPE.INSERTS, 30, 'test', '+');
var expected = '<tr>\n' + var expected = '<tr>\n' +
' <td class="d2h-code-side-linenumber d2h-ins">30</td>\n' + ' <td class="d2h-code-side-linenumber d2h-ins">\n' +
' <td class="d2h-ins">' + ' 30\n' +
' <div class="d2h-code-side-line d2h-ins"><span class="d2h-code-line-prefix">+</span><span class="d2h-code-line-ctn">test</span></div>' +
' </td>\n' + ' </td>\n' +
' </tr>\n'; ' <td class="d2h-ins">\n' +
' <div class="d2h-code-side-line d2h-ins">\n' +
' <span class="d2h-code-line-prefix">+</span>\n' +
' <span class="d2h-code-line-ctn">test</span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>';
assert.equal(expected, fileHtml); assert.equal(expected, fileHtml);
}); });
@ -139,11 +179,16 @@ describe('SideBySidePrinter', function() {
var fileHtml = sideBySidePrinter.generateSingleLineHtml( var fileHtml = sideBySidePrinter.generateSingleLineHtml(
diffParser.LINE_TYPE.DELETES, 30, 'test', '-'); diffParser.LINE_TYPE.DELETES, 30, 'test', '-');
var expected = '<tr>\n' + var expected = '<tr>\n' +
' <td class="d2h-code-side-linenumber d2h-del">30</td>\n' + ' <td class="d2h-code-side-linenumber d2h-del">\n' +
' <td class="d2h-del">' + ' 30\n' +
' <div class="d2h-code-side-line d2h-del"><span class="d2h-code-line-prefix">-</span><span class="d2h-code-line-ctn">test</span></div>' +
' </td>\n' + ' </td>\n' +
' </tr>\n'; ' <td class="d2h-del">\n' +
' <div class="d2h-code-side-line d2h-del">\n' +
' <span class="d2h-code-line-prefix">-</span>\n' +
' <span class="d2h-code-line-ctn">test</span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>';
assert.equal(expected, fileHtml); assert.equal(expected, fileHtml);
}); });
@ -184,60 +229,67 @@ describe('SideBySidePrinter', function() {
var html = sideBySidePrinter.generateSideBySideJsonHtml(exampleJson); var html = sideBySidePrinter.generateSideBySideJsonHtml(exampleJson);
var expected = var expected =
'<div class="d2h-wrapper">\n' + '<div class="d2h-wrapper">\n' +
'<div id="d2h-675094" class="d2h-file-wrapper" data-lang="undefined">\n' + ' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="">\n' +
' <div class="d2h-file-header">\n' + ' <div class="d2h-file-header">\n' +
' <span class="d2h-file-stats">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-lines-added">\n' + ' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' <span>+1</span>\n' + ' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
' </span>\n' + '</svg></span>\n' +
' <span class="d2h-lines-deleted">\n' + ' <span class="d2h-file-name">sample</span>\n' +
' <span>-1</span>\n' + ' <span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>\n' +
' </span>\n' + ' </div>\n' +
' </span>\n' + ' <div class="d2h-files-diff">\n' +
' <span class="d2h-file-name-wrapper">\n' + ' <div class="d2h-file-side-diff">\n' +
' <span class="d2h-file-name">sample</span>\n' + ' <div class="d2h-code-wrapper">\n' +
' </span>\n' + ' <table class="d2h-diff-table">\n' +
' </div>\n' + ' <tbody class="d2h-diff-tbody">\n' +
' <div class="d2h-files-diff">\n' + ' <tr>\n' +
' <div class="d2h-file-side-diff">\n' + ' <td class="d2h-code-side-linenumber d2h-info"></td>\n' +
' <div class="d2h-code-wrapper">\n' + ' <td class="d2h-info">\n' +
' <table class="d2h-diff-table">\n' + ' <div class="d2h-code-side-line d2h-info">@@ -1 +1 @@</div>\n' +
' <tbody class="d2h-diff-tbody">\n' + ' </td>\n' +
' <tr>\n' + '</tr><tr>\n' +
' <td class="d2h-code-side-linenumber d2h-info"></td>\n' + ' <td class="d2h-code-side-linenumber d2h-del d2h-change">\n' +
' <td class="d2h-info">\n' + ' 1\n' +
' <div class="d2h-code-side-line d2h-info">@@ -1 +1 @@</div>\n' + ' </td>\n' +
' </td>\n' + ' <td class="d2h-del d2h-change">\n' +
' <div class="d2h-code-side-line d2h-del d2h-change">\n' +
' <span class="d2h-code-line-prefix">-</span>\n' +
' <span class="d2h-code-line-ctn"><del>test</del></span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>\n' + '</tr>\n' +
'<tr>\n' + ' </tbody>\n' +
' <td class="d2h-code-side-linenumber d2h-del d2h-change">1</td>\n' + ' </table>\n' +
' <td class="d2h-del d2h-change"> <div class="d2h-code-side-line d2h-del d2h-change"><span class="d2h-code-line-prefix">-</span><span class="d2h-code-line-ctn"><del>test</del></span></div> </td>\n' + ' </div>\n' +
' </tr>\n' + ' </div>\n' +
' </tbody>\n' + ' <div class="d2h-file-side-diff">\n' +
' </table>\n' + ' <div class="d2h-code-wrapper">\n' +
' </div>\n' + ' <table class="d2h-diff-table">\n' +
' </div>\n' + ' <tbody class="d2h-diff-tbody">\n' +
' <div class="d2h-file-side-diff">\n' + ' <tr>\n' +
' <div class="d2h-code-wrapper">\n' + ' <td class="d2h-code-side-linenumber d2h-info"></td>\n' +
' <table class="d2h-diff-table">\n' + ' <td class="d2h-info">\n' +
' <tbody class="d2h-diff-tbody">\n' + ' <div class="d2h-code-side-line d2h-info"></div>\n' +
' <tr>\n' + ' </td>\n' +
' <td class="d2h-code-side-linenumber d2h-info"></td>\n' + '</tr><tr>\n' +
' <td class="d2h-info">\n' + ' <td class="d2h-code-side-linenumber d2h-ins d2h-change">\n' +
' <div class="d2h-code-side-line d2h-info"></div>\n' + ' 1\n' +
' </td>\n' + ' </td>\n' +
' <td class="d2h-ins d2h-change">\n' +
' <div class="d2h-code-side-line d2h-ins d2h-change">\n' +
' <span class="d2h-code-line-prefix">+</span>\n' +
' <span class="d2h-code-line-ctn"><ins>test1r</ins></span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>\n' + '</tr>\n' +
'<tr>\n' + ' </tbody>\n' +
' <td class="d2h-code-side-linenumber d2h-ins d2h-change">1</td>\n' + ' </table>\n' +
' <td class="d2h-ins d2h-change"> <div class="d2h-code-side-line d2h-ins d2h-change"><span class="d2h-code-line-prefix">+</span><span class="d2h-code-line-ctn"><ins>test1r</ins></span></div> </td>\n' + ' </div>\n' +
' </tr>\n' + ' </div>\n' +
' </tbody>\n' + ' </div>\n' +
' </table>\n' + '</div>\n' +
' </div>\n' + '</div>';
' </div>\n' +
' </div>\n' +
' </div>\n' +
'</div>\n';
assert.equal(expected, html); assert.equal(expected, html);
}); });
@ -254,43 +306,44 @@ describe('SideBySidePrinter', function() {
var html = sideBySidePrinter.generateSideBySideJsonHtml(exampleJson); var html = sideBySidePrinter.generateSideBySideJsonHtml(exampleJson);
var expected = var expected =
'<div class="d2h-wrapper">\n' + '<div class="d2h-wrapper">\n' +
'<div id="d2h-675094" class="d2h-file-wrapper" data-lang="js">\n' + ' <div id="d2h-675094" class="d2h-file-wrapper" data-lang="js">\n' +
' <div class="d2h-file-header">\n' + ' <div class="d2h-file-header">\n' +
' <span class="d2h-file-stats">\n' + ' <span class="d2h-file-name-wrapper">\n' +
' <span class="d2h-lines-added">\n' + ' <span class="d2h-icon-wrapper"><svg aria-hidden="true" class="d2h-icon" height="16" version="1.1" viewBox="0 0 12 16" width="12">\n' +
' <span>+undefined</span>\n' + ' <path d="M6 5H2v-1h4v1zM2 8h7v-1H2v1z m0 2h7v-1H2v1z m0 2h7v-1H2v1z m10-7.5v9.5c0 0.55-0.45 1-1 1H1c-0.55 0-1-0.45-1-1V2c0-0.55 0.45-1 1-1h7.5l3.5 3.5z m-1 0.5L8 2H1v12h10V5z"></path>\n' +
' </span>\n' + '</svg></span>\n' +
' <span class="d2h-lines-deleted">\n' + ' <span class="d2h-file-name">sample</span>\n' +
' <span>-undefined</span>\n' + ' <span class="d2h-tag d2h-changed d2h-changed-tag">CHANGED</span></span>\n' +
' </span>\n' + ' </div>\n' +
' </span>\n' + ' <div class="d2h-files-diff">\n' +
' <span class="d2h-file-name-wrapper">\n' + ' <div class="d2h-file-side-diff">\n' +
' <span class="d2h-file-name">sample</span>\n' + ' <div class="d2h-code-wrapper">\n' +
' </span>\n' + ' <table class="d2h-diff-table">\n' +
' </div>\n' + ' <tbody class="d2h-diff-tbody">\n' +
' <div class="d2h-files-diff">\n' + ' <tr>\n' +
' <div class="d2h-file-side-diff">\n' + ' <td class="d2h-info">\n' +
' <div class="d2h-code-wrapper">\n' + ' <div class="d2h-code-side-line d2h-info">\n' +
' <table class="d2h-diff-table">\n' + ' File without changes\n' +
' <tbody class="d2h-diff-tbody">\n' + ' </div>\n' +
' <tr>\n' + ' </td>\n' +
' <td class="d2h-info"> <div class="d2h-code-side-line d2h-info">File without changes </div> </td>\n' +
'</tr>\n' + '</tr>\n' +
' </tbody>\n' + '\n' +
' </table>\n' + ' </tbody>\n' +
' </div>\n' + ' </table>\n' +
' </div>\n' + ' </div>\n' +
' <div class="d2h-file-side-diff">\n' + ' </div>\n' +
' <div class="d2h-code-wrapper">\n' + ' <div class="d2h-file-side-diff">\n' +
' <table class="d2h-diff-table">\n' + ' <div class="d2h-code-wrapper">\n' +
' <tbody class="d2h-diff-tbody">\n' + ' <table class="d2h-diff-table">\n' +
' </tbody>\n' + ' <tbody class="d2h-diff-tbody">\n' +
' </table>\n' + ' \n' +
' </div>\n' + ' </tbody>\n' +
' </div>\n' + ' </table>\n' +
' </div>\n' + ' </div>\n' +
' </div>\n' + ' </div>\n' +
'</div>\n'; ' </div>\n' +
'</div>\n' +
'</div>';
assert.equal(expected, html); assert.equal(expected, html);
}); });
@ -316,24 +369,29 @@ describe('SideBySidePrinter', function() {
var html = sideBySidePrinter.processLines(oldLines, newLines); var html = sideBySidePrinter.processLines(oldLines, newLines);
var expectedLeft = var expectedLeft =
'<tr>\n' + '<tr>\n' +
' <td class="d2h-code-side-linenumber d2h-del">1</td>\n' + ' <td class="d2h-code-side-linenumber d2h-del">\n' +
' <td class="d2h-del">' + ' 1\n' +
' <div class="d2h-code-side-line d2h-del">' +
'<span class="d2h-code-line-prefix">-</span>' +
'<span class="d2h-code-line-ctn">test</span></div>' +
' </td>\n' + ' </td>\n' +
' </tr>\n'; ' <td class="d2h-del">\n' +
' <div class="d2h-code-side-line d2h-del">\n' +
' <span class="d2h-code-line-prefix">-</span>\n' +
' <span class="d2h-code-line-ctn">test</span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>';
var expectedRight = var expectedRight =
'<tr>\n' + '<tr>\n' +
' <td class="d2h-code-side-linenumber d2h-ins">1</td>\n' + ' <td class="d2h-code-side-linenumber d2h-ins">\n' +
' <td class="d2h-ins">' + ' 1\n' +
' <div class="d2h-code-side-line d2h-ins">' +
'<span class="d2h-code-line-prefix">+</span>' +
'<span class="d2h-code-line-ctn">test1r</span>' +
'</div>' +
' </td>\n' + ' </td>\n' +
' </tr>\n'; ' <td class="d2h-ins">\n' +
' <div class="d2h-code-side-line d2h-ins">\n' +
' <span class="d2h-code-line-prefix">+</span>\n' +
' <span class="d2h-code-line-ctn">test1r</span>\n' +
' </div>\n' +
' </td>\n' +
'</tr>';
assert.equal(expectedLeft, html.left); assert.equal(expectedLeft, html.left);
assert.equal(expectedRight, html.right); assert.equal(expectedRight, html.right);