git tests coming

This commit is contained in:
Peter Cottle 2012-12-17 11:49:08 -08:00
parent ddf399e099
commit 822ed2e7fa
2 changed files with 26 additions and 1 deletions

25
spec/git.spec.js Normal file
View file

@ -0,0 +1,25 @@
var HeadlessGit = require('../src/js/git/headless').HeadlessGit;
var TreeCompare = require('../src/js/git/treeCompare').TreeCompare;
var treeCompare = new TreeCompare();
var loadTree = function(json) {
return JSON.parse(unescape(json));
};
var compareAnswer = function(headless, expectedJSON) {
var expectedTree = loadTree(expectedJSON);
var actualTree = headless.gitEngine.exportTree()
var equal = treeCompare.compareTrees(expectedTree, actualTree);
expect(equal).toBe(true);
};
describe('GitEngine', function() {
it('Should commit off of head', function() {
var headless = new HeadlessGit();
var expectedJSON = '{"branches":{"master":{"target":"C2","id":"master","type":"branch"}},"commits":{"C0":{"type":"commit","parents":[],"id":"C0","rootCommit":true},"C1":{"type":"commit","parents":["C0"],"id":"C1"},"C2":{"type":"commit","parents":["C1"],"id":"C2"}},"HEAD":{"id":"HEAD","target":"master","type":"general ref"}}';
headless.sendCommand('git commit');
compareAnswer(headless, expectedJSON);
});
});

View file

@ -8,7 +8,6 @@ Big Graphic things:
Medium things: Medium things:
~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ ] gitEngine loads from tree immediately, not the weird thing we have now! [ ] gitEngine loads from tree immediately, not the weird thing we have now!
[.] headless Git for testing (send it commands and expected trees)
[.] few tests [.] few tests
Small things to implement: Small things to implement:
@ -30,4 +29,5 @@ Done things:
(I only started this on Dec 17th 2012 to get a better sense of what was done) (I only started this on Dec 17th 2012 to get a better sense of what was done)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[x] aliases replace when put into commands [x] aliases replace when put into commands
[x] headless Git for testing (send it commands and expected trees)