diff --git a/package.json b/package.json index f97cd02..4ecc558 100644 --- a/package.json +++ b/package.json @@ -38,9 +38,9 @@ "scripts": { "release": "./scripts/release.sh", "templates": "./scripts/hulk.js --wrapper node --variable 'browserTemplates' ./src/templates/*.mustache > ./src/templates/diff2html-templates.js", - "test": "istanbul cover -x '**/templates/**' -x 'rematch.js' _mocha -- -u exports -R spec ./test/**/*", + "test": "istanbul cover _mocha -- -u exports -R spec ./test/**/*", "style": "jscs src test", - "codacy": "istanbul cover -x '**/templates/**' -x 'rematch.js' _mocha -- -u exports -R spec ./test/**/* && cat ./coverage/lcov.info | codacy-coverage" + "codacy": "istanbul cover _mocha -- -u exports -R spec ./test/**/* && cat ./coverage/lcov.info | codacy-coverage" }, "main": "./src/diff2html.js", "browser": { diff --git a/src/diff-parser.js b/src/diff-parser.js index 0ffc395..f42aed4 100644 --- a/src/diff-parser.js +++ b/src/diff-parser.js @@ -23,7 +23,9 @@ DiffParser.prototype.LINE_TYPE = LINE_TYPE; - DiffParser.prototype.generateDiffJson = function(diffInput, config) { + DiffParser.prototype.generateDiffJson = function(diffInput, configuration) { + var config = configuration || {}; + var files = []; var currentFile = null; var currentBlock = null; diff --git a/test/line-by-line-tests.js b/test/line-by-line-tests.js index 5c40bc7..e7e8a64 100644 --- a/test/line-by-line-tests.js +++ b/test/line-by-line-tests.js @@ -20,6 +20,7 @@ describe('LineByLinePrinter', function() { assert.equal(expected, fileHtml); }); }); + describe('makeLineHtml', function() { it('should work for insertions', function() { @@ -43,8 +44,8 @@ describe('LineByLinePrinter', function() { assert.equal(expected, fileHtml); }); - it('should work for deletions', function() { + it('should work for deletions', function() { var diffParser = require('../src/diff-parser.js').DiffParser; var lineByLinePrinter = new LineByLinePrinter({}); var fileHtml = lineByLinePrinter.makeLineHtml( @@ -65,8 +66,8 @@ describe('LineByLinePrinter', function() { assert.equal(expected, fileHtml); }); - it('should convert indents into non breakin spaces (2 white spaces)', function() { + it('should convert indents into non breakin spaces (2 white spaces)', function() { var diffParser = require('../src/diff-parser.js').DiffParser; var lineByLinePrinter = new LineByLinePrinter({}); var fileHtml = lineByLinePrinter.makeLineHtml( @@ -87,8 +88,8 @@ describe('LineByLinePrinter', function() { assert.equal(expected, fileHtml); }); - it('should convert indents into non breakin spaces (4 white spaces)', function() { + it('should convert indents into non breakin spaces (4 white spaces)', function() { var diffParser = require('../src/diff-parser.js').DiffParser; var lineByLinePrinter = new LineByLinePrinter({}); var fileHtml = lineByLinePrinter.makeLineHtml( @@ -109,8 +110,8 @@ describe('LineByLinePrinter', function() { assert.equal(expected, fileHtml); }); - it('should convert indents into non breakin spaces (one tab)', function() { + it('should convert indents into non breakin spaces (one tab)', function() { var diffParser = require('../src/diff-parser.js').DiffParser; var lineByLinePrinter = new LineByLinePrinter({}); var fileHtml = lineByLinePrinter.makeLineHtml( @@ -132,4 +133,285 @@ describe('LineByLinePrinter', function() { assert.equal(expected, fileHtml); }); }); + + describe('makeFileDiffHtml', function() { + it('should work for simple file', function() { + var lineByLinePrinter = new LineByLinePrinter({}); + + var file = { + addedLines: 12, + deletedLines: 41, + language: 'js', + oldName: 'my/file/name.js', + newName: 'my/file/name.js' + }; + var diffs = 'Random Html'; + + var fileHtml = lineByLinePrinter.makeFileDiffHtml(file, diffs); + + var expected = '
| \n' + + ' | \n' + + ' \n' + + ' | \n' + + '
| \n' +
+ ' 1 \n' +
+ ' \n' +
+ ' | \n' +
+ ' \n' +
+ ' \n' +
+ ' -\n' +
+ ' \n' +
+ ' | \n' +
+ '
| \n' +
+ ' \n' +
+ ' 1 \n' +
+ ' | \n' +
+ ' \n' +
+ ' \n' +
+ ' +\n' +
+ ' test1r\n' +
+ ' \n' +
+ ' | \n' +
+ '