diff --git a/backbone.geppetto.js b/backbone.geppetto.js index 17d26cc..1595907 100755 --- a/backbone.geppetto.js +++ b/backbone.geppetto.js @@ -145,7 +145,7 @@ if (this._mappings.hasOwnProperty(key)) { var config = this._mappings[key]; if (!overrideRules && config.type === TYPES.SINGLETON) { - if (!config.object) { + if (!config.object && config.clazz) { config.object = this._createAndSetupInstance(config); } output = config.object; diff --git a/specs/src/geppetto-specs.js b/specs/src/geppetto-specs.js index 5d80853..0f8cbc8 100755 --- a/specs/src/geppetto-specs.js +++ b/specs/src/geppetto-specs.js @@ -452,6 +452,7 @@ define([ }); + describe("when triggering commands", function() { var context; var CommandClass; diff --git a/specs/src/resolver-specs.js b/specs/src/resolver-specs.js index a1f75ca..0599e55 100644 --- a/specs/src/resolver-specs.js +++ b/specs/src/resolver-specs.js @@ -151,9 +151,13 @@ define([ describe("when mapping a value", function() { var key = 'a value'; var value = {}; + var spy; + + beforeEach(function() { context.wireValue(key, value); }); + it('should be determinable', function() { expect(context.hasWiring(key)).to.be.true; }); @@ -165,6 +169,43 @@ define([ var second = context.getObject(key); expect(second).to.equal(first); }); + + it("it should accept the value 'false' as mapped value", function(){ + spy = sinon.spy(function() { + context.wireValue('false', false); + context.getObject('false'); + }); + spy(); + expect(spy).to.have.not.thrown(); + }); + + it("it should accept empty string as mapped value", function(){ + spy = sinon.spy(function() { + context.wireValue('empty_string', ''); + context.getObject('empty_string'); + }); + spy(); + expect(spy).to.have.not.thrown(); + }); + + it("it should accept 0 as mapped value", function(){ + spy = sinon.spy(function() { + context.wireValue('zero', 0); + context.getObject('zero'); + }); + spy(); + expect(spy).to.have.not.thrown(); + }); + + it("it should accept null as mapped value", function(){ + spy = sinon.spy(function() { + context.wireValue('null_value', null); + context.getObject('null_value'); + }); + spy(); + expect(spy).to.have.not.thrown(); + }); + }); describe("when mapping a class", function() { var key = 'a class';