Fixed build
This commit is contained in:
@@ -3538,8 +3538,8 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
|||||||
result.pass = actual.calls.any();
|
result.pass = actual.calls.any();
|
||||||
|
|
||||||
result.message = result.pass ?
|
result.message = result.pass ?
|
||||||
'Expected spy ' + actual.and.identity() + ' not to have been called.' :
|
'Expected spy ' + actual.and.identity + ' not to have been called.' :
|
||||||
'Expected spy ' + actual.and.identity() + ' to have been called.';
|
'Expected spy ' + actual.and.identity + ' to have been called.';
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -3574,11 +3574,11 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
|||||||
var result = { pass: false };
|
var result = { pass: false };
|
||||||
|
|
||||||
if (!firstSpy.calls.count()) {
|
if (!firstSpy.calls.count()) {
|
||||||
result.message = 'Expected spy ' + firstSpy.and.identity() + ' to have been called.';
|
result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called.';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (!latterSpy.calls.count()) {
|
if (!latterSpy.calls.count()) {
|
||||||
result.message = 'Expected spy ' + latterSpy.and.identity() + ' to have been called.';
|
result.message = 'Expected spy ' + latterSpy.and.identity + ' to have been called.';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3588,17 +3588,17 @@ getJasmineRequireObj().toHaveBeenCalledBefore = function(j$) {
|
|||||||
result.pass = latest1stSpyCall < first2ndSpyCall;
|
result.pass = latest1stSpyCall < first2ndSpyCall;
|
||||||
|
|
||||||
if (result.pass) {
|
if (result.pass) {
|
||||||
result.message = 'Expected spy ' + firstSpy.and.identity() + ' to not have been called before spy ' + latterSpy.and.identity() + ', but it was';
|
result.message = 'Expected spy ' + firstSpy.and.identity + ' to not have been called before spy ' + latterSpy.and.identity + ', but it was';
|
||||||
} else {
|
} else {
|
||||||
var first1stSpyCall = firstSpy.calls.first().invocationOrder;
|
var first1stSpyCall = firstSpy.calls.first().invocationOrder;
|
||||||
var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
|
var latest2ndSpyCall = latterSpy.calls.mostRecent().invocationOrder;
|
||||||
|
|
||||||
if(first1stSpyCall < first2ndSpyCall) {
|
if(first1stSpyCall < first2ndSpyCall) {
|
||||||
result.message = 'Expected latest call to spy ' + firstSpy.and.identity() + ' to have been called before first call to spy ' + latterSpy.and.identity() + ' (no interleaved calls)';
|
result.message = 'Expected latest call to spy ' + firstSpy.and.identity + ' to have been called before first call to spy ' + latterSpy.and.identity + ' (no interleaved calls)';
|
||||||
} else if (latest2ndSpyCall > latest1stSpyCall) {
|
} else if (latest2ndSpyCall > latest1stSpyCall) {
|
||||||
result.message = 'Expected first call to spy ' + latterSpy.and.identity() + ' to have been called after latest call to spy ' + firstSpy.and.identity() + ' (no interleaved calls)';
|
result.message = 'Expected first call to spy ' + latterSpy.and.identity + ' to have been called after latest call to spy ' + firstSpy.and.identity + ' (no interleaved calls)';
|
||||||
} else {
|
} else {
|
||||||
result.message = 'Expected spy ' + firstSpy.and.identity() + ' to have been called before spy ' + latterSpy.and.identity();
|
result.message = 'Expected spy ' + firstSpy.and.identity + ' to have been called before spy ' + latterSpy.and.identity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3641,8 +3641,8 @@ getJasmineRequireObj().toHaveBeenCalledTimes = function(j$) {
|
|||||||
var timesMessage = expected === 1 ? 'once' : expected + ' times';
|
var timesMessage = expected === 1 ? 'once' : expected + ' times';
|
||||||
result.pass = calls === expected;
|
result.pass = calls === expected;
|
||||||
result.message = result.pass ?
|
result.message = result.pass ?
|
||||||
'Expected spy ' + actual.and.identity() + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' :
|
'Expected spy ' + actual.and.identity + ' not to have been called ' + timesMessage + '. It was called ' + calls + ' times.' :
|
||||||
'Expected spy ' + actual.and.identity() + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.';
|
'Expected spy ' + actual.and.identity + ' to have been called ' + timesMessage + '. It was called ' + calls + ' times.';
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -3676,15 +3676,15 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!actual.calls.any()) {
|
if (!actual.calls.any()) {
|
||||||
result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; };
|
result.message = function() { return 'Expected spy ' + actual.and.identity + ' to have been called with ' + j$.pp(expectedArgs) + ' but it was never called.'; };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
|
if (util.contains(actual.calls.allArgs(), expectedArgs, customEqualityTesters)) {
|
||||||
result.pass = true;
|
result.pass = true;
|
||||||
result.message = function() { return 'Expected spy ' + actual.and.identity() + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; };
|
result.message = function() { return 'Expected spy ' + actual.and.identity + ' not to have been called with ' + j$.pp(expectedArgs) + ' but it was.'; };
|
||||||
} else {
|
} else {
|
||||||
result.message = function() { return 'Expected spy ' + actual.and.identity() + ' to have been called with ' + j$.pp(expectedArgs) + ' but actual calls were ' + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + '.'; };
|
result.message = function() { return 'Expected spy ' + actual.and.identity + ' to have been called with ' + j$.pp(expectedArgs) + ' but actual calls were ' + j$.pp(actual.calls.allArgs()).replace(/^\[ | \]$/g, '') + '.'; };
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
@@ -4144,7 +4144,7 @@ getJasmineRequireObj().pp = function(j$) {
|
|||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
this.emitString(value);
|
this.emitString(value);
|
||||||
} else if (j$.isSpy(value)) {
|
} else if (j$.isSpy(value)) {
|
||||||
this.emitScalar('spy on ' + value.and.identity());
|
this.emitScalar('spy on ' + value.and.identity);
|
||||||
} else if (value instanceof RegExp) {
|
} else if (value instanceof RegExp) {
|
||||||
this.emitScalar(value.toString());
|
this.emitScalar(value.toString());
|
||||||
} else if (typeof value === 'function') {
|
} else if (typeof value === 'function') {
|
||||||
@@ -4905,7 +4905,7 @@ getJasmineRequireObj().Spy = function (j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
callTracker.track(callData);
|
callTracker.track(callData);
|
||||||
var returnValue = spyStrategy.exec.apply(this, arguments);
|
var returnValue = spyStrategy.exec(this, arguments);
|
||||||
callData.returnValue = returnValue;
|
callData.returnValue = returnValue;
|
||||||
|
|
||||||
return returnValue;
|
return returnValue;
|
||||||
@@ -5083,106 +5083,102 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|||||||
function SpyStrategy(options) {
|
function SpyStrategy(options) {
|
||||||
options = options || {};
|
options = options || {};
|
||||||
|
|
||||||
var identity = options.name || 'unknown',
|
|
||||||
originalFn = options.fn || function() {},
|
|
||||||
getSpy = options.getSpy || function() {},
|
|
||||||
plan = function() {};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the identifying information for the spy.
|
* Get the identifying information for the spy.
|
||||||
* @name Spy#and#identity
|
* @name Spy#and#identity
|
||||||
* @function
|
* @member
|
||||||
* @returns {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this.identity = function() {
|
this.identity = options.name || 'unknown';
|
||||||
return identity;
|
this.originalFn = options.fn || function() {};
|
||||||
};
|
this.getSpy = options.getSpy || function() {};
|
||||||
|
this.plan = function() {};
|
||||||
/**
|
|
||||||
* Execute the current spy strategy.
|
|
||||||
* @name Spy#and#exec
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.exec = function() {
|
|
||||||
return plan.apply(this, arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the spy to call through to the real implementation when invoked.
|
|
||||||
* @name Spy#and#callThrough
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.callThrough = function() {
|
|
||||||
plan = originalFn;
|
|
||||||
return getSpy();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the spy to return the value when invoked.
|
|
||||||
* @name Spy#and#returnValue
|
|
||||||
* @function
|
|
||||||
* @param {*} value The value to return.
|
|
||||||
*/
|
|
||||||
this.returnValue = function(value) {
|
|
||||||
plan = function() {
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
return getSpy();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the spy to return one of the specified values (sequentially) each time the spy is invoked.
|
|
||||||
* @name Spy#and#returnValues
|
|
||||||
* @function
|
|
||||||
* @param {...*} values - Values to be returned on subsequent calls to the spy.
|
|
||||||
*/
|
|
||||||
this.returnValues = function() {
|
|
||||||
var values = Array.prototype.slice.call(arguments);
|
|
||||||
plan = function () {
|
|
||||||
return values.shift();
|
|
||||||
};
|
|
||||||
return getSpy();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the spy to throw an error when invoked.
|
|
||||||
* @name Spy#and#throwError
|
|
||||||
* @function
|
|
||||||
* @param {Error|String} something Thing to throw
|
|
||||||
*/
|
|
||||||
this.throwError = function(something) {
|
|
||||||
var error = (something instanceof Error) ? something : new Error(something);
|
|
||||||
plan = function() {
|
|
||||||
throw error;
|
|
||||||
};
|
|
||||||
return getSpy();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the spy to call a fake implementation when invoked.
|
|
||||||
* @name Spy#and#callFake
|
|
||||||
* @function
|
|
||||||
* @param {Function} fn The function to invoke with the passed parameters.
|
|
||||||
*/
|
|
||||||
this.callFake = function(fn) {
|
|
||||||
if(!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
|
|
||||||
throw new Error('Argument passed to callFake should be a function, got ' + fn);
|
|
||||||
}
|
|
||||||
plan = fn;
|
|
||||||
return getSpy();
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tell the spy to do nothing when invoked. This is the default.
|
|
||||||
* @name Spy#and#stub
|
|
||||||
* @function
|
|
||||||
*/
|
|
||||||
this.stub = function(fn) {
|
|
||||||
plan = function() {};
|
|
||||||
return getSpy();
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the current spy strategy.
|
||||||
|
* @name Spy#and#exec
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
|
SpyStrategy.prototype.exec = function(context, args) {
|
||||||
|
return this.plan.apply(context, args);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the spy to call through to the real implementation when invoked.
|
||||||
|
* @name Spy#and#callThrough
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
|
SpyStrategy.prototype.callThrough = function() {
|
||||||
|
this.plan = this.originalFn;
|
||||||
|
return this.getSpy();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the spy to return the value when invoked.
|
||||||
|
* @name Spy#and#returnValue
|
||||||
|
* @function
|
||||||
|
* @param {*} value The value to return.
|
||||||
|
*/
|
||||||
|
SpyStrategy.prototype.returnValue = function(value) {
|
||||||
|
this.plan = function() {
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
return this.getSpy();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the spy to return one of the specified values (sequentially) each time the spy is invoked.
|
||||||
|
* @name Spy#and#returnValues
|
||||||
|
* @function
|
||||||
|
* @param {...*} values - Values to be returned on subsequent calls to the spy.
|
||||||
|
*/
|
||||||
|
SpyStrategy.prototype.returnValues = function() {
|
||||||
|
var values = Array.prototype.slice.call(arguments);
|
||||||
|
this.plan = function () {
|
||||||
|
return values.shift();
|
||||||
|
};
|
||||||
|
return this.getSpy();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the spy to throw an error when invoked.
|
||||||
|
* @name Spy#and#throwError
|
||||||
|
* @function
|
||||||
|
* @param {Error|String} something Thing to throw
|
||||||
|
*/
|
||||||
|
SpyStrategy.prototype.throwError = function(something) {
|
||||||
|
var error = (something instanceof Error) ? something : new Error(something);
|
||||||
|
this.plan = function() {
|
||||||
|
throw error;
|
||||||
|
};
|
||||||
|
return this.getSpy();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the spy to call a fake implementation when invoked.
|
||||||
|
* @name Spy#and#callFake
|
||||||
|
* @function
|
||||||
|
* @param {Function} fn The function to invoke with the passed parameters.
|
||||||
|
*/
|
||||||
|
SpyStrategy.prototype.callFake = function(fn) {
|
||||||
|
if(!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
|
||||||
|
throw new Error('Argument passed to callFake should be a function, got ' + fn);
|
||||||
|
}
|
||||||
|
this.plan = fn;
|
||||||
|
return this.getSpy();
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tell the spy to do nothing when invoked. This is the default.
|
||||||
|
* @name Spy#and#stub
|
||||||
|
* @function
|
||||||
|
*/
|
||||||
|
SpyStrategy.prototype.stub = function(fn) {
|
||||||
|
this.plan = function() {};
|
||||||
|
return this.getSpy();
|
||||||
|
};
|
||||||
|
|
||||||
return SpyStrategy;
|
return SpyStrategy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
|
|||||||
* @member
|
* @member
|
||||||
* @type {String}
|
* @type {String}
|
||||||
*/
|
*/
|
||||||
this.identity = options.name || 'unknown',
|
this.identity = options.name || 'unknown';
|
||||||
this.originalFn = options.fn || function() {},
|
this.originalFn = options.fn || function() {};
|
||||||
this.getSpy = options.getSpy || function() {},
|
this.getSpy = options.getSpy || function() {};
|
||||||
this.plan = function() {};
|
this.plan = function() {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user