Skip to content

Commit

Permalink
added mock support
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthropohedron committed Apr 7, 2015
1 parent b30223e commit b8cdaac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,25 @@ var contractFrags = [
null,
";1"
];
var mocks = {};

exports.createInstance = function createInstance(contractId, iface) {
if (mocks.hasOwnProperty(iface)) { return mocks[iface]; }
contractFrags[1] = contractId;
return Cc[contractFrags.join("")].createInstance(Ci[iface]);
};

exports.getService = function getService(contractId, service) {
if (mocks.hasOwnProperty(service)) { return mocks[service]; }
contractFrags[1] = contractId;
return Cc[contractFrags.join("")].getService(Ci[service]);
};

exports.setMock = function setMock(key, obj) {
mocks[key] = obj;
};

exports.clearMock = function clearMock(key) {
delete mocks[key];
};

0 comments on commit b8cdaac

Please sign in to comment.