[Finishes #51528655] spies should support and.stub()
This commit is contained in:
@@ -69,6 +69,24 @@ describe("SpyStrategy", function() {
|
|||||||
expect(returnValue).toEqual(67);
|
expect(returnValue).toEqual(67);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("allows a return to plan stubbing after another strategy", function() {
|
||||||
|
var originalFn = jasmine.createSpy("original"),
|
||||||
|
fakeFn = jasmine.createSpy("fake").and.callReturn(67),
|
||||||
|
spyStrategy = new j$.SpyStrategy({fn: originalFn}),
|
||||||
|
returnValue;
|
||||||
|
|
||||||
|
spyStrategy.callFake(fakeFn);
|
||||||
|
returnValue = spyStrategy.exec();
|
||||||
|
|
||||||
|
expect(originalFn).not.toHaveBeenCalled();
|
||||||
|
expect(returnValue).toEqual(67);
|
||||||
|
|
||||||
|
spyStrategy.stub();
|
||||||
|
returnValue = spyStrategy.exec();
|
||||||
|
|
||||||
|
expect(returnValue).toEqual(void 0);
|
||||||
|
});
|
||||||
|
|
||||||
it("returns the spy after changing the strategy", function(){
|
it("returns the spy after changing the strategy", function(){
|
||||||
var spy = {},
|
var spy = {},
|
||||||
spyFn = jasmine.createSpy('spyFn').and.callReturn(spy),
|
spyFn = jasmine.createSpy('spyFn').and.callReturn(spy),
|
||||||
@@ -78,5 +96,6 @@ describe("SpyStrategy", function() {
|
|||||||
expect(spyStrategy.callReturn()).toBe(spy);
|
expect(spyStrategy.callReturn()).toBe(spy);
|
||||||
expect(spyStrategy.callThrow()).toBe(spy);
|
expect(spyStrategy.callThrow()).toBe(spy);
|
||||||
expect(spyStrategy.callFake()).toBe(spy);
|
expect(spyStrategy.callFake()).toBe(spy);
|
||||||
|
expect(spyStrategy.stub()).toBe(spy);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -39,6 +39,11 @@ getJasmineRequireObj().SpyStrategy = function() {
|
|||||||
plan = fn;
|
plan = fn;
|
||||||
return getSpy();
|
return getSpy();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.stub = function(fn) {
|
||||||
|
plan = function() {};
|
||||||
|
return getSpy();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
return SpyStrategy;
|
return SpyStrategy;
|
||||||
|
|||||||
Reference in New Issue
Block a user