Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed bug of return types not over-writing each other

  • Loading branch information...
commit 265e3ad60e1697f3ad97e94c31b3b542452b0320 1 parent e806ea1
@nathanmacinnes authored
Showing with 19 additions and 0 deletions.
  1. +6 −0 lib/pretendr.js
  2. +13 −0 test/spec.js
View
6 lib/pretendr.js
@@ -49,12 +49,18 @@ makePretendr = function (descriptor, mock, asTemplate) {
outs[indexNum] = baseObj;
setFake = function (fake) {
+ delete attributes.returnValue;
+ delete attributes.template;
attributes.fake = fake;
};
setReturnValue = function (value) {
+ delete attributes.fake;
+ delete attributes.template;
attributes.returnValue = value;
};
setTemplate = function (o) {
+ delete attributes.fake;
+ delete attributes.returnValue;
if (o) {
if (o.hasOwnProperty('clone')) {
attributes.template = o.clone();
View
13 test/spec.js
@@ -193,6 +193,19 @@ describe("pretendr", function () {
var template = this.pretendrResult.template({});
expect(this.pretendrResult.template()).to.equal(template);
});
+ it("should make all the return options overwrite others", function () {
+ this.pretendrResult.template({
+ a : {}
+ });
+ this.pretendrResult.returnValue(5);
+ expect(this.pretendrResult.mock()).to.equal(5);
+ this.pretendrResult.fake(function () {
+ return 7;
+ });
+ expect(this.pretendrResult.mock()).to.equal(7);
+ this.pretendrResult.template(8);
+ expect(this.pretendrResult.mock()).to.equal(8);
+ });
describe("as constructor", function () {
it("should record instances", function () {
var instance,
Please sign in to comment.
Something went wrong with that request. Please try again.