From fe5082ca0c8157249caeda1ad4b69e2d1cc06d4e Mon Sep 17 00:00:00 2001 From: Gabriel Imre Date: Tue, 24 Mar 2015 11:14:25 +0200 Subject: [PATCH] added quick mocking capabilities for single module --- lib/container.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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;