deprecating wasCalled, wasCalledWith, wasNotCalled, wasNotCalledWith and adding toHaveBeenCalled, and toHaveBeenCalledWith
This commit is contained in:
@@ -162,12 +162,18 @@ jasmine.Matchers.prototype.toBeFalsy = function() {
|
||||
return !this.actual;
|
||||
};
|
||||
|
||||
|
||||
/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
|
||||
jasmine.Matchers.prototype.wasCalled = function() {
|
||||
return this.toHaveBeenCalled();
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was called.
|
||||
*/
|
||||
jasmine.Matchers.prototype.wasCalled = function() {
|
||||
jasmine.Matchers.prototype.toHaveBeenCalled = function() {
|
||||
if (arguments.length > 0) {
|
||||
throw new Error('wasCalled does not take arguments, use wasCalledWith');
|
||||
throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
|
||||
}
|
||||
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
@@ -183,6 +189,8 @@ jasmine.Matchers.prototype.wasCalled = function() {
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was not called.
|
||||
*
|
||||
* @deprecated Use expect(xxx).not.toHaveBeenCalled() instead
|
||||
*/
|
||||
jasmine.Matchers.prototype.wasNotCalled = function() {
|
||||
if (arguments.length > 0) {
|
||||
@@ -200,13 +208,18 @@ jasmine.Matchers.prototype.wasNotCalled = function() {
|
||||
return !this.actual.wasCalled;
|
||||
};
|
||||
|
||||
/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
|
||||
jasmine.Matchers.prototype.wasCalledWith = function() {
|
||||
return this.toHaveBeenCalledWith.apply(this, arguments);
|
||||
};
|
||||
|
||||
/**
|
||||
* Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
|
||||
*
|
||||
* @example
|
||||
*
|
||||
*/
|
||||
jasmine.Matchers.prototype.wasCalledWith = function() {
|
||||
jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
|
||||
var expectedArgs = jasmine.util.argsToArray(arguments);
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
|
||||
@@ -222,6 +235,7 @@ jasmine.Matchers.prototype.wasCalledWith = function() {
|
||||
return this.env.contains_(this.actual.argsForCall, expectedArgs);
|
||||
};
|
||||
|
||||
/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
|
||||
jasmine.Matchers.prototype.wasNotCalledWith = function() {
|
||||
var expectedArgs = jasmine.util.argsToArray(arguments);
|
||||
if (!jasmine.isSpy(this.actual)) {
|
||||
|
||||
@@ -172,7 +172,7 @@ jasmine.isDomNode = function(obj) {
|
||||
*
|
||||
* @example
|
||||
* // don't care about which function is passed in, as long as it's a function
|
||||
* expect(mySpy).wasCalledWith(jasmine.any(Function));
|
||||
* expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
|
||||
*
|
||||
* @param {Class} clazz
|
||||
* @returns matchable object of the type clazz
|
||||
@@ -187,7 +187,8 @@ jasmine.any = function(clazz) {
|
||||
* Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
|
||||
* expectation syntax. Spies can be checked if they were called or not and what the calling params were.
|
||||
*
|
||||
* A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs)
|
||||
* A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
|
||||
*
|
||||
* Spies are torn down at the end of every spec.
|
||||
*
|
||||
* Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
|
||||
@@ -217,8 +218,8 @@ jasmine.any = function(clazz) {
|
||||
*
|
||||
* // mock example
|
||||
* foo.not(7 == 7);
|
||||
* expect(foo.not).wasCalled();
|
||||
* expect(foo.not).wasCalledWith(true);
|
||||
* expect(foo.not).toHaveBeenCalled();
|
||||
* expect(foo.not).toHaveBeenCalledWith(true);
|
||||
*
|
||||
* @constructor
|
||||
* @see spyOn, jasmine.createSpy, jasmine.createSpyObj
|
||||
|
||||
Reference in New Issue
Block a user