add single quote check to jshint and fix src files for that
[fixes #522]
This commit is contained in:
committed by
Greg Cobb and Sheel Choksi
parent
095b02ad83
commit
31d71ac22f
@@ -32,7 +32,7 @@ getJasmineRequireObj().Clock = function() {
|
||||
self.setTimeout = function(fn, delay, params) {
|
||||
if (legacyIE()) {
|
||||
if (arguments.length > 2) {
|
||||
throw new Error("IE < 9 cannot support extra params to setTimeout without a polyfill");
|
||||
throw new Error('IE < 9 cannot support extra params to setTimeout without a polyfill');
|
||||
}
|
||||
return timer.setTimeout(fn, delay);
|
||||
}
|
||||
@@ -42,7 +42,7 @@ getJasmineRequireObj().Clock = function() {
|
||||
self.setInterval = function(fn, delay, params) {
|
||||
if (legacyIE()) {
|
||||
if (arguments.length > 2) {
|
||||
throw new Error("IE < 9 cannot support extra params to setInterval without a polyfill");
|
||||
throw new Error('IE < 9 cannot support extra params to setInterval without a polyfill');
|
||||
}
|
||||
return timer.setInterval(fn, delay);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ getJasmineRequireObj().Clock = function() {
|
||||
if (installed) {
|
||||
delayedFunctionScheduler.tick(millis);
|
||||
} else {
|
||||
throw new Error("Mock clock is not installed, use jasmine.clock().install()");
|
||||
throw new Error('Mock clock is not installed, use jasmine.clock().install()');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -21,12 +21,12 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
var currentSuite = null;
|
||||
|
||||
var reporter = new j$.ReportDispatcher([
|
||||
"jasmineStarted",
|
||||
"jasmineDone",
|
||||
"suiteStarted",
|
||||
"suiteDone",
|
||||
"specStarted",
|
||||
"specDone"
|
||||
'jasmineStarted',
|
||||
'jasmineDone',
|
||||
'suiteStarted',
|
||||
'suiteDone',
|
||||
'specStarted',
|
||||
'specDone'
|
||||
]);
|
||||
|
||||
this.specFilter = function() {
|
||||
@@ -180,7 +180,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
|
||||
this.spyOn = function(obj, methodName) {
|
||||
if (j$.util.isUndefined(obj)) {
|
||||
throw new Error("spyOn could not find an object to spy upon for " + methodName + "()");
|
||||
throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
|
||||
}
|
||||
|
||||
if (j$.util.isUndefined(obj[methodName])) {
|
||||
@@ -238,7 +238,7 @@ getJasmineRequireObj().Env = function(j$) {
|
||||
}
|
||||
|
||||
if (declarationError) {
|
||||
this.it("encountered a declaration exception", function() {
|
||||
this.it('encountered a declaration exception', function() {
|
||||
throw declarationError;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ getJasmineRequireObj().ExceptionFormatter = function() {
|
||||
}
|
||||
|
||||
if (error.fileName || error.sourceURL) {
|
||||
message += " in " + (error.fileName || error.sourceURL);
|
||||
message += ' in ' + (error.fileName || error.sourceURL);
|
||||
}
|
||||
|
||||
if (error.line || error.lineNumber) {
|
||||
message += " (line " + (error.line || error.lineNumber) + ")";
|
||||
message += ' (line ' + (error.line || error.lineNumber) + ')';
|
||||
}
|
||||
|
||||
return message;
|
||||
|
||||
@@ -18,7 +18,7 @@ getJasmineRequireObj().Expectation = function() {
|
||||
return function() {
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
expected = args.slice(0),
|
||||
message = "";
|
||||
message = '';
|
||||
|
||||
args.unshift(this.actual);
|
||||
|
||||
@@ -43,7 +43,7 @@ getJasmineRequireObj().Expectation = function() {
|
||||
args.unshift(name);
|
||||
message = this.util.buildFailureMessage.apply(null, args);
|
||||
} else {
|
||||
if (Object.prototype.toString.apply(result.message) === "[object Function]") {
|
||||
if (Object.prototype.toString.apply(result.message) === '[object Function]') {
|
||||
message = result.message();
|
||||
} else {
|
||||
message = result.message;
|
||||
|
||||
@@ -15,18 +15,18 @@ getJasmineRequireObj().buildExpectationResult = function() {
|
||||
|
||||
function message() {
|
||||
if (options.passed) {
|
||||
return "Passed.";
|
||||
return 'Passed.';
|
||||
} else if (options.message) {
|
||||
return options.message;
|
||||
} else if (options.error) {
|
||||
return messageFormatter(options.error);
|
||||
}
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
function stack() {
|
||||
if (options.passed) {
|
||||
return "";
|
||||
return '';
|
||||
}
|
||||
|
||||
var error = options.error;
|
||||
|
||||
@@ -7,7 +7,7 @@ getJasmineRequireObj().JsApiReporter = function() {
|
||||
|
||||
function JsApiReporter(options) {
|
||||
var timer = options.timer || noopTimer,
|
||||
status = "loaded";
|
||||
status = 'loaded';
|
||||
|
||||
this.started = false;
|
||||
this.finished = false;
|
||||
|
||||
@@ -5,7 +5,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
||||
}
|
||||
|
||||
ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
|
||||
if (typeof(this.sample) !== "object") { throw new Error("You must provide an object to objectContaining, not '"+this.sample+"'."); }
|
||||
if (typeof(this.sample) !== 'object') { throw new Error('You must provide an object to objectContaining, not \''+this.sample+'\'.'); }
|
||||
|
||||
mismatchKeys = mismatchKeys || [];
|
||||
mismatchValues = mismatchValues || [];
|
||||
@@ -16,10 +16,10 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
||||
|
||||
for (var property in this.sample) {
|
||||
if (!hasKey(other, property) && hasKey(this.sample, property)) {
|
||||
mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
|
||||
mismatchKeys.push('expected has key \'' + property + '\', but missing from actual.');
|
||||
}
|
||||
else if (!j$.matchersUtil.equals(this.sample[property], other[property])) {
|
||||
mismatchValues.push("'" + property + "' was '" + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + "' in actual, but was '" + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in expected.");
|
||||
mismatchValues.push('\'' + property + '\' was \'' + (other[property] ? j$.util.htmlEscape(other[property].toString()) : other[property]) + '\' in actual, but was \'' + (this.sample[property] ? j$.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + '\' in expected.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ getJasmineRequireObj().ObjectContaining = function(j$) {
|
||||
};
|
||||
|
||||
ObjectContaining.prototype.jasmineToString = function() {
|
||||
return "<jasmine.objectContaining(" + j$.pp(this.sample) + ")>";
|
||||
return '<jasmine.objectContaining(' + j$.pp(this.sample) + ')>';
|
||||
};
|
||||
|
||||
return ObjectContaining;
|
||||
|
||||
@@ -20,7 +20,7 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
} else if (typeof value === 'string') {
|
||||
this.emitString(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) {
|
||||
this.emitScalar(value.toString());
|
||||
} else if (typeof value === 'function') {
|
||||
@@ -74,12 +74,12 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
};
|
||||
|
||||
StringPrettyPrinter.prototype.emitString = function(value) {
|
||||
this.append("'" + value + "'");
|
||||
this.append('\'' + value + '\'');
|
||||
};
|
||||
|
||||
StringPrettyPrinter.prototype.emitArray = function(array) {
|
||||
if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
|
||||
this.append("Array");
|
||||
this.append('Array');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ getJasmineRequireObj().pp = function(j$) {
|
||||
|
||||
StringPrettyPrinter.prototype.emitObject = function(obj) {
|
||||
if (this.ppNestLevel_ > j$.MAX_PRETTY_PRINT_DEPTH) {
|
||||
this.append("Object");
|
||||
this.append('Object');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -92,10 +92,10 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
}
|
||||
|
||||
self.addExpectationResult(false, {
|
||||
matcherName: "",
|
||||
matcherName: '',
|
||||
passed: false,
|
||||
expected: "",
|
||||
actual: "",
|
||||
expected: '',
|
||||
actual: '',
|
||||
error: e
|
||||
});
|
||||
}
|
||||
@@ -138,7 +138,7 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return this.getSpecName(this);
|
||||
};
|
||||
|
||||
Spec.pendingSpecExceptionMessage = "=> marked Pending";
|
||||
Spec.pendingSpecExceptionMessage = '=> marked Pending';
|
||||
|
||||
Spec.isPendingSpecException = function(e) {
|
||||
return !!(e && e.toString && e.toString().indexOf(Spec.pendingSpecExceptionMessage) !== -1);
|
||||
@@ -147,6 +147,6 @@ getJasmineRequireObj().Spec = function(j$) {
|
||||
return Spec;
|
||||
};
|
||||
|
||||
if (typeof window == void 0 && typeof exports == "object") {
|
||||
if (typeof window == void 0 && typeof exports == 'object') {
|
||||
exports.Spec = jasmineRequire.Spec;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ getJasmineRequireObj().SpyStrategy = function() {
|
||||
function SpyStrategy(options) {
|
||||
options = options || {};
|
||||
|
||||
var identity = options.name || "unknown",
|
||||
var identity = options.name || 'unknown',
|
||||
originalFn = options.fn || function() {},
|
||||
getSpy = options.getSpy || function() {},
|
||||
plan = function() {};
|
||||
|
||||
@@ -85,6 +85,6 @@ getJasmineRequireObj().Suite = function() {
|
||||
return Suite;
|
||||
};
|
||||
|
||||
if (typeof window == void 0 && typeof exports == "object") {
|
||||
if (typeof window == void 0 && typeof exports == 'object') {
|
||||
exports.Suite = jasmineRequire.Suite;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
getJasmineRequireObj().base = (function (jasmineGlobal) {
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
jasmineGlobal = global;
|
||||
}
|
||||
|
||||
return function(j$) {
|
||||
j$.unimplementedMethod_ = function() {
|
||||
throw new Error("unimplemented method");
|
||||
throw new Error('unimplemented method');
|
||||
};
|
||||
|
||||
j$.MAX_PRETTY_PRINT_DEPTH = 40;
|
||||
@@ -22,15 +22,15 @@ getJasmineRequireObj().base = (function (jasmineGlobal) {
|
||||
};
|
||||
|
||||
j$.isArray_ = function(value) {
|
||||
return j$.isA_("Array", value);
|
||||
return j$.isA_('Array', value);
|
||||
};
|
||||
|
||||
j$.isString_ = function(value) {
|
||||
return j$.isA_("String", value);
|
||||
return j$.isA_('String', value);
|
||||
};
|
||||
|
||||
j$.isNumber_ = function(value) {
|
||||
return j$.isA_("Number", value);
|
||||
return j$.isA_('Number', value);
|
||||
};
|
||||
|
||||
j$.isA_ = function(typeName, value) {
|
||||
@@ -67,7 +67,7 @@ getJasmineRequireObj().base = (function (jasmineGlobal) {
|
||||
|
||||
for (var prop in originalFn) {
|
||||
if (prop === 'and' || prop === 'calls') {
|
||||
throw new Error("Jasmine spies would overwrite the 'and' and 'calls' properties on the object being spied upon");
|
||||
throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon');
|
||||
}
|
||||
|
||||
spy[prop] = originalFn[prop];
|
||||
@@ -89,7 +89,7 @@ getJasmineRequireObj().base = (function (jasmineGlobal) {
|
||||
|
||||
j$.createSpyObj = function(baseName, methodNames) {
|
||||
if (!j$.isArray_(methodNames) || methodNames.length === 0) {
|
||||
throw "createSpyObj requires a non-empty array of method names to create spies for";
|
||||
throw 'createSpyObj requires a non-empty array of method names to create spies for';
|
||||
}
|
||||
var obj = {};
|
||||
for (var i = 0; i < methodNames.length; i++) {
|
||||
|
||||
@@ -11,7 +11,7 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
contains: function(haystack, needle, customTesters) {
|
||||
customTesters = customTesters || [];
|
||||
|
||||
if (Object.prototype.toString.apply(haystack) === "[object Array]") {
|
||||
if (Object.prototype.toString.apply(haystack) === '[object Array]') {
|
||||
for (var i = 0; i < haystack.length; i++) {
|
||||
if (eq(haystack[i], needle, [], [], customTesters)) {
|
||||
return true;
|
||||
@@ -30,21 +30,21 @@ getJasmineRequireObj().matchersUtil = function(j$) {
|
||||
expected = args.slice(3),
|
||||
englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
|
||||
|
||||
var message = "Expected " +
|
||||
var message = 'Expected ' +
|
||||
j$.pp(actual) +
|
||||
(isNot ? " not " : " ") +
|
||||
(isNot ? ' not ' : ' ') +
|
||||
englishyPredicate;
|
||||
|
||||
if (expected.length > 0) {
|
||||
for (var i = 0; i < expected.length; i++) {
|
||||
if (i > 0) {
|
||||
message += ",";
|
||||
message += ',';
|
||||
}
|
||||
message += " " + j$.pp(expected[i]);
|
||||
message += ' ' + j$.pp(expected[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return message + ".";
|
||||
return message + '.';
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
getJasmineRequireObj().requireMatchers = function(jRequire, j$) {
|
||||
var availableMatchers = [
|
||||
"toBe",
|
||||
"toBeCloseTo",
|
||||
"toBeDefined",
|
||||
"toBeFalsy",
|
||||
"toBeGreaterThan",
|
||||
"toBeLessThan",
|
||||
"toBeNaN",
|
||||
"toBeNull",
|
||||
"toBeTruthy",
|
||||
"toBeUndefined",
|
||||
"toContain",
|
||||
"toEqual",
|
||||
"toHaveBeenCalled",
|
||||
"toHaveBeenCalledWith",
|
||||
"toMatch",
|
||||
"toThrow",
|
||||
"toThrowError"
|
||||
'toBe',
|
||||
'toBeCloseTo',
|
||||
'toBeDefined',
|
||||
'toBeFalsy',
|
||||
'toBeGreaterThan',
|
||||
'toBeLessThan',
|
||||
'toBeNaN',
|
||||
'toBeNull',
|
||||
'toBeTruthy',
|
||||
'toBeUndefined',
|
||||
'toContain',
|
||||
'toEqual',
|
||||
'toHaveBeenCalled',
|
||||
'toHaveBeenCalledWith',
|
||||
'toMatch',
|
||||
'toThrow',
|
||||
'toThrowError'
|
||||
],
|
||||
matchers = {};
|
||||
|
||||
|
||||
@@ -8,9 +8,9 @@ getJasmineRequireObj().toBeNaN = function(j$) {
|
||||
};
|
||||
|
||||
if (result.pass) {
|
||||
result.message = "Expected actual not to be NaN.";
|
||||
result.message = 'Expected actual not to be NaN.';
|
||||
} else {
|
||||
result.message = function() { return "Expected " + j$.pp(actual) + " to be NaN."; };
|
||||
result.message = function() { return 'Expected ' + j$.pp(actual) + ' to be NaN.'; };
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -16,8 +16,8 @@ getJasmineRequireObj().toHaveBeenCalled = function(j$) {
|
||||
result.pass = actual.calls.any();
|
||||
|
||||
result.message = result.pass ?
|
||||
"Expected spy " + actual.and.identity() + " not to have been called." :
|
||||
"Expected spy " + actual.and.identity() + " to have been called.";
|
||||
'Expected spy ' + actual.and.identity() + ' not to have been called.' :
|
||||
'Expected spy ' + actual.and.identity() + ' to have been called.';
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -13,15 +13,15 @@ getJasmineRequireObj().toHaveBeenCalledWith = function(j$) {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
if (util.contains(actual.calls.allArgs(), expectedArgs)) {
|
||||
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 {
|
||||
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;
|
||||
|
||||
@@ -7,8 +7,8 @@ getJasmineRequireObj().toThrow = function(j$) {
|
||||
threw = false,
|
||||
thrown;
|
||||
|
||||
if (typeof actual != "function") {
|
||||
throw new Error("Actual is not a Function");
|
||||
if (typeof actual != 'function') {
|
||||
throw new Error('Actual is not a Function');
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -19,22 +19,22 @@ getJasmineRequireObj().toThrow = function(j$) {
|
||||
}
|
||||
|
||||
if (!threw) {
|
||||
result.message = "Expected function to throw an exception.";
|
||||
result.message = 'Expected function to throw an exception.';
|
||||
return result;
|
||||
}
|
||||
|
||||
if (arguments.length == 1) {
|
||||
result.pass = true;
|
||||
result.message = function() { return "Expected function not to throw, but it threw " + j$.pp(thrown) + "."; };
|
||||
result.message = function() { return 'Expected function not to throw, but it threw ' + j$.pp(thrown) + '.'; };
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
if (util.equals(thrown, expected)) {
|
||||
result.pass = true;
|
||||
result.message = function() { return "Expected function not to throw " + j$.pp(expected) + "."; };
|
||||
result.message = function() { return 'Expected function not to throw ' + j$.pp(expected) + '.'; };
|
||||
} else {
|
||||
result.message = function() { return "Expected function to throw " + j$.pp(expected) + ", but it threw " + j$.pp(thrown) + "."; };
|
||||
result.message = function() { return 'Expected function to throw ' + j$.pp(expected) + ', but it threw ' + j$.pp(thrown) + '.'; };
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -12,8 +12,8 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
name,
|
||||
constructorName;
|
||||
|
||||
if (typeof actual != "function") {
|
||||
throw new Error("Actual is not a Function");
|
||||
if (typeof actual != 'function') {
|
||||
throw new Error('Actual is not a Function');
|
||||
}
|
||||
|
||||
extractExpectedParams.apply(null, arguments);
|
||||
@@ -26,17 +26,17 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
}
|
||||
|
||||
if (!threw) {
|
||||
fail.message = "Expected function to throw an Error.";
|
||||
fail.message = 'Expected function to throw an Error.';
|
||||
return fail;
|
||||
}
|
||||
|
||||
if (!(thrown instanceof Error)) {
|
||||
fail.message = function() { return "Expected function to throw an Error, but it threw " + j$.pp(thrown) + "."; };
|
||||
fail.message = function() { return 'Expected function to throw an Error, but it threw ' + j$.pp(thrown) + '.'; };
|
||||
return fail;
|
||||
}
|
||||
|
||||
if (arguments.length == 1) {
|
||||
pass.message = "Expected function not to throw an Error, but it threw " + fnNameFor(thrown) + ".";
|
||||
pass.message = 'Expected function not to throw an Error, but it threw ' + fnNameFor(thrown) + '.';
|
||||
return pass;
|
||||
}
|
||||
|
||||
@@ -47,54 +47,54 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
|
||||
if (errorType && message) {
|
||||
if (thrown.constructor == errorType && util.equals(thrown.message, message)) {
|
||||
pass.message = function() { return "Expected function not to throw " + name + " with message " + j$.pp(message) + "."; };
|
||||
pass.message = function() { return 'Expected function not to throw ' + name + ' with message ' + j$.pp(message) + '.'; };
|
||||
return pass;
|
||||
} else {
|
||||
fail.message = function() { return "Expected function to throw " + name + " with message " + j$.pp(message) +
|
||||
", but it threw " + constructorName + " with message " + j$.pp(thrown.message) + "."; };
|
||||
fail.message = function() { return 'Expected function to throw ' + name + ' with message ' + j$.pp(message) +
|
||||
', but it threw ' + constructorName + ' with message ' + j$.pp(thrown.message) + '.'; };
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorType && regexp) {
|
||||
if (thrown.constructor == errorType && regexp.test(thrown.message)) {
|
||||
pass.message = function() { return "Expected function not to throw " + name + " with message matching " + j$.pp(regexp) + "."; };
|
||||
pass.message = function() { return 'Expected function not to throw ' + name + ' with message matching ' + j$.pp(regexp) + '.'; };
|
||||
return pass;
|
||||
} else {
|
||||
fail.message = function() { return "Expected function to throw " + name + " with message matching " + j$.pp(regexp) +
|
||||
", but it threw " + constructorName + " with message " + j$.pp(thrown.message) + "."; };
|
||||
fail.message = function() { return 'Expected function to throw ' + name + ' with message matching ' + j$.pp(regexp) +
|
||||
', but it threw ' + constructorName + ' with message ' + j$.pp(thrown.message) + '.'; };
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (errorType) {
|
||||
if (thrown.constructor == errorType) {
|
||||
pass.message = "Expected function not to throw " + name + ".";
|
||||
pass.message = 'Expected function not to throw ' + name + '.';
|
||||
return pass;
|
||||
} else {
|
||||
fail.message = "Expected function to throw " + name + ", but it threw " + constructorName + ".";
|
||||
fail.message = 'Expected function to throw ' + name + ', but it threw ' + constructorName + '.';
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (message) {
|
||||
if (thrown.message == message) {
|
||||
pass.message = function() { return "Expected function not to throw an exception with message " + j$.pp(message) + "."; };
|
||||
pass.message = function() { return 'Expected function not to throw an exception with message ' + j$.pp(message) + '.'; };
|
||||
return pass;
|
||||
} else {
|
||||
fail.message = function() { return "Expected function to throw an exception with message " + j$.pp(message) +
|
||||
", but it threw an exception with message " + j$.pp(thrown.message) + "."; };
|
||||
fail.message = function() { return 'Expected function to throw an exception with message ' + j$.pp(message) +
|
||||
', but it threw an exception with message ' + j$.pp(thrown.message) + '.'; };
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (regexp) {
|
||||
if (regexp.test(thrown.message)) {
|
||||
pass.message = function() { return "Expected function not to throw an exception with a message matching " + j$.pp(regexp) + "."; };
|
||||
pass.message = function() { return 'Expected function not to throw an exception with a message matching ' + j$.pp(regexp) + '.'; };
|
||||
return pass;
|
||||
} else {
|
||||
fail.message = function() { return "Expected function to throw an exception with a message matching " + j$.pp(regexp) +
|
||||
", but it threw an exception with message " + j$.pp(thrown.message) + "."; };
|
||||
fail.message = function() { return 'Expected function to throw an exception with a message matching ' + j$.pp(regexp) +
|
||||
', but it threw an exception with message ' + j$.pp(thrown.message) + '.'; };
|
||||
return fail;
|
||||
}
|
||||
}
|
||||
@@ -113,34 +113,34 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
||||
|
||||
if (expected instanceof RegExp) {
|
||||
regexp = expected;
|
||||
} else if (typeof expected == "string") {
|
||||
} else if (typeof expected == 'string') {
|
||||
message = expected;
|
||||
} else if (checkForAnErrorType(expected)) {
|
||||
errorType = expected;
|
||||
}
|
||||
|
||||
if (!(errorType || message || regexp)) {
|
||||
throw new Error("Expected is not an Error, string, or RegExp.");
|
||||
throw new Error('Expected is not an Error, string, or RegExp.');
|
||||
}
|
||||
} else {
|
||||
if (checkForAnErrorType(arguments[1])) {
|
||||
errorType = arguments[1];
|
||||
} else {
|
||||
throw new Error("Expected error type is not an Error.");
|
||||
throw new Error('Expected error type is not an Error.');
|
||||
}
|
||||
|
||||
if (arguments[2] instanceof RegExp) {
|
||||
regexp = arguments[2];
|
||||
} else if (typeof arguments[2] == "string") {
|
||||
} else if (typeof arguments[2] == 'string') {
|
||||
message = arguments[2];
|
||||
} else {
|
||||
throw new Error("Expected error message is not a string or RegExp.");
|
||||
throw new Error('Expected error message is not a string or RegExp.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkForAnErrorType(type) {
|
||||
if (typeof type !== "function") {
|
||||
if (typeof type !== 'function') {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function getJasmineRequireObj() {
|
||||
if (typeof module !== "undefined" && module.exports) {
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
return exports;
|
||||
} else {
|
||||
window.jasmineRequire = window.jasmineRequire || {};
|
||||
|
||||
Reference in New Issue
Block a user