GitHub, Bitbucket and GitLab commit and pull request compatible
-
Just paste the GitHub, Bitbucket or GitLab commit, pull request or merge request url
- or any other git or unified compatible diff and we will render a pretty html representation of it
- with code syntax highlight and line similarity matching for better code reviews.
-
\n' +
- ' \n' +
- '\n' +
- '';
+ " \n" +
+ " \n" +
+ "\n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ " \n" +
+ "\n" +
+ "";
-var htmlSideExample1WithFilesSummary = filesExample1 + htmlSideExample1;
+const htmlSideExample1WithFilesSummary = filesExample1 + htmlSideExample1;
-describe('Diff2Html', function() {
- describe('getJsonFromDiff', function() {
- it('should parse simple diff to json', function() {
- var diff =
- 'diff --git a/sample b/sample\n' +
- 'index 0000001..0ddf2ba\n' +
- '--- a/sample\n' +
- '+++ b/sample\n' +
- '@@ -1 +1 @@\n' +
- '-test\n' +
- '+test1\n';
- var result = Diff2Html.getJsonFromDiff(diff);
+describe("Diff2Html", function() {
+ describe("getJsonFromDiff", function() {
+ it("should parse simple diff to json", function() {
+ const diff =
+ "diff --git a/sample b/sample\n" +
+ "index 0000001..0ddf2ba\n" +
+ "--- a/sample\n" +
+ "+++ b/sample\n" +
+ "@@ -1 +1 @@\n" +
+ "-test\n" +
+ "+test1\n";
+ const result = Diff2Html.getJsonFromDiff(diff);
- var file1 = result[0];
- assert.equal(1, result.length);
- assert.equal(1, file1.addedLines);
- assert.equal(1, file1.deletedLines);
- assert.equal('sample', file1.oldName);
- assert.equal('sample', file1.newName);
- assert.equal(1, file1.blocks.length);
+ const file1 = result[0];
+ expect(1).toEqual(result.length);
+ expect(1).toEqual(file1.addedLines);
+ expect(1).toEqual(file1.deletedLines);
+ expect("sample").toEqual(file1.oldName);
+ expect("sample").toEqual(file1.newName);
+ expect(1).toEqual(file1.blocks.length);
});
// Test case for issue #49
- it('should parse diff with added EOF', function() {
- var diff =
- 'diff --git a/sample.scala b/sample.scala\n' +
- 'index b583263..8b2fc3e 100644\n' +
- '--- a/b583263..8b2fc3e\n' +
- '+++ b/8b2fc3e\n' +
- '@@ -50,5 +50,7 @@ case class Response[+A](value: Option[A],\n' +
- ' object ResponseErrorCode extends JsonEnumeration {\n' +
- ' val NoError, ServiceError, JsonError,\n' +
- ' InvalidPermissions, MissingPermissions, GenericError,\n' +
- '- TokenRevoked, MissingToken = Value\n' +
- '-}\n' +
- '\\ No newline at end of file\n' +
- '+ TokenRevoked, MissingToken,\n' +
- '+ IndexLock, RepositoryError, NotValidRepo, PullRequestNotMergeable, BranchError,\n' +
- '+ PluginError, CodeParserError, EngineError = Value\n' +
- '+}\n';
- var result = Diff2Html.getJsonFromDiff(diff);
+ it("should parse diff with added EOF", function() {
+ const diff =
+ "diff --git a/sample.scala b/sample.scala\n" +
+ "index b583263..8b2fc3e 100644\n" +
+ "--- a/b583263..8b2fc3e\n" +
+ "+++ b/8b2fc3e\n" +
+ "@@ -50,5 +50,7 @@ case class Response[+A](value: Option[A],\n" +
+ " object ResponseErrorCode extends JsonEnumeration {\n" +
+ " val NoError, ServiceError, JsonError,\n" +
+ " InvalidPermissions, MissingPermissions, GenericError,\n" +
+ "- TokenRevoked, MissingToken = Value\n" +
+ "-}\n" +
+ "\\ No newline at end of file\n" +
+ "+ TokenRevoked, MissingToken,\n" +
+ "+ IndexLock, RepositoryError, NotValidRepo, PullRequestNotMergeable, BranchError,\n" +
+ "+ PluginError, CodeParserError, EngineError = Value\n" +
+ "+}\n";
+ const result = Diff2Html.getJsonFromDiff(diff);
- assert.equal(50, result[0].blocks[0].lines[0].oldNumber);
- assert.equal(50, result[0].blocks[0].lines[0].newNumber);
+ expect(50).toEqual(result[0].blocks[0].lines[0].oldNumber);
+ expect(50).toEqual(result[0].blocks[0].lines[0].newNumber);
- assert.equal(51, result[0].blocks[0].lines[1].oldNumber);
- assert.equal(51, result[0].blocks[0].lines[1].newNumber);
+ expect(51).toEqual(result[0].blocks[0].lines[1].oldNumber);
+ expect(51).toEqual(result[0].blocks[0].lines[1].newNumber);
- assert.equal(52, result[0].blocks[0].lines[2].oldNumber);
- assert.equal(52, result[0].blocks[0].lines[2].newNumber);
+ expect(52).toEqual(result[0].blocks[0].lines[2].oldNumber);
+ expect(52).toEqual(result[0].blocks[0].lines[2].newNumber);
- assert.equal(53, result[0].blocks[0].lines[3].oldNumber);
- assert.equal(null, result[0].blocks[0].lines[3].newNumber);
+ expect(53).toEqual(result[0].blocks[0].lines[3].oldNumber);
+ expect(null).toEqual(result[0].blocks[0].lines[3].newNumber);
- assert.equal(54, result[0].blocks[0].lines[4].oldNumber);
- assert.equal(null, result[0].blocks[0].lines[4].newNumber);
+ expect(54).toEqual(result[0].blocks[0].lines[4].oldNumber);
+ expect(null).toEqual(result[0].blocks[0].lines[4].newNumber);
- assert.equal(null, result[0].blocks[0].lines[5].oldNumber);
- assert.equal(53, result[0].blocks[0].lines[5].newNumber);
+ expect(null).toEqual(result[0].blocks[0].lines[5].oldNumber);
+ expect(53).toEqual(result[0].blocks[0].lines[5].newNumber);
- assert.equal(null, result[0].blocks[0].lines[6].oldNumber);
- assert.equal(54, result[0].blocks[0].lines[6].newNumber);
+ expect(null).toEqual(result[0].blocks[0].lines[6].oldNumber);
+ expect(54).toEqual(result[0].blocks[0].lines[6].newNumber);
- assert.equal(null, result[0].blocks[0].lines[7].oldNumber);
- assert.equal(55, result[0].blocks[0].lines[7].newNumber);
+ expect(null).toEqual(result[0].blocks[0].lines[7].oldNumber);
+ expect(55).toEqual(result[0].blocks[0].lines[7].newNumber);
- assert.equal(null, result[0].blocks[0].lines[8].oldNumber);
- assert.equal(56, result[0].blocks[0].lines[8].newNumber);
+ expect(null).toEqual(result[0].blocks[0].lines[8].oldNumber);
+ expect(56).toEqual(result[0].blocks[0].lines[8].newNumber);
});
- it('should generate pretty line by line html from diff', function() {
- var result = Diff2Html.getPrettyHtmlFromDiff(diffExample1);
- assert.equal(htmlLineExample1, result);
+ it("should generate pretty line by line html from diff", function() {
+ const result = Diff2Html.getPrettyHtmlFromDiff(diffExample1);
+ expect(htmlLineExample1).toEqual(result);
});
- it('should generate pretty line by line html from json', function() {
- var result = Diff2Html.getPrettyHtmlFromJson(jsonExample1);
- assert.equal(htmlLineExample1, result);
+ it("should generate pretty line by line html from json", function() {
+ const result = Diff2Html.getPrettyHtmlFromJson(jsonExample1);
+ expect(htmlLineExample1).toEqual(result);
});
- it('should generate pretty diff with files summary', function() {
- var result = Diff2Html.getPrettyHtmlFromDiff(diffExample1, {showFiles: true});
- assert.equal(htmlLineExample1WithFilesSummary, result);
+ it("should generate pretty diff with files summary", function() {
+ const result = Diff2Html.getPrettyHtmlFromDiff(diffExample1, { showFiles: true });
+ expect(htmlLineExample1WithFilesSummary).toEqual(result);
});
- it('should generate pretty side by side html from diff', function() {
- var result = Diff2Html.getPrettySideBySideHtmlFromDiff(diffExample1);
- assert.equal(htmlSideExample1, result);
+ it("should generate pretty side by side html from diff", function() {
+ const result = Diff2Html.getPrettySideBySideHtmlFromDiff(diffExample1);
+ expect(htmlSideExample1).toEqual(result);
});
- it('should generate pretty side by side html from json', function() {
- var result = Diff2Html.getPrettySideBySideHtmlFromJson(jsonExample1);
- assert.equal(htmlSideExample1, result);
+ it("should generate pretty side by side html from json", function() {
+ const result = Diff2Html.getPrettySideBySideHtmlFromJson(jsonExample1);
+ expect(htmlSideExample1).toEqual(result);
});
- it('should generate pretty side by side html from diff', function() {
- var result = Diff2Html.getPrettySideBySideHtmlFromDiff(diffExample1, {showFiles: true});
- assert.equal(htmlSideExample1WithFilesSummary, result);
+ it("should generate pretty side by side html from diff 2", function() {
+ const result = Diff2Html.getPrettySideBySideHtmlFromDiff(diffExample1, { showFiles: true });
+ expect(htmlSideExample1WithFilesSummary).toEqual(result);
});
- it('should generate pretty side by side html from diff with html on headers', function() {
- var diffExample2 = 'diff --git a/CHANGELOG.md b/CHANGELOG.md\n' +
- 'index fc3e3f4..b486d10 100644\n' +
- '--- a/CHANGELOG.md\n' +
- '+++ b/CHANGELOG.md\n' +
- '@@ -1,7 +1,6 @@\n' +
- ' # Change Log\n' +
- ' All notable changes to this project will be documented in this file.\n' +
- ' This project adheres to [Semantic Versioning](http://semver.org/).\n' +
+ it("should generate pretty side by side html from diff with html on headers", function() {
+ const diffExample2 =
+ "diff --git a/CHANGELOG.md b/CHANGELOG.md\n" +
+ "index fc3e3f4..b486d10 100644\n" +
+ "--- a/CHANGELOG.md\n" +
+ "+++ b/CHANGELOG.md\n" +
+ "@@ -1,7 +1,6 @@\n" +
+ " # Change Log\n" +
+ " All notable changes to this project will be documented in this file.\n" +
+ " This project adheres to [Semantic Versioning](http://semver.org/).\n" +
'-$a="
Use the following format for additions: ` - VERSION: [feature/patch (if applicable)] Short description of change. Links to relevant issues/PRs.`\n' +
' $a="
\n' +
' \n' +
' All notable changes to this project will be documented in this file.\n' +
- '
\n' +
- '
\n' +
- '
\n' +
+ " \n" +
+ " \n" +
+ "
\n" +
'
\n' +
'
3
\n' +
'
3
\n' +
- '
\n' +
+ " \n" +
'
\n' +
'
\n' +
' \n' +
' This project adheres to [Semantic Versioning](http://semver.org/).\n' +
- '
\n' +
- '
\n' +
- '
\n' +
+ " \n" +
+ " \n" +
+ "
\n" +
'
\n' +
'
4
\n' +
'\n' +
- '
\n' +
+ " \n" +
'
\n' +
'
\n' +
' -\n' +
' $a="<table><tr><td>Use the following format for additions: ` - VERSION: [feature/patch (if applicable)] Short description of change. Links to relevant issues/PRs.`\n' +
- '
\n' +
- '
\n' +
- '
\n' +
+ " \n" +
+ " \n" +
+ "
\n" +
'
\n' +
'
5
\n' +
'
4
\n' +
- '
\n' +
+ " \n" +
'
\n' +
'
\n' +
' \n' +
' $a="<table><tr><td>\n' +
- '
\n' +
- '
\n' +
- '
\n' +
+ " \n" +
+ " \n" +
+ "
\n" +
'
\n' +
'
6
\n' +
'
5
\n' +
- '
\n' +
+ " \n" +
'
\n' +
'
\n' +
' \n' +
' $a="<table><tr><td>- 1.1.9: Fix around ubuntu's inability to cache promises. [#877](https://github.com/FredrikNoren/ungit/pull/878)\n' +
- '
\n' +
- '
\n' +
- '
\n' +
+ " \n" +
+ " \n" +
+ "
\n" +
'
\n' +
'
7
\n' +
'
6
\n' +
- '
\n' +
+ " \n" +
'
\n' +
'
\n' +
' \n' +
' - 1.1.8:\n' +
- '
\n' +
- '
\n' +
- '
\n' +
- '
\n' +
+ " \n" +
+ " \n" +
+ "
\n" +
+ "
\n" +
'
\n' +
'
\n' +
'
@@ -11,7 +10,7 @@ $a="<table><tr><td>- 1.1.9: Fix around ubuntu's inability to cache promises. [#8