diff --git a/lib/container.js b/lib/container.js index 75547ae..91006b5 100644 --- a/lib/container.js +++ b/lib/container.js @@ -81,6 +81,18 @@ Container.prototype.create = function(id, parent) { return comp.create(this); } +Container.prototype.mock = function(id, mock_id) { + this._loadModule(mock_id); + + var mock = this._o[mock_id]; + if (!mock) { + throw new Error("Unable to create component '" + mock_id + "'"); + } + + this._o[ id ] = mock; + delete this._o[ mock_id ]; +}; + Container.prototype.factory = function(id, dependencies, fn, sid) { if (typeof dependencies == 'function') { fn = dependencies;