46 lines
1.2 KiB
JavaScript
46 lines
1.2 KiB
JavaScript
getJasmineRequireObj().Any = function(j$) {
|
|
function Any(expectedObject) {
|
|
if (typeof expectedObject === 'undefined') {
|
|
throw new TypeError(
|
|
'jasmine.any() expects to be passed a constructor function. ' +
|
|
'Please pass one or use jasmine.anything() to match any object.'
|
|
);
|
|
}
|
|
this.expectedObject = expectedObject;
|
|
}
|
|
|
|
Any.prototype.asymmetricMatch = function(other) {
|
|
if (this.expectedObject == String) {
|
|
return typeof other == 'string' || other instanceof String;
|
|
}
|
|
|
|
if (this.expectedObject == Number) {
|
|
return typeof other == 'number' || other instanceof Number;
|
|
}
|
|
|
|
if (this.expectedObject == Function) {
|
|
return typeof other == 'function' || other instanceof Function;
|
|
}
|
|
|
|
if (this.expectedObject == Object) {
|
|
return other !== null && typeof other == 'object';
|
|
}
|
|
|
|
if (this.expectedObject == Boolean) {
|
|
return typeof other == 'boolean';
|
|
}
|
|
|
|
if (typeof Symbol != 'undefined' && this.expectedObject == Symbol) {
|
|
return typeof other == 'symbol';
|
|
}
|
|
|
|
return other instanceof this.expectedObject;
|
|
};
|
|
|
|
Any.prototype.jasmineToString = function() {
|
|
return '<jasmine.any(' + j$.fnNameFor(this.expectedObject) + ')>';
|
|
};
|
|
|
|
return Any;
|
|
};
|