Update.
This commit is contained in:
parent
701ee719e6
commit
4ebc3b5964
|
@ -13,13 +13,13 @@ jasmine.unimplementedMethod_ = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Large or small values here may result in slow test running & "Too much recursion" errors
|
* Default interval for event loop yields. Small values here may result in slow test running. Zero means no updates until all tests have completed.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
|
jasmine.DEFAULT_UPDATE_INTERVAL = 250;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows for bound functions to be comapred. Internal use only.
|
* Allows for bound functions to be compared. Internal use only.
|
||||||
*
|
*
|
||||||
* @ignore
|
* @ignore
|
||||||
* @private
|
* @private
|
||||||
|
@ -177,7 +177,7 @@ jasmine.Spy = function(name) {
|
||||||
*/
|
*/
|
||||||
this.isSpy = true;
|
this.isSpy = true;
|
||||||
/**
|
/**
|
||||||
* The acutal function this spy stubs.
|
* The actual function this spy stubs.
|
||||||
*/
|
*/
|
||||||
this.plan = function() {
|
this.plan = function() {
|
||||||
};
|
};
|
||||||
|
@ -324,6 +324,16 @@ jasmine.createSpy = function(name) {
|
||||||
return spyObj;
|
return spyObj;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines whether an object is a spy.
|
||||||
|
*
|
||||||
|
* @param {jasmine.Spy|Object} putativeSpy
|
||||||
|
* @returns {Boolean}
|
||||||
|
*/
|
||||||
|
jasmine.isSpy = function(putativeSpy) {
|
||||||
|
return putativeSpy && putativeSpy.isSpy;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
|
* Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
|
||||||
* large in one call.
|
* large in one call.
|
||||||
|
@ -534,7 +544,7 @@ jasmine.version_= {
|
||||||
"major": 0,
|
"major": 0,
|
||||||
"minor": 10,
|
"minor": 10,
|
||||||
"build": 0,
|
"build": 0,
|
||||||
"revision": 1257050679
|
"revision": 1259249316
|
||||||
};
|
};
|
||||||
/**
|
/**
|
||||||
* @namespace
|
* @namespace
|
||||||
|
@ -542,13 +552,16 @@ jasmine.version_= {
|
||||||
jasmine.util = {};
|
jasmine.util = {};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declare that a child class inherite it's prototype from the parent class.
|
* Declare that a child class inherit it's prototype from the parent class.
|
||||||
*
|
*
|
||||||
* @private
|
* @private
|
||||||
* @param {Function} childClass
|
* @param {Function} childClass
|
||||||
* @param {Function} parentClass
|
* @param {Function} parentClass
|
||||||
*/
|
*/
|
||||||
jasmine.util.inherit = function(childClass, parentClass) {
|
jasmine.util.inherit = function(childClass, parentClass) {
|
||||||
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
var subclass = function() {
|
var subclass = function() {
|
||||||
};
|
};
|
||||||
subclass.prototype = parentClass.prototype;
|
subclass.prototype = parentClass.prototype;
|
||||||
|
@ -612,7 +625,7 @@ jasmine.Env = function() {
|
||||||
|
|
||||||
this.reporter = new jasmine.MultiReporter();
|
this.reporter = new jasmine.MultiReporter();
|
||||||
|
|
||||||
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL
|
this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
|
||||||
this.lastUpdate = 0;
|
this.lastUpdate = 0;
|
||||||
this.specFilter = function() {
|
this.specFilter = function() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -621,6 +634,17 @@ jasmine.Env = function() {
|
||||||
this.nextSpecId_ = 0;
|
this.nextSpecId_ = 0;
|
||||||
this.nextSuiteId_ = 0;
|
this.nextSuiteId_ = 0;
|
||||||
this.equalityTesters_ = [];
|
this.equalityTesters_ = [];
|
||||||
|
|
||||||
|
// wrap matchers
|
||||||
|
this.matchersClass = function() {
|
||||||
|
jasmine.Matchers.apply(this, arguments);
|
||||||
|
};
|
||||||
|
jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
|
||||||
|
|
||||||
|
for (var methodName in jasmine.Matchers.prototype) {
|
||||||
|
var orig = jasmine.Matchers.prototype[methodName];
|
||||||
|
this.matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -898,7 +922,7 @@ jasmine.JsApiReporter.prototype.suites = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
|
||||||
var isSuite = suiteOrSpec instanceof jasmine.Suite
|
var isSuite = suiteOrSpec instanceof jasmine.Suite;
|
||||||
var summary = {
|
var summary = {
|
||||||
id: suiteOrSpec.id,
|
id: suiteOrSpec.id,
|
||||||
name: suiteOrSpec.description,
|
name: suiteOrSpec.description,
|
||||||
|
@ -954,7 +978,8 @@ jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
|
||||||
|
|
||||||
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||||
var summaryMessages = [];
|
var summaryMessages = [];
|
||||||
for (var messageIndex in result.messages) {
|
var messagesLength = result.messages.length
|
||||||
|
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
|
||||||
var resultMessage = result.messages[messageIndex];
|
var resultMessage = result.messages[messageIndex];
|
||||||
summaryMessages.push({
|
summaryMessages.push({
|
||||||
text: resultMessage.text,
|
text: resultMessage.text,
|
||||||
|
@ -979,7 +1004,7 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
|
||||||
* @constructor
|
* @constructor
|
||||||
* @param {jasmine.Env} env
|
* @param {jasmine.Env} env
|
||||||
* @param actual
|
* @param actual
|
||||||
* @param {jasmine.NestedResults} results
|
* @param {jasmine.Spec} spec
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers = function(env, actual, spec) {
|
jasmine.Matchers = function(env, actual, spec) {
|
||||||
this.env = env;
|
this.env = env;
|
||||||
|
@ -1001,15 +1026,25 @@ jasmine.Matchers.prototype.report = function(result, failing_message, details) {
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Matchers.matcherFn_ = function(matcherName, options) {
|
jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
|
||||||
return function () {
|
return function() {
|
||||||
jasmine.util.extend(this, options);
|
|
||||||
var matcherArgs = jasmine.util.argsToArray(arguments);
|
var matcherArgs = jasmine.util.argsToArray(arguments);
|
||||||
var args = [this.actual].concat(matcherArgs);
|
var result = matcherFunction.apply(this, arguments);
|
||||||
var result = options.test.apply(this, args);
|
|
||||||
var message;
|
var message;
|
||||||
if (!result) {
|
if (!result) {
|
||||||
message = options.message.apply(this, args);
|
if (this.message) {
|
||||||
|
message = this.message.apply(this, arguments);
|
||||||
|
} else {
|
||||||
|
var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
|
||||||
|
message = "Expected " + jasmine.pp(this.actual) + " " + englishyPredicate;
|
||||||
|
if (matcherArgs.length > 0) {
|
||||||
|
for (var i = 0; i < matcherArgs.length; i++) {
|
||||||
|
if (i > 0) message += ",";
|
||||||
|
message += " " + jasmine.pp(matcherArgs[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
message += ".";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
var expectationResult = new jasmine.ExpectationResult({
|
var expectationResult = new jasmine.ExpectationResult({
|
||||||
matcherName: matcherName,
|
matcherName: matcherName,
|
||||||
|
@ -1031,27 +1066,17 @@ jasmine.Matchers.matcherFn_ = function(matcherName, options) {
|
||||||
* @param expected
|
* @param expected
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jasmine.Matchers.prototype.toBe = jasmine.Matchers.matcherFn_('toBe', {
|
jasmine.Matchers.prototype.toBe = function(expected) {
|
||||||
test: function (actual, expected) {
|
return this.actual === expected;
|
||||||
return actual === expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to be " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toNotBe: compares the actual to the expected using !==
|
* toNotBe: compares the actual to the expected using !==
|
||||||
* @param expected
|
* @param expected
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toNotBe = jasmine.Matchers.matcherFn_('toNotBe', {
|
jasmine.Matchers.prototype.toNotBe = function(expected) {
|
||||||
test: function (actual, expected) {
|
return this.actual !== expected;
|
||||||
return actual !== expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to not be " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
|
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
|
||||||
|
@ -1059,27 +1084,17 @@ jasmine.Matchers.prototype.toNotBe = jasmine.Matchers.matcherFn_('toNotBe', {
|
||||||
* @param expected
|
* @param expected
|
||||||
*/
|
*/
|
||||||
|
|
||||||
jasmine.Matchers.prototype.toEqual = jasmine.Matchers.matcherFn_('toEqual', {
|
jasmine.Matchers.prototype.toEqual = function(expected) {
|
||||||
test: function (actual, expected) {
|
return this.env.equals_(this.actual, expected);
|
||||||
return this.env.equals_(actual, expected);
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to equal " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
|
||||||
* @param expected
|
* @param expected
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toNotEqual = jasmine.Matchers.matcherFn_('toNotEqual', {
|
jasmine.Matchers.prototype.toNotEqual = function(expected) {
|
||||||
test: function (actual, expected) {
|
return !this.env.equals_(this.actual, expected);
|
||||||
return !this.env.equals_(actual, expected);
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return "Expected " + jasmine.pp(actual) + " to not equal " + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
|
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
|
||||||
|
@ -1087,228 +1102,143 @@ jasmine.Matchers.prototype.toNotEqual = jasmine.Matchers.matcherFn_('toNotEqual'
|
||||||
*
|
*
|
||||||
* @param reg_exp
|
* @param reg_exp
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toMatch = jasmine.Matchers.matcherFn_('toMatch', {
|
jasmine.Matchers.prototype.toMatch = function(expected) {
|
||||||
test: function(actual, expected) {
|
return new RegExp(expected).test(this.actual);
|
||||||
return new RegExp(expected).test(actual);
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return jasmine.pp(actual) + " does not match the regular expression " + new RegExp(expected).toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
|
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
|
||||||
* @param reg_exp
|
* @param reg_exp
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toNotMatch = function(expected) {
|
||||||
jasmine.Matchers.prototype.toNotMatch = jasmine.Matchers.matcherFn_('toNotMatch', {
|
return !(new RegExp(expected).test(this.actual));
|
||||||
test: function(actual, expected) {
|
};
|
||||||
return !(new RegExp(expected).test(actual));
|
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return jasmine.pp(actual) + " should not match " + new RegExp(expected).toString();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the acutal to undefined.
|
* Matcher that compares the actual to undefined.
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toBeDefined = function() {
|
||||||
jasmine.Matchers.prototype.toBeDefined = jasmine.Matchers.matcherFn_('toBeDefined', {
|
return (this.actual !== undefined);
|
||||||
test: function(actual) {
|
};
|
||||||
return (actual !== undefined);
|
|
||||||
},
|
|
||||||
message: function() {
|
|
||||||
return 'Expected actual to not be undefined.';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the acutal to undefined.
|
* Matcher that compares the actual to undefined.
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toBeUndefined = function() {
|
||||||
jasmine.Matchers.prototype.toBeUndefined = jasmine.Matchers.matcherFn_('toBeUndefined', {
|
return (this.actual === undefined);
|
||||||
test: function(actual) {
|
};
|
||||||
return (actual === undefined);
|
|
||||||
},
|
|
||||||
message: function(actual) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be undefined.';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that compares the actual to null.
|
* Matcher that compares the actual to null.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toBeNull = jasmine.Matchers.matcherFn_('toBeNull', {
|
jasmine.Matchers.prototype.toBeNull = function() {
|
||||||
test: function(actual) {
|
return (this.actual === null);
|
||||||
return (actual === null);
|
};
|
||||||
},
|
|
||||||
message: function(actual) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be null.';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that boolean not-nots the actual.
|
* Matcher that boolean not-nots the actual.
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toBeTruthy = jasmine.Matchers.matcherFn_('toBeTruthy', {
|
jasmine.Matchers.prototype.toBeTruthy = function() {
|
||||||
test: function(actual) {
|
return !!this.actual;
|
||||||
return !!actual;
|
};
|
||||||
},
|
|
||||||
message: function() {
|
|
||||||
return 'Expected actual to be truthy';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that boolean nots the actual.
|
* Matcher that boolean nots the actual.
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toBeFalsy = jasmine.Matchers.matcherFn_('toBeFalsy', {
|
jasmine.Matchers.prototype.toBeFalsy = function() {
|
||||||
test: function(actual) {
|
return !this.actual;
|
||||||
return !actual;
|
};
|
||||||
},
|
|
||||||
message: function(actual) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be falsy';
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks to see if the acutal, a Jasmine spy, was called.
|
* Matcher that checks to see if the actual, a Jasmine spy, was called.
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.wasCalled = function() {
|
||||||
|
if (arguments.length > 0) {
|
||||||
|
throw new Error('wasCalled does not take arguments, use wasCalledWith');
|
||||||
|
}
|
||||||
|
|
||||||
jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.matcherFn_('wasCalled', {
|
if (!jasmine.isSpy(this.actual)) {
|
||||||
getActual_: function() {
|
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||||
var args = jasmine.util.argsToArray(arguments);
|
|
||||||
if (args.length > 1) {
|
|
||||||
throw(new Error('wasCalled does not take arguments, use wasCalledWith'));
|
|
||||||
}
|
}
|
||||||
return args.splice(0, 1)[0];
|
|
||||||
},
|
this.message = function() {
|
||||||
test: function() {
|
return "Expected spy " + this.actual.identity + " to have been called.";
|
||||||
var actual = this.getActual_.apply(this, arguments);
|
};
|
||||||
if (!actual || !actual.isSpy) {
|
|
||||||
return false;
|
return this.actual.wasCalled;
|
||||||
}
|
};
|
||||||
return actual.wasCalled;
|
|
||||||
},
|
|
||||||
message: function() {
|
|
||||||
var actual = this.getActual_.apply(this, arguments);
|
|
||||||
if (!actual || !actual.isSpy) {
|
|
||||||
return 'Actual is not a spy.';
|
|
||||||
}
|
|
||||||
return "Expected spy " + actual.identity + " to have been called.";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks to see if the acutal, a Jasmine spy, was not called.
|
* Matcher that checks to see if the actual, a Jasmine spy, was not called.
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.wasNotCalled = jasmine.Matchers.matcherFn_('wasNotCalled', {
|
jasmine.Matchers.prototype.wasNotCalled = function() {
|
||||||
getActual_: function() {
|
if (arguments.length > 0) {
|
||||||
var args = jasmine.util.argsToArray(arguments);
|
throw new Error('wasNotCalled does not take arguments');
|
||||||
return args.splice(0, 1)[0];
|
|
||||||
},
|
|
||||||
test: function() {
|
|
||||||
var actual = this.getActual_.apply(this, arguments);
|
|
||||||
if (!actual || !actual.isSpy) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return !actual.wasCalled;
|
|
||||||
},
|
|
||||||
message: function() {
|
|
||||||
var actual = this.getActual_.apply(this, arguments);
|
|
||||||
if (!actual || !actual.isSpy) {
|
|
||||||
return 'Actual is not a spy.';
|
|
||||||
}
|
|
||||||
return "Expected spy " + actual.identity + " to not have been called.";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.matcherFn_('wasCalledWith', {
|
if (!jasmine.isSpy(this.actual)) {
|
||||||
test: function() {
|
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||||
var args = jasmine.util.argsToArray(arguments);
|
|
||||||
var actual = args.splice(0, 1)[0];
|
|
||||||
if (!actual || !actual.isSpy) {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return this.env.contains_(actual.argsForCall, args);
|
|
||||||
},
|
this.message = function() {
|
||||||
message: function() {
|
return "Expected spy " + this.actual.identity + " to not have been called.";
|
||||||
var args = jasmine.util.argsToArray(arguments);
|
};
|
||||||
var actual = args.splice(0, 1)[0];
|
|
||||||
var message;
|
return !this.actual.wasCalled;
|
||||||
if (!actual || !actual.isSpy) {
|
};
|
||||||
message = 'Actual is not a spy';
|
|
||||||
} else {
|
|
||||||
message = "Expected spy to have been called with " + jasmine.pp(args) + " but was called with " + actual.argsForCall;
|
|
||||||
}
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks to see if the acutal, a Jasmine spy, was called with a set of parameters.
|
* Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.wasCalledWith = function() {
|
||||||
|
if (!jasmine.isSpy(this.actual)) {
|
||||||
|
throw new Error('Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.message = function() {
|
||||||
|
return "Expected spy to have been called with " + jasmine.pp(arguments) + " but was called with " + jasmine.pp(this.actual.argsForCall);
|
||||||
|
};
|
||||||
|
|
||||||
|
return this.env.contains_(this.actual.argsForCall, jasmine.util.argsToArray(arguments));
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks that the expected item is an element in the actual Array.
|
* Matcher that checks that the expected item is an element in the actual Array.
|
||||||
*
|
*
|
||||||
* @param {Object} item
|
* @param {Object} item
|
||||||
*/
|
*/
|
||||||
|
jasmine.Matchers.prototype.toContain = function(expected) {
|
||||||
jasmine.Matchers.prototype.toContain = jasmine.Matchers.matcherFn_('toContain', {
|
return this.env.contains_(this.actual, expected);
|
||||||
test: function(actual, expected) {
|
};
|
||||||
return this.env.contains_(actual, expected);
|
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to contain ' + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks that the expected item is NOT an element in the actual Array.
|
* Matcher that checks that the expected item is NOT an element in the actual Array.
|
||||||
*
|
*
|
||||||
* @param {Object} item
|
* @param {Object} item
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toNotContain = jasmine.Matchers.matcherFn_('toNotContain', {
|
jasmine.Matchers.prototype.toNotContain = function(expected) {
|
||||||
test: function(actual, expected) {
|
return !this.env.contains_(this.actual, expected);
|
||||||
return !this.env.contains_(actual, expected);
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to not contain ' + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jasmine.Matchers.prototype.toBeLessThan = jasmine.Matchers.matcherFn_('toBeLessThan', {
|
jasmine.Matchers.prototype.toBeLessThan = function(expected) {
|
||||||
test: function(actual, expected) {
|
return this.actual < expected;
|
||||||
return actual < expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be less than ' + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jasmine.Matchers.prototype.toBeGreaterThan = jasmine.Matchers.matcherFn_('toBeGreaterThan', {
|
jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
|
||||||
test: function(actual, expected) {
|
return this.actual > expected;
|
||||||
return actual > expected;
|
};
|
||||||
},
|
|
||||||
message: function(actual, expected) {
|
|
||||||
return 'Expected ' + jasmine.pp(actual) + ' to be greater than ' + jasmine.pp(expected);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Matcher that checks that the expected exception was thrown by the actual.
|
* Matcher that checks that the expected exception was thrown by the actual.
|
||||||
*
|
*
|
||||||
* @param {String} expectedException
|
* @param {String} expectedException
|
||||||
*/
|
*/
|
||||||
jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', {
|
jasmine.Matchers.prototype.toThrow = function(expected) {
|
||||||
getException_: function(actual, expected) {
|
function getException_(actual, expected) {
|
||||||
var exception;
|
var exception;
|
||||||
if (typeof actual != 'function') {
|
if (typeof actual != 'function') {
|
||||||
throw new Error('Actual is not a function');
|
throw new Error('Actual is not a function');
|
||||||
|
@ -1319,24 +1249,25 @@ jasmine.Matchers.prototype.toThrow = jasmine.Matchers.matcherFn_('toThrow', {
|
||||||
exception = e;
|
exception = e;
|
||||||
}
|
}
|
||||||
return exception;
|
return exception;
|
||||||
},
|
}
|
||||||
test: function(actual, expected) {
|
|
||||||
var result = false;
|
var result = false;
|
||||||
var exception = this.getException_(actual, expected);
|
var exception = getException_(this.actual, expected);
|
||||||
if (exception) {
|
if (exception) {
|
||||||
result = (expected === undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
result = (expected === undefined || this.env.equals_(exception.message || exception, expected.message || expected));
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
},
|
this.message = function(expected) {
|
||||||
message: function(actual, expected) {
|
var exception = getException_(this.actual, expected);
|
||||||
var exception = this.getException_(actual, expected);
|
|
||||||
if (exception && (expected === undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
if (exception && (expected === undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
|
||||||
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' ');
|
return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception ].join(' ');
|
||||||
} else {
|
} else {
|
||||||
return "Expected function to throw an exception.";
|
return "Expected function to throw an exception.";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
});
|
|
||||||
|
return result;
|
||||||
|
};
|
||||||
|
|
||||||
jasmine.Matchers.Any = function(expectedClass) {
|
jasmine.Matchers.Any = function(expectedClass) {
|
||||||
this.expectedClass = expectedClass;
|
this.expectedClass = expectedClass;
|
||||||
|
@ -1485,11 +1416,9 @@ jasmine.PrettyPrinter = function() {
|
||||||
* Formats a value in a nice, human-readable string.
|
* Formats a value in a nice, human-readable string.
|
||||||
*
|
*
|
||||||
* @param value
|
* @param value
|
||||||
* @returns {String}
|
|
||||||
*/
|
*/
|
||||||
jasmine.PrettyPrinter.prototype.format = function(value) {
|
jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||||
if (this.ppNestLevel_ > 40) {
|
if (this.ppNestLevel_ > 40) {
|
||||||
// return '(jasmine.pp nested too deeply!)';
|
|
||||||
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
|
throw new Error('jasmine.PrettyPrinter: format() nested too deeply!');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1505,12 +1434,16 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
|
||||||
this.emitScalar(value.toString());
|
this.emitScalar(value.toString());
|
||||||
} else if (typeof value === 'string') {
|
} else if (typeof value === 'string') {
|
||||||
this.emitString(value);
|
this.emitString(value);
|
||||||
|
} else if (jasmine.isSpy(value)) {
|
||||||
|
this.emitScalar("spy on " + value.identity);
|
||||||
} else if (typeof value === 'function') {
|
} else if (typeof value === 'function') {
|
||||||
this.emitScalar('Function');
|
this.emitScalar('Function');
|
||||||
} else if (typeof value.nodeType === 'number') {
|
} else if (typeof value.nodeType === 'number') {
|
||||||
this.emitScalar('HTMLNode');
|
this.emitScalar('HTMLNode');
|
||||||
} else if (value instanceof Date) {
|
} else if (value instanceof Date) {
|
||||||
this.emitScalar('Date(' + value + ')');
|
this.emitScalar('Date(' + value + ')');
|
||||||
|
} else if (value instanceof RegExp) {
|
||||||
|
this.emitScalar(value.toString());
|
||||||
} else if (value.__Jasmine_been_here_before__) {
|
} else if (value.__Jasmine_been_here_before__) {
|
||||||
this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
|
this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
|
||||||
} else if (jasmine.isArray_(value) || typeof value == 'object') {
|
} else if (jasmine.isArray_(value) || typeof value == 'object') {
|
||||||
|
@ -1688,13 +1621,23 @@ jasmine.Queue.prototype.results = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* JasmineReporters.reporter
|
/** JasmineReporters.reporter
|
||||||
* Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
|
* Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to
|
||||||
* descendants of this object to do something with the results (see json_reporter.js)
|
* descendants of this object to do something with the results (see json_reporter.js)
|
||||||
|
*
|
||||||
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
jasmine.Reporters = {};
|
jasmine.Reporters = {};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param callbacks
|
||||||
|
*/
|
||||||
jasmine.Reporters.reporter = function(callbacks) {
|
jasmine.Reporters.reporter = function(callbacks) {
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
* @param callbacks
|
||||||
|
*/
|
||||||
var that = {
|
var that = {
|
||||||
callbacks: callbacks || {},
|
callbacks: callbacks || {},
|
||||||
|
|
||||||
|
@ -1801,11 +1744,9 @@ jasmine.Spec = function(env, suite, description) {
|
||||||
if (!env) {
|
if (!env) {
|
||||||
throw new Error('jasmine.Env() required');
|
throw new Error('jasmine.Env() required');
|
||||||
}
|
}
|
||||||
;
|
|
||||||
if (!suite) {
|
if (!suite) {
|
||||||
throw new Error('jasmine.Suite() required');
|
throw new Error('jasmine.Suite() required');
|
||||||
}
|
}
|
||||||
;
|
|
||||||
var spec = this;
|
var spec = this;
|
||||||
spec.id = env.nextSpecId ? env.nextSpecId() : null;
|
spec.id = env.nextSpecId ? env.nextSpecId() : null;
|
||||||
spec.env = env;
|
spec.env = env;
|
||||||
|
@ -1882,7 +1823,7 @@ jasmine.Spec.prototype.fail = function (e) {
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Spec.prototype.getMatchersClass_ = function() {
|
jasmine.Spec.prototype.getMatchersClass_ = function() {
|
||||||
return this.matchersClass || jasmine.Matchers;
|
return this.matchersClass || this.env.matchersClass;
|
||||||
};
|
};
|
||||||
|
|
||||||
jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
|
||||||
|
@ -2204,7 +2145,9 @@ jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @namespace
|
||||||
|
*/
|
||||||
jasmine.Clock = {
|
jasmine.Clock = {
|
||||||
defaultFakeTimer: new jasmine.FakeTimer(),
|
defaultFakeTimer: new jasmine.FakeTimer(),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue