before headless fix, but not animation factory is static class

This commit is contained in:
Peter Cottle 2013-06-05 18:48:59 -10:00
parent a7e515dd8c
commit d0e206bcc4
4 changed files with 56 additions and 49 deletions

View file

@ -16,6 +16,16 @@ var Command = require('../models/commandModel').Command;
var mock = require('../util/mock').mock;
var util = require('../util');
function getMockFactory() {
var mockFactory = {};
for (var key in AnimationFactory) {
mockFactory[key] = function() {
return Q.defer().promise;
};
}
return mockFactory;
}
var HeadlessGit = function() {
this.init();
};
@ -27,7 +37,7 @@ HeadlessGit.prototype.init = function() {
// here we mock visuals and animation factory so the git engine
// is headless
var animationFactory = mock(AnimationFactory);
var animationFactory = getMockFactory();
var gitVisuals = mock(GitVisuals);
this.gitEngine = new GitEngine({

View file

@ -5,7 +5,7 @@ var Q = require('q');
var intl = require('../intl');
var AnimationFactoryModule = require('../visuals/animation/animationFactory');
var AnimationFactory = require('../visuals/animation/animationFactory').AnimationFactory;
var AnimationQueue = require('../visuals/animation').AnimationQueue;
var TreeCompare = require('./treeCompare').TreeCompare;
@ -28,8 +28,9 @@ function GitEngine(options) {
this.eventBaton = options.eventBaton;
this.eventBaton.stealBaton('processGitCommand', this.dispatch, this);
// poor man's dependency injection
this.animationFactory = options.animationFactory ||
new AnimationFactoryModule.AnimationFactory();
AnimationFactory;
// global variable to keep track of the options given
// along with the command call.