Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Allow stub to return new instance objects

  • Loading branch information...
commit ac62fdfc27b13fcd3fb59c0cf67609aecac3c928 1 parent b86cf7a
@felixge authored
Showing with 13 additions and 1 deletion.
  1. +1 −1  lib/gently/gently.js
  2. +12 −0 test/simple/test-gently.js
View
2  lib/gently/gently.js
@@ -13,7 +13,7 @@ module.exports = Gently;
Gently.prototype.stub = function(location, exportsName) {
function Stub() {
- Stub['new'].apply(this, arguments);
+ return Stub['new'].apply(this, arguments);
};
Stub['new'] = function () {};
View
12 test/simple/test-gently.js
@@ -207,6 +207,18 @@ test(function stub() {
assert.equal(newCalled, 1);
assert.equal(stub.toString(), 'require('+JSON.stringify(LOCATION)+')');
})();
+
+ (function testUseReturnValueAsInstance() {
+ var R = {};
+
+ Stub['new'] = function() {
+ return R;
+ };
+
+ var stub = new Stub();
+ assert.strictEqual(stub, R);
+
+ })();
})();
var EXPORTS_NAME = 'MyClass';
Please sign in to comment.
Something went wrong with that request. Please try again.