Code coverage report for src\test\gitLog.js

Statements: 100% (55 / 55)      Branches: 100% (0 / 0)      Functions: 100% (10 / 10)      Lines: 100% (55 / 55)      Ignored: none     

All files » src\test\ » gitLog.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 1111 1   1   1 1 1 1 1     1     1 1 1 1     1 1 1             1 1 1 1 1 1     1 1 1         1 1 1 1     1 1 1             1 1 1 1     1 1 1             1 1 1 1     1 1                         1 1     1 1 1     1 1 1 1 1    
var parseCommit = require('../gitLog').parseCommit;
var getGitLog = require('../gitLog').getGitLog;
 
gt.module('parse commit');
 
gt.test(function stringComparison() {
	gt.equal('foo', 'foo', 'two strings are equal');
	var foo = 'foo';
	gt.equal('foo', foo, 'two strings are equal');
	var o = {
		foo: 'foo'
	};
	gt.equal('foo', o.foo, 'two strings are equal');
});
 
gt.test(function compareIds() {
	var id1 = '4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348';
	var id2 = '4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348';
	gt.equal(id1, id2, 'same strings');
});
 
gt.test(function basic() {
	gt.func(parseCommit, 'is a function');
	var data = 
	'commit 4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348\n' +
	'Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>\n' +
	'Date:   Tue Feb 12 23:09:26 2013 -0500\n\n' +
  '  simpler history module structure\n\n' + 
	'M       index.js\n' +
	'M       src/fileHistory.js\n';
	var info = parseCommit(data);
	gt.object(info, 'got back object');
	gt.equal(info.commit, '4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348', 'commit id');
	gt.ok(/Gleb Bahmutov/.test(info.author), 'correct author');
	gt.string(info.description, 'has description');
	gt.ok(info.description.length > 0, 'non empty description');
});
 
gt.test(function withoutFileInformation() {
	gt.func(parseCommit, 'is a function');
	var data = '\n\n' +
	'commit 4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348\n' +
	'Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>\n' +
	'Date:   Tue Feb 12 23:09:26 2013 -0500\n\n' +
  '  simpler history module structure\n';
	var info = parseCommit(data);
	gt.object(info, 'got back object');
	gt.equal(info.commit, '4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348', 'commit id');
	gt.equal(info.files.length, 0, 'no files');
});
 
gt.test(function basicWithSpaces() {
	gt.func(parseCommit, 'is a function');
	var data = '\n\n' +
	'commit 4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348\n' +
	'Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>\n' +
	'Date:   Tue Feb 12 23:09:26 2013 -0500\n\n' +
  '  simpler history module structure\n\n' + 
	'M       index.js\n' +
	'M       src/fileHistory.js\n';
	var info = parseCommit(data);
	gt.object(info, 'got back object');
	gt.equal(info.commit, '4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348', 'commit id');
	gt.equal(info.files.length, 2, 'two files');
});
 
gt.test(function basicWithoutCommitKeyword() {
	gt.func(parseCommit, 'is a function');
	var data = 
	'4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348\n' +
	'Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>\n' +
	'Date:   Tue Feb 12 23:09:26 2013 -0500\n\n' +
  '  simpler history module structure\n\n' + 
	'M       index.js\n' +
	'A       src/fileHistory.js\n';
	var info = parseCommit(data);
	gt.object(info, 'got back object');
	gt.equal(info.commit, '4ec3c78ffd07a526a0e1bcf5aca8ba383cfab348', 'commit id');
	gt.equal(info.files.length, 2, 'two files');
});
 
gt.test(function largerCommit() {
	var data =
	' 935e39e573f86776a4a657c35fd135b593358044\n' +
	'Author: Gleb Bahmutov <gleb.bahmutov@gmail.com>\n' +
	'Date:   Wed Feb 13 00:52:31 2013 -0500\n\n' +
  '\ttesting\n' +
	'parsing commit\n' +
	' parsing, adding individual file information\n\n' +
 
	'M       .gitignore\n' +
	'M       index.js\n' +
	'M       src/fileHistory.js\n' +
	'M       src/gitLog.js\n' +
	'A       test/parseCommit.js\n';
	var info = parseCommit(data);
	gt.object(info, 'got back object');
});
 
gt.module('getGitLog');
gt.test(function getLogBasics() {
	gt.arity(getGitLog, 3, 'function arity');
});
 
gt.async(function getThisFileLog() {
	getGitLog(__filename, 5, function(commits) {
		gt.array(commits, 'got commits array');
		gt.ok(commits.length <= 5, '5 commits at most');
		gt.start();
	});
});