Skip to content

Commit

Permalink
Add unit tests for GitCommit.raw_log
Browse files Browse the repository at this point in the history
  • Loading branch information
scottnonnenberg committed Apr 16, 2015
1 parent add82b5 commit c88e44a
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion test/test_git_basic.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var testCase = require('nodeunit').testCase,
Repo = require('../lib/git').Repo,
Git = require('../lib/git').Git,
fs = require('fs'),
Commit = require('../lib/git').Commit,
Commit = require('../lib/git/internal/git_commit').GitCommit,
Blob = require('../lib/git').Blob,
GitFileOperations = require('../lib/git').GitFileOperations;

Expand All @@ -24,6 +24,39 @@ module.exports = testCase({
callback();
},

"GitCommit.raw_log eliminates final empty line":function(assert) {
var message = 'first line\nsecond line\n';
var headers = 'headers';
var sha = 'SHA';

var expected = 'commit SHA\n' +
'headers\n\n' +
' first line\n' +
' second line\n\n';

var commit = new Commit(null, null, null, null, message, headers);

assert.equal(expected, commit.raw_log(sha));
assert.done();
},

"GitCommit.raw_log does not drop final line if non-empty":function(assert) {
var message = 'first line\nsecond line\nthird line';
var headers = 'headers';
var sha = 'SHA';

var expected = 'commit SHA\n' +
'headers\n\n' +
' first line\n' +
' second line\n' +
' third line\n\n';

var commit = new Commit(null, null, null, null, message, headers);

assert.equal(expected, commit.raw_log(sha));
assert.done();
},

"Should correctly init gitdir":function(assert) {
var tmp_path = './test/tmp';
GitFileOperations.fs_rmdir_r(tmp_path, function(err, result) {
Expand Down

0 comments on commit c88e44a

Please sign in to comment.