From df7e636aa74837a3f121937a3dbcbc95c3670b83 Mon Sep 17 00:00:00 2001 From: Peter Cottle Date: Mon, 17 Dec 2012 21:01:50 -0800 Subject: [PATCH] sweet, got unit tests in a digestable format --- spec/git.spec.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/spec/git.spec.js b/spec/git.spec.js index 2d895370..380f8e25 100644 --- a/spec/git.spec.js +++ b/spec/git.spec.js @@ -14,12 +14,18 @@ var compareAnswer = function(headless, expectedJSON) { expect(equal).toBe(true); }; +var expectCommandToProduceTree = function(command, expectedJSON) { + var headless = new HeadlessGit(); + headless.sendCommand(command); + compareAnswer(headless, expectedJSON); +}; + 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); + expectCommandToProduceTree( + 'git commit', + '{"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"}}' + ); }); });