describe("As a module", function() { describe("current working directory should", function() { it("default to node's current working directory", function() { var sgf = require("../"); sgf.cwd.should.equal(process.cwd()); }); it("be over writable", function() { var sgf = require("../"); sgf.cwd = test_folder sgf.cwd.should.equal(test_folder); }); }); describe("getHead will return", function() { beforeEach(function(done) { setup(function(err) { if (err) { done(err); } else { newGit(function(err, stdout, stderr) { if (err || stderr) { done(err || new Error(stderr)); } else { done(); } }); } }); }); it("firstHead in a repo without commits", function(done) { var sgf = newSGF(); sgf.getHead(asyncCatch(done, function(head){ head.should.equal('4b825dc642cb6eb9a060e54bf8d69288fbee4904'); })); }); it("some hash in a repo with commits", function(done) { addAndCommitFile(function(err, data) { if (err) { done(err); } else { var sgf = newSGF(); sgf.getHead(asyncCatch(done, function(head){ head.should.not.equal(sgf.firstHead); })); } }); }); }); describe("used in a directory with staged files", function() { beforeEach(function(done) { setup(function(err) { if (err) { done(err); } else { newGit(function(err, stdout, stderr) { if (err || stderr) { done(err || new Error(stderr)); } else { addAndCommitFile(function(err){ done(err); }); } }); } }); }); it("I, being the cli, should log the file paths and their git status", function(done) { addFiles(2, function(err, data) { if (err) return done(err); var sorter = function(a,b){ if(a.filename > b.filename){ return 1; } else if(a.filename < b.filename){ return -1; } else{ return 0; } }; data.sort(sorter); exec('../../bin/cli.js', {cwd: test_folder}, function(err, stdout, stderr) { if (err) return done(err); var results = stdout.trim().split('\n').map(function(line) { var p = line.split(' '); var status = p[0]; var filename = p.slice(1).join(' '); return { status: status, filename: filename }; }); results.sort(sorter); for(var i=0; i b.filename){ return 1; } else if(a.filename < b.filename){ return -1; } else{ return 0; } }; data.sort(sorter); var sgf = newSGF(); sgf(asyncCatch(done, function(results){ results.sort(sorter); for(var i=0; i