jasmine.undefined
instead of undefined
, since undefined
is just
@@ -20,44 +20,44 @@ jasmine.unimplementedMethod_ = function() {
*
* @private
*/
-jasmine.undefined = jasmine.___undefined___;
+jasmine.undefined = jasmine.___undefined___
/**
* Show diagnostic messages in the console if set to true
*
*/
-jasmine.VERBOSE = false;
+jasmine.VERBOSE = false
/**
* Default interval in milliseconds for event loop yields (e.g. to allow network activity or to refresh the screen with the HTML-based runner). 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
/**
* Maximum levels of nesting that will be included when an object is pretty-printed
*/
-jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
+jasmine.MAX_PRETTY_PRINT_DEPTH = 40
/**
* Default timeout interval in milliseconds for waitsFor() blocks.
*/
-jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;
+jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000
/**
* By default exceptions thrown in the context of a test are caught by jasmine so that it can run the remaining tests in the suite.
* Set to false to let the exception bubble up in the browser.
*
*/
-jasmine.CATCH_EXCEPTIONS = true;
+jasmine.CATCH_EXCEPTIONS = true
-jasmine.getGlobal = function() {
- function getGlobal() {
- return this;
+jasmine.getGlobal = function () {
+ function getGlobal () {
+ return this
}
- return getGlobal();
-};
+ return getGlobal()
+}
/**
* Allows for bound functions to be compared. Internal use only.
@@ -67,69 +67,69 @@ jasmine.getGlobal = function() {
* @param base {Object} bound 'this' for the function
* @param name {Function} function to find
*/
-jasmine.bindOriginal_ = function(base, name) {
- var original = base[name];
+jasmine.bindOriginal_ = function (base, name) {
+ var original = base[name]
if (original.apply) {
- return function() {
- return original.apply(base, arguments);
- };
+ return function () {
+ return original.apply(base, arguments)
+ }
} else {
// IE support
- return jasmine.getGlobal()[name];
+ return jasmine.getGlobal()[name]
}
-};
+}
-jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');
-jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout');
-jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval');
-jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval');
+jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout')
+jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout')
+jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval')
+jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval')
-jasmine.MessageResult = function(values) {
- this.type = 'log';
- this.values = values;
- this.trace = new Error(); // todo: test better
-};
+jasmine.MessageResult = function (values) {
+ this.type = 'log'
+ this.values = values
+ this.trace = new Error() // todo: test better
+}
-jasmine.MessageResult.prototype.toString = function() {
- var text = "";
+jasmine.MessageResult.prototype.toString = function () {
+ var text = ''
for (var i = 0; i < this.values.length; i++) {
- if (i > 0) text += " ";
+ if (i > 0) text += ' '
if (jasmine.isString_(this.values[i])) {
- text += this.values[i];
+ text += this.values[i]
} else {
- text += jasmine.pp(this.values[i]);
+ text += jasmine.pp(this.values[i])
}
}
- return text;
-};
+ return text
+}
-jasmine.ExpectationResult = function(params) {
- this.type = 'expect';
- this.matcherName = params.matcherName;
- this.passed_ = params.passed;
- this.expected = params.expected;
- this.actual = params.actual;
- this.message = this.passed_ ? 'Passed.' : params.message;
+jasmine.ExpectationResult = function (params) {
+ this.type = 'expect'
+ this.matcherName = params.matcherName
+ this.passed_ = params.passed
+ this.expected = params.expected
+ this.actual = params.actual
+ this.message = this.passed_ ? 'Passed.' : params.message
- var trace = (params.trace || new Error(this.message));
- this.trace = this.passed_ ? '' : trace;
-};
+ var trace = (params.trace || new Error(this.message))
+ this.trace = this.passed_ ? '' : trace
+}
jasmine.ExpectationResult.prototype.toString = function () {
- return this.message;
-};
+ return this.message
+}
jasmine.ExpectationResult.prototype.passed = function () {
- return this.passed_;
-};
+ return this.passed_
+}
/**
* Getter for the Jasmine environment. Ensures one gets created
*/
-jasmine.getEnv = function() {
- var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();
- return env;
-};
+jasmine.getEnv = function () {
+ var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env()
+ return env
+}
/**
* @ignore
@@ -137,9 +137,9 @@ jasmine.getEnv = function() {
* @param value
* @returns {Boolean}
*/
-jasmine.isArray_ = function(value) {
- return jasmine.isA_("Array", value);
-};
+jasmine.isArray_ = function (value) {
+ return jasmine.isA_('Array', value)
+}
/**
* @ignore
@@ -147,9 +147,9 @@ jasmine.isArray_ = function(value) {
* @param value
* @returns {Boolean}
*/
-jasmine.isString_ = function(value) {
- return jasmine.isA_("String", value);
-};
+jasmine.isString_ = function (value) {
+ return jasmine.isA_('String', value)
+}
/**
* @ignore
@@ -157,9 +157,9 @@ jasmine.isString_ = function(value) {
* @param value
* @returns {Boolean}
*/
-jasmine.isNumber_ = function(value) {
- return jasmine.isA_("Number", value);
-};
+jasmine.isNumber_ = function (value) {
+ return jasmine.isA_('Number', value)
+}
/**
* @ignore
@@ -168,9 +168,9 @@ jasmine.isNumber_ = function(value) {
* @param value
* @returns {Boolean}
*/
-jasmine.isA_ = function(typeName, value) {
- return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';
-};
+jasmine.isA_ = function (typeName, value) {
+ return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'
+}
/**
* Pretty printer for expecations. Takes any object and turns it into a human-readable string.
@@ -178,11 +178,11 @@ jasmine.isA_ = function(typeName, value) {
* @param value {Object} an object to be outputted
* @returns {String}
*/
-jasmine.pp = function(value) {
- var stringPrettyPrinter = new jasmine.StringPrettyPrinter();
- stringPrettyPrinter.format(value);
- return stringPrettyPrinter.string;
-};
+jasmine.pp = function (value) {
+ var stringPrettyPrinter = new jasmine.StringPrettyPrinter()
+ stringPrettyPrinter.format(value)
+ return stringPrettyPrinter.string
+}
/**
* Returns true if the object is a DOM Node.
@@ -190,9 +190,9 @@ jasmine.pp = function(value) {
* @param {Object} obj object to check
* @returns {Boolean}
*/
-jasmine.isDomNode = function(obj) {
- return obj.nodeType > 0;
-};
+jasmine.isDomNode = function (obj) {
+ return obj.nodeType > 0
+}
/**
* Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter.
@@ -204,9 +204,9 @@ jasmine.isDomNode = function(obj) {
* @param {Class} clazz
* @returns matchable object of the type clazz
*/
-jasmine.any = function(clazz) {
- return new jasmine.Matchers.Any(clazz);
-};
+jasmine.any = function (clazz) {
+ return new jasmine.Matchers.Any(clazz)
+}
/**
* Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the
@@ -220,8 +220,8 @@ jasmine.any = function(clazz) {
* @returns matchable object for the sample
*/
jasmine.objectContaining = function (sample) {
- return new jasmine.Matchers.ObjectContaining(sample);
-};
+ return new jasmine.Matchers.ObjectContaining(sample)
+}
/**
* Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.
@@ -267,20 +267,20 @@ jasmine.objectContaining = function (sample) {
* @see spyOn, jasmine.createSpy, jasmine.createSpyObj
* @param {String} name
*/
-jasmine.Spy = function(name) {
+jasmine.Spy = function (name) {
/**
* The name of the spy, if provided.
*/
- this.identity = name || 'unknown';
+ this.identity = name || 'unknown'
/**
* Is this Object a spy?
*/
- this.isSpy = true;
+ this.isSpy = true
/**
* The actual function this spy stubs.
*/
- this.plan = function() {
- };
+ this.plan = function () {
+ }
/**
* Tracking of the most recent call to the spy.
* @example
@@ -288,7 +288,7 @@ jasmine.Spy = function(name) {
* mySpy(1, 2);
* mySpy.mostRecentCall.args = [1, 2];
*/
- this.mostRecentCall = {};
+ this.mostRecentCall = {}
/**
* Holds arguments for each call to the spy, indexed by call count
@@ -300,9 +300,9 @@ jasmine.Spy = function(name) {
* mySpy.argsForCall[0] = [1, 2];
* mySpy.argsForCall[1] = [7, 8];
*/
- this.argsForCall = [];
- this.calls = [];
-};
+ this.argsForCall = []
+ this.calls = []
+}
/**
* Tells a spy to call through to the actual implemenatation.
@@ -315,10 +315,10 @@ jasmine.Spy = function(name) {
* // defining a spy on an existing property: foo.bar
* spyOn(foo, 'bar').andCallThrough();
*/
-jasmine.Spy.prototype.andCallThrough = function() {
- this.plan = this.originalValue;
- return this;
-};
+jasmine.Spy.prototype.andCallThrough = function () {
+ this.plan = this.originalValue
+ return this
+}
/**
* For setting the return value of a spy.
@@ -332,12 +332,12 @@ jasmine.Spy.prototype.andCallThrough = function() {
*
* @param {Object} value
*/
-jasmine.Spy.prototype.andReturn = function(value) {
- this.plan = function() {
- return value;
- };
- return this;
-};
+jasmine.Spy.prototype.andReturn = function (value) {
+ this.plan = function () {
+ return value
+ }
+ return this
+}
/**
* For throwing an exception when a spy is called.
@@ -351,12 +351,12 @@ jasmine.Spy.prototype.andReturn = function(value) {
*
* @param {String} exceptionMsg
*/
-jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
- this.plan = function() {
- throw exceptionMsg;
- };
- return this;
-};
+jasmine.Spy.prototype.andThrow = function (exceptionMsg) {
+ this.plan = function () {
+ throw exceptionMsg
+ }
+ return this
+}
/**
* Calls an alternate implementation when a spy is called.
@@ -373,10 +373,10 @@ jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
*
* @param {Function} fakeFunc
*/
-jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
- this.plan = fakeFunc;
- return this;
-};
+jasmine.Spy.prototype.andCallFake = function (fakeFunc) {
+ this.plan = fakeFunc
+ return this
+}
/**
* Resets all of a spy's the tracking variables so that it can be used again.
@@ -392,37 +392,36 @@ jasmine.Spy.prototype.andCallFake = function(fakeFunc) {
*
* expect(foo.bar.callCount).toEqual(0);
*/
-jasmine.Spy.prototype.reset = function() {
- this.wasCalled = false;
- this.callCount = 0;
- this.argsForCall = [];
- this.calls = [];
- this.mostRecentCall = {};
-};
+jasmine.Spy.prototype.reset = function () {
+ this.wasCalled = false
+ this.callCount = 0
+ this.argsForCall = []
+ this.calls = []
+ this.mostRecentCall = {}
+}
-jasmine.createSpy = function(name) {
-
- var spyObj = function() {
- spyObj.wasCalled = true;
- spyObj.callCount++;
- var args = jasmine.util.argsToArray(arguments);
- spyObj.mostRecentCall.object = this;
- spyObj.mostRecentCall.args = args;
- spyObj.argsForCall.push(args);
- spyObj.calls.push({object: this, args: args});
- return spyObj.plan.apply(this, arguments);
- };
+jasmine.createSpy = function (name) {
+ var spyObj = function () {
+ spyObj.wasCalled = true
+ spyObj.callCount++
+ var args = jasmine.util.argsToArray(arguments)
+ spyObj.mostRecentCall.object = this
+ spyObj.mostRecentCall.args = args
+ spyObj.argsForCall.push(args)
+ spyObj.calls.push({ object: this, args: args })
+ return spyObj.plan.apply(this, arguments)
+ }
- var spy = new jasmine.Spy(name);
+ var spy = new jasmine.Spy(name)
for (var prop in spy) {
- spyObj[prop] = spy[prop];
+ spyObj[prop] = spy[prop]
}
- spyObj.reset();
+ spyObj.reset()
- return spyObj;
-};
+ return spyObj
+}
/**
* Determines whether an object is a spy.
@@ -430,9 +429,9 @@ jasmine.createSpy = function(name) {
* @param {jasmine.Spy|Object} putativeSpy
* @returns {Boolean}
*/
-jasmine.isSpy = function(putativeSpy) {
- return putativeSpy && putativeSpy.isSpy;
-};
+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
@@ -441,26 +440,26 @@ jasmine.isSpy = function(putativeSpy) {
* @param {String} baseName name of spy class
* @param {Array} methodNames array of names of methods to make spies
*/
-jasmine.createSpyObj = function(baseName, methodNames) {
+jasmine.createSpyObj = function (baseName, methodNames) {
if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {
- throw new Error('createSpyObj requires a non-empty array of method names to create spies for');
+ throw new Error('createSpyObj requires a non-empty array of method names to create spies for')
}
- var obj = {};
+ var obj = {}
for (var i = 0; i < methodNames.length; i++) {
- obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
+ obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i])
}
- return obj;
-};
+ return obj
+}
/**
* All parameters are pretty-printed and concatenated together, then written to the current spec's output.
*
* Be careful not to leave calls to jasmine.log
in production code.
*/
-jasmine.log = function() {
- var spec = jasmine.getEnv().currentSpec;
- spec.log.apply(spec, arguments);
-};
+jasmine.log = function () {
+ var spec = jasmine.getEnv().currentSpec
+ spec.log.apply(spec, arguments)
+}
/**
* Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.
@@ -477,10 +476,10 @@ jasmine.log = function() {
* @param methodName
* @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods
*/
-var spyOn = function(obj, methodName) {
- return jasmine.getEnv().currentSpec.spyOn(obj, methodName);
-};
-if (isCommonJS) exports.spyOn = spyOn;
+var spyOn = function (obj, methodName) {
+ return jasmine.getEnv().currentSpec.spyOn(obj, methodName)
+}
+if (isCommonJS) exports.spyOn = spyOn
/**
* Creates a Jasmine spec that will be added to the current suite.
@@ -495,10 +494,10 @@ if (isCommonJS) exports.spyOn = spyOn;
* @param {String} desc description of this specification
* @param {Function} func defines the preconditions and expectations of the spec
*/
-var it = function(desc, func) {
- return jasmine.getEnv().it(desc, func);
-};
-if (isCommonJS) exports.it = it;
+var it = function (desc, func) {
+ return jasmine.getEnv().it(desc, func)
+}
+if (isCommonJS) exports.it = it
/**
* Creates a disabled Jasmine spec.
@@ -508,10 +507,10 @@ if (isCommonJS) exports.it = it;
* @param {String} desc description of this specification
* @param {Function} func defines the preconditions and expectations of the spec
*/
-var xit = function(desc, func) {
- return jasmine.getEnv().xit(desc, func);
-};
-if (isCommonJS) exports.xit = xit;
+var xit = function (desc, func) {
+ return jasmine.getEnv().xit(desc, func)
+}
+if (isCommonJS) exports.xit = xit
/**
* Starts a chain for a Jasmine expectation.
@@ -522,20 +521,20 @@ if (isCommonJS) exports.xit = xit;
* @param {Object} actual Actual value to test against and expected value
* @return {jasmine.Matchers}
*/
-var expect = function(actual) {
- return jasmine.getEnv().currentSpec.expect(actual);
-};
-if (isCommonJS) exports.expect = expect;
+var expect = function (actual) {
+ return jasmine.getEnv().currentSpec.expect(actual)
+}
+if (isCommonJS) exports.expect = expect
/**
* Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.
*
* @param {Function} func Function that defines part of a jasmine spec.
*/
-var runs = function(func) {
- jasmine.getEnv().currentSpec.runs(func);
-};
-if (isCommonJS) exports.runs = runs;
+var runs = function (func) {
+ jasmine.getEnv().currentSpec.runs(func)
+}
+if (isCommonJS) exports.runs = runs
/**
* Waits a fixed time period before moving to the next block.
@@ -543,10 +542,10 @@ if (isCommonJS) exports.runs = runs;
* @deprecated Use waitsFor() instead
* @param {Number} timeout milliseconds to wait
*/
-var waits = function(timeout) {
- jasmine.getEnv().currentSpec.waits(timeout);
-};
-if (isCommonJS) exports.waits = waits;
+var waits = function (timeout) {
+ jasmine.getEnv().currentSpec.waits(timeout)
+}
+if (isCommonJS) exports.waits = waits
/**
* Waits for the latchFunction to return true before proceeding to the next block.
@@ -555,10 +554,10 @@ if (isCommonJS) exports.waits = waits;
* @param {String} optional_timeoutMessage
* @param {Number} optional_timeout
*/
-var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
- jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);
-};
-if (isCommonJS) exports.waitsFor = waitsFor;
+var waitsFor = function (latchFunction, optional_timeoutMessage, optional_timeout) {
+ jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments)
+}
+if (isCommonJS) exports.waitsFor = waitsFor
/**
* A function that is called before each spec in a suite.
@@ -567,10 +566,10 @@ if (isCommonJS) exports.waitsFor = waitsFor;
*
* @param {Function} beforeEachFunction
*/
-var beforeEach = function(beforeEachFunction) {
- jasmine.getEnv().beforeEach(beforeEachFunction);
-};
-if (isCommonJS) exports.beforeEach = beforeEach;
+var beforeEach = function (beforeEachFunction) {
+ jasmine.getEnv().beforeEach(beforeEachFunction)
+}
+if (isCommonJS) exports.beforeEach = beforeEach
/**
* A function that is called after each spec in a suite.
@@ -579,10 +578,10 @@ if (isCommonJS) exports.beforeEach = beforeEach;
*
* @param {Function} afterEachFunction
*/
-var afterEach = function(afterEachFunction) {
- jasmine.getEnv().afterEach(afterEachFunction);
-};
-if (isCommonJS) exports.afterEach = afterEach;
+var afterEach = function (afterEachFunction) {
+ jasmine.getEnv().afterEach(afterEachFunction)
+}
+if (isCommonJS) exports.afterEach = afterEach
/**
* Defines a suite of specifications.
@@ -599,10 +598,10 @@ if (isCommonJS) exports.afterEach = afterEach;
* @param {String} description A string, usually the class under test.
* @param {Function} specDefinitions function that defines several specs.
*/
-var describe = function(description, specDefinitions) {
- return jasmine.getEnv().describe(description, specDefinitions);
-};
-if (isCommonJS) exports.describe = describe;
+var describe = function (description, specDefinitions) {
+ return jasmine.getEnv().describe(description, specDefinitions)
+}
+if (isCommonJS) exports.describe = describe
/**
* Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
@@ -610,43 +609,42 @@ if (isCommonJS) exports.describe = describe;
* @param {String} description A string, usually the class under test.
* @param {Function} specDefinitions function that defines several specs.
*/
-var xdescribe = function(description, specDefinitions) {
- return jasmine.getEnv().xdescribe(description, specDefinitions);
-};
-if (isCommonJS) exports.xdescribe = xdescribe;
-
+var xdescribe = function (description, specDefinitions) {
+ return jasmine.getEnv().xdescribe(description, specDefinitions)
+}
+if (isCommonJS) exports.xdescribe = xdescribe
// Provide the XMLHttpRequest class for IE 5.x-6.x:
-jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
- function tryIt(f) {
+jasmine.XmlHttpRequest = (typeof XMLHttpRequest === 'undefined') ? function () {
+ function tryIt (f) {
try {
- return f();
- } catch(e) {
+ return f()
+ } catch (e) {
}
- return null;
+ return null
}
- var xhr = tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP.6.0");
+ var xhr = tryIt(function () {
+ return new ActiveXObject('Msxml2.XMLHTTP.6.0')
}) ||
- tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP.3.0");
+ tryIt(function () {
+ return new ActiveXObject('Msxml2.XMLHTTP.3.0')
}) ||
- tryIt(function() {
- return new ActiveXObject("Msxml2.XMLHTTP");
+ tryIt(function () {
+ return new ActiveXObject('Msxml2.XMLHTTP')
}) ||
- tryIt(function() {
- return new ActiveXObject("Microsoft.XMLHTTP");
- });
+ tryIt(function () {
+ return new ActiveXObject('Microsoft.XMLHTTP')
+ })
- if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
+ if (!xhr) throw new Error('This browser does not support XMLHttpRequest.')
- return xhr;
-} : XMLHttpRequest;
+ return xhr
+} : XMLHttpRequest
/**
* @namespace
*/
-jasmine.util = {};
+jasmine.util = {}
/**
* Declare that a child class inherit it's prototype from the parent class.
@@ -655,391 +653,382 @@ jasmine.util = {};
* @param {Function} childClass
* @param {Function} parentClass
*/
-jasmine.util.inherit = function(childClass, parentClass) {
+jasmine.util.inherit = function (childClass, parentClass) {
/**
* @private
*/
- var subclass = function() {
- };
- subclass.prototype = parentClass.prototype;
- childClass.prototype = new subclass();
-};
+ var subclass = function () {
+ }
+ subclass.prototype = parentClass.prototype
+ childClass.prototype = new subclass()
+}
-jasmine.util.formatException = function(e) {
- var lineNumber;
+jasmine.util.formatException = function (e) {
+ var lineNumber
if (e.line) {
- lineNumber = e.line;
- }
- else if (e.lineNumber) {
- lineNumber = e.lineNumber;
+ lineNumber = e.line
+ } else if (e.lineNumber) {
+ lineNumber = e.lineNumber
}
- var file;
+ var file
if (e.sourceURL) {
- file = e.sourceURL;
- }
- else if (e.fileName) {
- file = e.fileName;
+ file = e.sourceURL
+ } else if (e.fileName) {
+ file = e.fileName
}
- var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
+ var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString()
if (file && lineNumber) {
- message += ' in ' + file + ' (line ' + lineNumber + ')';
+ message += ' in ' + file + ' (line ' + lineNumber + ')'
}
- return message;
-};
+ return message
+}
-jasmine.util.htmlEscape = function(str) {
- if (!str) return str;
+jasmine.util.htmlEscape = function (str) {
+ if (!str) return str
return str.replace(/&/g, '&')
.replace(//g, '>');
-};
+ .replace(/>/g, '>')
+}
-jasmine.util.argsToArray = function(args) {
- var arrayOfArgs = [];
- for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);
- return arrayOfArgs;
-};
+jasmine.util.argsToArray = function (args) {
+ var arrayOfArgs = []
+ for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i])
+ return arrayOfArgs
+}
-jasmine.util.extend = function(destination, source) {
- for (var property in source) destination[property] = source[property];
- return destination;
-};
+jasmine.util.extend = function (destination, source) {
+ for (var property in source) destination[property] = source[property]
+ return destination
+}
/**
* Environment for Jasmine
*
* @constructor
*/
-jasmine.Env = function() {
- this.currentSpec = null;
- this.currentSuite = null;
- this.currentRunner_ = new jasmine.Runner(this);
+jasmine.Env = function () {
+ this.currentSpec = null
+ this.currentSuite = null
+ this.currentRunner_ = new jasmine.Runner(this)
- this.reporter = new jasmine.MultiReporter();
+ this.reporter = new jasmine.MultiReporter()
- this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;
- this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;
- this.lastUpdate = 0;
- this.specFilter = function() {
- return true;
- };
+ this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL
+ this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL
+ this.lastUpdate = 0
+ this.specFilter = function () {
+ return true
+ }
- this.nextSpecId_ = 0;
- this.nextSuiteId_ = 0;
- this.equalityTesters_ = [];
+ this.nextSpecId_ = 0
+ this.nextSuiteId_ = 0
+ this.equalityTesters_ = []
// wrap matchers
- this.matchersClass = function() {
- jasmine.Matchers.apply(this, arguments);
- };
- jasmine.util.inherit(this.matchersClass, jasmine.Matchers);
-
- jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);
-};
+ this.matchersClass = function () {
+ jasmine.Matchers.apply(this, arguments)
+ }
+ jasmine.util.inherit(this.matchersClass, jasmine.Matchers)
+ jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass)
+}
-jasmine.Env.prototype.setTimeout = jasmine.setTimeout;
-jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;
-jasmine.Env.prototype.setInterval = jasmine.setInterval;
-jasmine.Env.prototype.clearInterval = jasmine.clearInterval;
+jasmine.Env.prototype.setTimeout = jasmine.setTimeout
+jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout
+jasmine.Env.prototype.setInterval = jasmine.setInterval
+jasmine.Env.prototype.clearInterval = jasmine.clearInterval
/**
* @returns an object containing jasmine version build info, if set.
*/
jasmine.Env.prototype.version = function () {
if (jasmine.version_) {
- return jasmine.version_;
+ return jasmine.version_
} else {
- throw new Error('Version not set');
+ throw new Error('Version not set')
}
-};
+}
/**
* @returns string containing jasmine version build info, if set.
*/
-jasmine.Env.prototype.versionString = function() {
+jasmine.Env.prototype.versionString = function () {
if (!jasmine.version_) {
- return "version unknown";
+ return 'version unknown'
}
- var version = this.version();
- var versionString = version.major + "." + version.minor + "." + version.build;
+ var version = this.version()
+ var versionString = version.major + '.' + version.minor + '.' + version.build
if (version.release_candidate) {
- versionString += ".rc" + version.release_candidate;
+ versionString += '.rc' + version.release_candidate
}
- versionString += " revision " + version.revision;
- return versionString;
-};
+ versionString += ' revision ' + version.revision
+ return versionString
+}
/**
* @returns a sequential integer starting at 0
*/
jasmine.Env.prototype.nextSpecId = function () {
- return this.nextSpecId_++;
-};
+ return this.nextSpecId_++
+}
/**
* @returns a sequential integer starting at 0
*/
jasmine.Env.prototype.nextSuiteId = function () {
- return this.nextSuiteId_++;
-};
+ return this.nextSuiteId_++
+}
/**
* Register a reporter to receive status updates from Jasmine.
* @param {jasmine.Reporter} reporter An object which will receive status updates.
*/
-jasmine.Env.prototype.addReporter = function(reporter) {
- this.reporter.addReporter(reporter);
-};
+jasmine.Env.prototype.addReporter = function (reporter) {
+ this.reporter.addReporter(reporter)
+}
-jasmine.Env.prototype.execute = function() {
- this.currentRunner_.execute();
-};
+jasmine.Env.prototype.execute = function () {
+ this.currentRunner_.execute()
+}
-jasmine.Env.prototype.describe = function(description, specDefinitions) {
- var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
+jasmine.Env.prototype.describe = function (description, specDefinitions) {
+ var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite)
- var parentSuite = this.currentSuite;
+ var parentSuite = this.currentSuite
if (parentSuite) {
- parentSuite.add(suite);
+ parentSuite.add(suite)
} else {
- this.currentRunner_.add(suite);
+ this.currentRunner_.add(suite)
}
- this.currentSuite = suite;
+ this.currentSuite = suite
- var declarationError = null;
+ var declarationError = null
try {
- specDefinitions.call(suite);
- } catch(e) {
- declarationError = e;
+ specDefinitions.call(suite)
+ } catch (e) {
+ declarationError = e
}
if (declarationError) {
- this.it("encountered a declaration exception", function() {
- throw declarationError;
- });
+ this.it('encountered a declaration exception', function () {
+ throw declarationError
+ })
}
- this.currentSuite = parentSuite;
+ this.currentSuite = parentSuite
- return suite;
-};
+ return suite
+}
-jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
+jasmine.Env.prototype.beforeEach = function (beforeEachFunction) {
if (this.currentSuite) {
- this.currentSuite.beforeEach(beforeEachFunction);
+ this.currentSuite.beforeEach(beforeEachFunction)
} else {
- this.currentRunner_.beforeEach(beforeEachFunction);
+ this.currentRunner_.beforeEach(beforeEachFunction)
}
-};
+}
jasmine.Env.prototype.currentRunner = function () {
- return this.currentRunner_;
-};
+ return this.currentRunner_
+}
-jasmine.Env.prototype.afterEach = function(afterEachFunction) {
+jasmine.Env.prototype.afterEach = function (afterEachFunction) {
if (this.currentSuite) {
- this.currentSuite.afterEach(afterEachFunction);
+ this.currentSuite.afterEach(afterEachFunction)
} else {
- this.currentRunner_.afterEach(afterEachFunction);
+ this.currentRunner_.afterEach(afterEachFunction)
}
+}
-};
-
-jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
+jasmine.Env.prototype.xdescribe = function (desc, specDefinitions) {
return {
- execute: function() {
+ execute: function () {
}
- };
-};
+ }
+}
-jasmine.Env.prototype.it = function(description, func) {
- var spec = new jasmine.Spec(this, this.currentSuite, description);
- this.currentSuite.add(spec);
- this.currentSpec = spec;
+jasmine.Env.prototype.it = function (description, func) {
+ var spec = new jasmine.Spec(this, this.currentSuite, description)
+ this.currentSuite.add(spec)
+ this.currentSpec = spec
if (func) {
- spec.runs(func);
+ spec.runs(func)
}
- return spec;
-};
+ return spec
+}
-jasmine.Env.prototype.xit = function(desc, func) {
+jasmine.Env.prototype.xit = function (desc, func) {
return {
id: this.nextSpecId(),
- runs: function() {
+ runs: function () {
}
- };
-};
+ }
+}
-jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {
- if (a.source != b.source)
- mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");
+jasmine.Env.prototype.compareRegExps_ = function (a, b, mismatchKeys, mismatchValues) {
+ if (a.source != b.source) { mismatchValues.push('expected pattern /' + b.source + '/ is not equal to the pattern /' + a.source + '/') }
- if (a.ignoreCase != b.ignoreCase)
- mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.ignoreCase != b.ignoreCase) { mismatchValues.push('expected modifier i was' + (b.ignoreCase ? ' ' : ' not ') + 'set and does not equal the origin modifier') }
- if (a.global != b.global)
- mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.global != b.global) { mismatchValues.push('expected modifier g was' + (b.global ? ' ' : ' not ') + 'set and does not equal the origin modifier') }
- if (a.multiline != b.multiline)
- mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.multiline != b.multiline) { mismatchValues.push('expected modifier m was' + (b.multiline ? ' ' : ' not ') + 'set and does not equal the origin modifier') }
- if (a.sticky != b.sticky)
- mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");
+ if (a.sticky != b.sticky) { mismatchValues.push('expected modifier y was' + (b.sticky ? ' ' : ' not ') + 'set and does not equal the origin modifier') }
- return (mismatchValues.length === 0);
-};
+ return (mismatchValues.length === 0)
+}
-jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
+jasmine.Env.prototype.compareObjects_ = function (a, b, mismatchKeys, mismatchValues) {
if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
- return true;
+ return true
}
- a.__Jasmine_been_here_before__ = b;
- b.__Jasmine_been_here_before__ = a;
+ a.__Jasmine_been_here_before__ = b
+ b.__Jasmine_been_here_before__ = a
- var hasKey = function(obj, keyName) {
- return obj !== null && obj[keyName] !== jasmine.undefined;
- };
+ var hasKey = function (obj, keyName) {
+ return obj !== null && obj[keyName] !== jasmine.undefined
+ }
for (var property in b) {
if (!hasKey(a, property) && hasKey(b, property)) {
- mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.")
}
}
for (property in a) {
if (!hasKey(b, property) && hasKey(a, property)) {
- mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
+ mismatchKeys.push("expected missing key '" + property + "', but present in actual.")
}
}
for (property in b) {
- if (property == '__Jasmine_been_here_before__') continue;
+ if (property == '__Jasmine_been_here_before__') continue
if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {
- mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.");
+ mismatchValues.push("'" + property + "' was '" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "' in expected, but was '" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "' in actual.")
}
}
if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {
- mismatchValues.push("arrays were not the same length");
+ mismatchValues.push('arrays were not the same length')
}
- delete a.__Jasmine_been_here_before__;
- delete b.__Jasmine_been_here_before__;
- return (mismatchKeys.length === 0 && mismatchValues.length === 0);
-};
+ delete a.__Jasmine_been_here_before__
+ delete b.__Jasmine_been_here_before__
+ return (mismatchKeys.length === 0 && mismatchValues.length === 0)
+}
-jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {
- mismatchKeys = mismatchKeys || [];
- mismatchValues = mismatchValues || [];
+jasmine.Env.prototype.equals_ = function (a, b, mismatchKeys, mismatchValues) {
+ mismatchKeys = mismatchKeys || []
+ mismatchValues = mismatchValues || []
for (var i = 0; i < this.equalityTesters_.length; i++) {
- var equalityTester = this.equalityTesters_[i];
- var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);
- if (result !== jasmine.undefined) return result;
+ var equalityTester = this.equalityTesters_[i]
+ var result = equalityTester(a, b, this, mismatchKeys, mismatchValues)
+ if (result !== jasmine.undefined) return result
}
- if (a === b) return true;
+ if (a === b) return true
if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
- return (a == jasmine.undefined && b == jasmine.undefined);
+ return (a == jasmine.undefined && b == jasmine.undefined)
}
if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
- return a === b;
+ return a === b
}
if (a instanceof Date && b instanceof Date) {
- return a.getTime() == b.getTime();
+ return a.getTime() == b.getTime()
}
if (a.jasmineMatches) {
- return a.jasmineMatches(b);
+ return a.jasmineMatches(b)
}
if (b.jasmineMatches) {
- return b.jasmineMatches(a);
+ return b.jasmineMatches(a)
}
if (a instanceof jasmine.Matchers.ObjectContaining) {
- return a.matches(b);
+ return a.matches(b)
}
if (b instanceof jasmine.Matchers.ObjectContaining) {
- return b.matches(a);
+ return b.matches(a)
}
if (jasmine.isString_(a) && jasmine.isString_(b)) {
- return (a == b);
+ return (a == b)
}
if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
- return (a == b);
+ return (a == b)
}
if (a instanceof RegExp && b instanceof RegExp) {
- return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
+ return this.compareRegExps_(a, b, mismatchKeys, mismatchValues)
}
- if (typeof a === "object" && typeof b === "object") {
- return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
+ if (typeof a === 'object' && typeof b === 'object') {
+ return this.compareObjects_(a, b, mismatchKeys, mismatchValues)
}
- //Straight check
- return (a === b);
-};
+ // Straight check
+ return (a === b)
+}
-jasmine.Env.prototype.contains_ = function(haystack, needle) {
+jasmine.Env.prototype.contains_ = function (haystack, needle) {
if (jasmine.isArray_(haystack)) {
for (var i = 0; i < haystack.length; i++) {
- if (this.equals_(haystack[i], needle)) return true;
+ if (this.equals_(haystack[i], needle)) return true
}
- return false;
+ return false
}
- return haystack.indexOf(needle) >= 0;
-};
+ return haystack.indexOf(needle) >= 0
+}
-jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
- this.equalityTesters_.push(equalityTester);
-};
+jasmine.Env.prototype.addEqualityTester = function (equalityTester) {
+ this.equalityTesters_.push(equalityTester)
+}
/** No-op base class for Jasmine reporters.
*
* @constructor
*/
-jasmine.Reporter = function() {
-};
+jasmine.Reporter = function () {
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportRunnerStarting = function (runner) {
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportRunnerResults = function (runner) {
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSuiteResults = function (suite) {
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSpecStarting = function (spec) {
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.reportSpecResults = function(spec) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSpecResults = function (spec) {
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.Reporter.prototype.log = function(str) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.log = function (str) {
+}
/**
* Blocks are functions with executable code that make up a spec.
@@ -1049,110 +1038,109 @@ jasmine.Reporter.prototype.log = function(str) {
* @param {Function} func
* @param {jasmine.Spec} spec
*/
-jasmine.Block = function(env, func, spec) {
- this.env = env;
- this.func = func;
- this.spec = spec;
-};
+jasmine.Block = function (env, func, spec) {
+ this.env = env
+ this.func = func
+ this.spec = spec
+}
-jasmine.Block.prototype.execute = function(onComplete) {
+jasmine.Block.prototype.execute = function (onComplete) {
if (!jasmine.CATCH_EXCEPTIONS) {
- this.func.apply(this.spec);
- }
- else {
+ this.func.apply(this.spec)
+ } else {
try {
- this.func.apply(this.spec);
+ this.func.apply(this.spec)
} catch (e) {
- this.spec.fail(e);
+ this.spec.fail(e)
}
}
- onComplete();
-};
+ onComplete()
+}
/** JavaScript API reporter.
*
* @constructor
*/
-jasmine.JsApiReporter = function() {
- this.started = false;
- this.finished = false;
- this.suites_ = [];
- this.results_ = {};
-};
+jasmine.JsApiReporter = function () {
+ this.started = false
+ this.finished = false
+ this.suites_ = []
+ this.results_ = {}
+}
-jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {
- this.started = true;
- var suites = runner.topLevelSuites();
+jasmine.JsApiReporter.prototype.reportRunnerStarting = function (runner) {
+ this.started = true
+ var suites = runner.topLevelSuites()
for (var i = 0; i < suites.length; i++) {
- var suite = suites[i];
- this.suites_.push(this.summarize_(suite));
+ var suite = suites[i]
+ this.suites_.push(this.summarize_(suite))
}
-};
+}
-jasmine.JsApiReporter.prototype.suites = function() {
- return this.suites_;
-};
+jasmine.JsApiReporter.prototype.suites = function () {
+ return this.suites_
+}
-jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
- var isSuite = suiteOrSpec instanceof jasmine.Suite;
+jasmine.JsApiReporter.prototype.summarize_ = function (suiteOrSpec) {
+ var isSuite = suiteOrSpec instanceof jasmine.Suite
var summary = {
id: suiteOrSpec.id,
name: suiteOrSpec.description,
type: isSuite ? 'suite' : 'spec',
children: []
- };
-
+ }
+
if (isSuite) {
- var children = suiteOrSpec.children();
+ var children = suiteOrSpec.children()
for (var i = 0; i < children.length; i++) {
- summary.children.push(this.summarize_(children[i]));
+ summary.children.push(this.summarize_(children[i]))
}
}
- return summary;
-};
+ return summary
+}
-jasmine.JsApiReporter.prototype.results = function() {
- return this.results_;
-};
+jasmine.JsApiReporter.prototype.results = function () {
+ return this.results_
+}
-jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {
- return this.results_[specId];
-};
+jasmine.JsApiReporter.prototype.resultsForSpec = function (specId) {
+ return this.results_[specId]
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {
- this.finished = true;
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.reportRunnerResults = function (runner) {
+ this.finished = true
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.reportSuiteResults = function (suite) {
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
+// noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.reportSpecResults = function (spec) {
this.results_[spec.id] = {
messages: spec.results().getItems(),
- result: spec.results().failedCount > 0 ? "failed" : "passed"
- };
-};
+ result: spec.results().failedCount > 0 ? 'failed' : 'passed'
+ }
+}
-//noinspection JSUnusedLocalSymbols
-jasmine.JsApiReporter.prototype.log = function(str) {
-};
+// noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.log = function (str) {
+}
-jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){
- var results = {};
+jasmine.JsApiReporter.prototype.resultsForSpecs = function (specIds) {
+ var results = {}
for (var i = 0; i < specIds.length; i++) {
- var specId = specIds[i];
- results[specId] = this.summarizeResult_(this.results_[specId]);
+ var specId = specIds[i]
+ results[specId] = this.summarizeResult_(this.results_[specId])
}
- return results;
-};
+ return results
+}
-jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
- var summaryMessages = [];
- var messagesLength = result.messages.length;
+jasmine.JsApiReporter.prototype.summarizeResult_ = function (result) {
+ var summaryMessages = []
+ var messagesLength = result.messages.length
for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {
- var resultMessage = result.messages[messageIndex];
+ var resultMessage = result.messages[messageIndex]
summaryMessages.push({
text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
passed: resultMessage.passed ? resultMessage.passed() : true,
@@ -1161,14 +1149,14 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
trace: {
stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
}
- });
+ })
}
return {
- result : result.result,
- messages : summaryMessages
- };
-};
+ result: result.result,
+ messages: summaryMessages
+ }
+}
/**
* @constructor
@@ -1176,60 +1164,60 @@ jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){
* @param actual
* @param {jasmine.Spec} spec
*/
-jasmine.Matchers = function(env, actual, spec, opt_isNot) {
- this.env = env;
- this.actual = actual;
- this.spec = spec;
- this.isNot = opt_isNot || false;
- this.reportWasCalled_ = false;
-};
+jasmine.Matchers = function (env, actual, spec, opt_isNot) {
+ this.env = env
+ this.actual = actual
+ this.spec = spec
+ this.isNot = opt_isNot || false
+ this.reportWasCalled_ = false
+}
// todo: @deprecated as of Jasmine 0.11, remove soon [xw]
-jasmine.Matchers.pp = function(str) {
- throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");
-};
+jasmine.Matchers.pp = function (str) {
+ throw new Error('jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!')
+}
// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]
-jasmine.Matchers.prototype.report = function(result, failing_message, details) {
- throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");
-};
+jasmine.Matchers.prototype.report = function (result, failing_message, details) {
+ throw new Error('As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs')
+}
-jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {
+jasmine.Matchers.wrapInto_ = function (prototype, matchersClass) {
for (var methodName in prototype) {
- if (methodName == 'report') continue;
- var orig = prototype[methodName];
- matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);
+ if (methodName == 'report') continue
+ var orig = prototype[methodName]
+ matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig)
}
-};
+}
-jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
- return function() {
- var matcherArgs = jasmine.util.argsToArray(arguments);
- var result = matcherFunction.apply(this, arguments);
+jasmine.Matchers.matcherFn_ = function (matcherName, matcherFunction) {
+ return function () {
+ var matcherArgs = jasmine.util.argsToArray(arguments)
+ var result = matcherFunction.apply(this, arguments)
if (this.isNot) {
- result = !result;
+ result = !result
}
- if (this.reportWasCalled_) return result;
+ if (this.reportWasCalled_) return result
- var message;
+ var message
if (!result) {
if (this.message) {
- message = this.message.apply(this, arguments);
+ message = this.message.apply(this, arguments)
if (jasmine.isArray_(message)) {
- message = message[this.isNot ? 1 : 0];
+ message = message[this.isNot ? 1 : 0]
}
} else {
- var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });
- message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;
+ var englishyPredicate = matcherName.replace(/[A-Z]/g, function (s) { return ' ' + s.toLowerCase() })
+ message = 'Expected ' + jasmine.pp(this.actual) + (this.isNot ? ' not ' : ' ') + englishyPredicate
if (matcherArgs.length > 0) {
for (var i = 0; i < matcherArgs.length; i++) {
- if (i > 0) message += ",";
- message += " " + jasmine.pp(matcherArgs[i]);
+ if (i > 0) message += ','
+ message += ' ' + jasmine.pp(matcherArgs[i])
}
}
- message += ".";
+ message += '.'
}
}
var expectationResult = new jasmine.ExpectationResult({
@@ -1238,49 +1226,46 @@ jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {
expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
actual: this.actual,
message: message
- });
- this.spec.addMatcherResult(expectationResult);
- return jasmine.undefined;
- };
-};
-
-
-
+ })
+ this.spec.addMatcherResult(expectationResult)
+ return jasmine.undefined
+ }
+}
/**
* toBe: compares the actual to the expected using ===
* @param expected
*/
-jasmine.Matchers.prototype.toBe = function(expected) {
- return this.actual === expected;
-};
+jasmine.Matchers.prototype.toBe = function (expected) {
+ return this.actual === expected
+}
/**
* toNotBe: compares the actual to the expected using !==
* @param expected
* @deprecated as of 1.0. Use not.toBe() instead.
*/
-jasmine.Matchers.prototype.toNotBe = function(expected) {
- return this.actual !== expected;
-};
+jasmine.Matchers.prototype.toNotBe = function (expected) {
+ return this.actual !== expected
+}
/**
* toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.
*
* @param expected
*/
-jasmine.Matchers.prototype.toEqual = function(expected) {
- return this.env.equals_(this.actual, expected);
-};
+jasmine.Matchers.prototype.toEqual = function (expected) {
+ return this.env.equals_(this.actual, expected)
+}
/**
* toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual
* @param expected
* @deprecated as of 1.0. Use not.toEqual() instead.
*/
-jasmine.Matchers.prototype.toNotEqual = function(expected) {
- return !this.env.equals_(this.actual, expected);
-};
+jasmine.Matchers.prototype.toNotEqual = function (expected) {
+ return !this.env.equals_(this.actual, expected)
+}
/**
* Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
@@ -1288,115 +1273,113 @@ jasmine.Matchers.prototype.toNotEqual = function(expected) {
*
* @param expected
*/
-jasmine.Matchers.prototype.toMatch = function(expected) {
- return new RegExp(expected).test(this.actual);
-};
+jasmine.Matchers.prototype.toMatch = function (expected) {
+ return new RegExp(expected).test(this.actual)
+}
/**
* Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch
* @param expected
* @deprecated as of 1.0. Use not.toMatch() instead.
*/
-jasmine.Matchers.prototype.toNotMatch = function(expected) {
- return !(new RegExp(expected).test(this.actual));
-};
+jasmine.Matchers.prototype.toNotMatch = function (expected) {
+ return !(new RegExp(expected).test(this.actual))
+}
/**
* Matcher that compares the actual to jasmine.undefined.
*/
-jasmine.Matchers.prototype.toBeDefined = function() {
- return (this.actual !== jasmine.undefined);
-};
+jasmine.Matchers.prototype.toBeDefined = function () {
+ return (this.actual !== jasmine.undefined)
+}
/**
* Matcher that compares the actual to jasmine.undefined.
*/
-jasmine.Matchers.prototype.toBeUndefined = function() {
- return (this.actual === jasmine.undefined);
-};
+jasmine.Matchers.prototype.toBeUndefined = function () {
+ return (this.actual === jasmine.undefined)
+}
/**
* Matcher that compares the actual to null.
*/
-jasmine.Matchers.prototype.toBeNull = function() {
- return (this.actual === null);
-};
+jasmine.Matchers.prototype.toBeNull = function () {
+ return (this.actual === null)
+}
/**
* Matcher that compares the actual to NaN.
*/
-jasmine.Matchers.prototype.toBeNaN = function() {
- this.message = function() {
- return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];
- };
+jasmine.Matchers.prototype.toBeNaN = function () {
+ this.message = function () {
+ return ['Expected ' + jasmine.pp(this.actual) + ' to be NaN.']
+ }
- return (this.actual !== this.actual);
-};
+ return (this.actual !== this.actual)
+}
/**
* Matcher that boolean not-nots the actual.
*/
-jasmine.Matchers.prototype.toBeTruthy = function() {
- return !!this.actual;
-};
-
+jasmine.Matchers.prototype.toBeTruthy = function () {
+ return !!this.actual
+}
/**
* Matcher that boolean nots the actual.
*/
-jasmine.Matchers.prototype.toBeFalsy = function() {
- return !this.actual;
-};
-
+jasmine.Matchers.prototype.toBeFalsy = function () {
+ return !this.actual
+}
/**
* Matcher that checks to see if the actual, a Jasmine spy, was called.
*/
-jasmine.Matchers.prototype.toHaveBeenCalled = function() {
+jasmine.Matchers.prototype.toHaveBeenCalled = function () {
if (arguments.length > 0) {
- throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');
+ throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith')
}
if (!jasmine.isSpy(this.actual)) {
- throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.')
}
- this.message = function() {
+ this.message = function () {
return [
- "Expected spy " + this.actual.identity + " to have been called.",
- "Expected spy " + this.actual.identity + " not to have been called."
- ];
- };
+ 'Expected spy ' + this.actual.identity + ' to have been called.',
+ 'Expected spy ' + this.actual.identity + ' not to have been called.'
+ ]
+ }
- return this.actual.wasCalled;
-};
+ return this.actual.wasCalled
+}
/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
-jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled;
+jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled
/**
* 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() {
+jasmine.Matchers.prototype.wasNotCalled = function () {
if (arguments.length > 0) {
- throw new Error('wasNotCalled does not take arguments');
+ throw new Error('wasNotCalled does not take arguments')
}
if (!jasmine.isSpy(this.actual)) {
- throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.')
}
- this.message = function() {
+ this.message = function () {
return [
- "Expected spy " + this.actual.identity + " to not have been called.",
- "Expected spy " + this.actual.identity + " to have been called."
- ];
- };
+ 'Expected spy ' + this.actual.identity + ' to not have been called.',
+ 'Expected spy ' + this.actual.identity + ' to have been called.'
+ ]
+ }
- return !this.actual.wasCalled;
-};
+ return !this.actual.wasCalled
+}
/**
* Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
@@ -1404,53 +1387,53 @@ jasmine.Matchers.prototype.wasNotCalled = function() {
* @example
*
*/
-jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {
- var expectedArgs = jasmine.util.argsToArray(arguments);
+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) + '.');
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.')
}
- this.message = function() {
- var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";
- var positiveMessage = "";
+ this.message = function () {
+ var invertedMessage = 'Expected spy ' + this.actual.identity + ' not to have been called with ' + jasmine.pp(expectedArgs) + ' but it was.'
+ var positiveMessage = ''
if (this.actual.callCount === 0) {
- positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";
+ positiveMessage = 'Expected spy ' + this.actual.identity + ' to have been called with ' + jasmine.pp(expectedArgs) + ' but it was never called.'
} else {
- positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but actual calls were " + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
+ positiveMessage = 'Expected spy ' + this.actual.identity + ' to have been called with ' + jasmine.pp(expectedArgs) + ' but actual calls were ' + jasmine.pp(this.actual.argsForCall).replace(/^\[ | \]$/g, '')
}
- return [positiveMessage, invertedMessage];
- };
+ return [positiveMessage, invertedMessage]
+ }
- return this.env.contains_(this.actual.argsForCall, expectedArgs);
-};
+ return this.env.contains_(this.actual.argsForCall, expectedArgs)
+}
/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
-jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith;
+jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith
/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */
-jasmine.Matchers.prototype.wasNotCalledWith = function() {
- var expectedArgs = jasmine.util.argsToArray(arguments);
+jasmine.Matchers.prototype.wasNotCalledWith = function () {
+ var expectedArgs = jasmine.util.argsToArray(arguments)
if (!jasmine.isSpy(this.actual)) {
- throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.')
}
- this.message = function() {
+ this.message = function () {
return [
- "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",
- "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"
- ];
- };
+ 'Expected spy not to have been called with ' + jasmine.pp(expectedArgs) + ' but it was',
+ 'Expected spy to have been called with ' + jasmine.pp(expectedArgs) + ' but it was'
+ ]
+ }
- return !this.env.contains_(this.actual.argsForCall, expectedArgs);
-};
+ return !this.env.contains_(this.actual.argsForCall, expectedArgs)
+}
/**
* Matcher that checks that the expected item is an element in the actual Array.
*
* @param {Object} expected
*/
-jasmine.Matchers.prototype.toContain = function(expected) {
- return this.env.contains_(this.actual, expected);
-};
+jasmine.Matchers.prototype.toContain = function (expected) {
+ return this.env.contains_(this.actual, expected)
+}
/**
* Matcher that checks that the expected item is NOT an element in the actual Array.
@@ -1458,17 +1441,17 @@ jasmine.Matchers.prototype.toContain = function(expected) {
* @param {Object} expected
* @deprecated as of 1.0. Use not.toContain() instead.
*/
-jasmine.Matchers.prototype.toNotContain = function(expected) {
- return !this.env.contains_(this.actual, expected);
-};
+jasmine.Matchers.prototype.toNotContain = function (expected) {
+ return !this.env.contains_(this.actual, expected)
+}
-jasmine.Matchers.prototype.toBeLessThan = function(expected) {
- return this.actual < expected;
-};
+jasmine.Matchers.prototype.toBeLessThan = function (expected) {
+ return this.actual < expected
+}
-jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
- return this.actual > expected;
-};
+jasmine.Matchers.prototype.toBeGreaterThan = function (expected) {
+ return this.actual > expected
+}
/**
* Matcher that checks that the expected item is equal to the actual item
@@ -1477,189 +1460,187 @@ jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {
* @param {Number} expected
* @param {Number} precision, as number of decimal places
*/
-jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
+jasmine.Matchers.prototype.toBeCloseTo = function (expected, precision) {
if (!(precision === 0)) {
- precision = precision || 2;
+ precision = precision || 2
}
- return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);
-};
+ return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2)
+}
/**
* Matcher that checks that the expected exception was thrown by the actual.
*
* @param {String} [expected]
*/
-jasmine.Matchers.prototype.toThrow = function(expected) {
- var result = false;
- var exception;
- if (typeof this.actual != 'function') {
- throw new Error('Actual is not a function');
+jasmine.Matchers.prototype.toThrow = function (expected) {
+ var result = false
+ var exception
+ if (typeof this.actual !== 'function') {
+ throw new Error('Actual is not a function')
}
try {
- this.actual();
+ this.actual()
} catch (e) {
- exception = e;
+ exception = e
}
if (exception) {
- result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
+ result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected))
}
- var not = this.isNot ? "not " : "";
+ var not = this.isNot ? 'not ' : ''
- this.message = function() {
+ this.message = function () {
if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {
- return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');
+ return ['Expected function ' + not + 'to throw', expected ? expected.message || expected : 'an exception', ', but it threw', exception.message || exception].join(' ')
} else {
- return "Expected function to throw an exception.";
+ return 'Expected function to throw an exception.'
}
- };
+ }
- return result;
-};
+ return result
+}
-jasmine.Matchers.Any = function(expectedClass) {
- this.expectedClass = expectedClass;
-};
+jasmine.Matchers.Any = function (expectedClass) {
+ this.expectedClass = expectedClass
+}
-jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
+jasmine.Matchers.Any.prototype.jasmineMatches = function (other) {
if (this.expectedClass == String) {
- return typeof other == 'string' || other instanceof String;
+ return typeof other === 'string' || other instanceof String
}
if (this.expectedClass == Number) {
- return typeof other == 'number' || other instanceof Number;
+ return typeof other === 'number' || other instanceof Number
}
if (this.expectedClass == Function) {
- return typeof other == 'function' || other instanceof Function;
+ return typeof other === 'function' || other instanceof Function
}
if (this.expectedClass == Object) {
- return typeof other == 'object';
+ return typeof other === 'object'
}
- return other instanceof this.expectedClass;
-};
+ return other instanceof this.expectedClass
+}
-jasmine.Matchers.Any.prototype.jasmineToString = function() {
- return 'jasmine.log
in production code.
*/
-jasmine.Spec.prototype.log = function() {
- return this.results_.log(arguments);
-};
+jasmine.Spec.prototype.log = function () {
+ return this.results_.log(arguments)
+}
jasmine.Spec.prototype.runs = function (func) {
- var block = new jasmine.Block(this.env, func, this);
- this.addToQueue(block);
- return this;
-};
+ var block = new jasmine.Block(this.env, func, this)
+ this.addToQueue(block)
+ return this
+}
jasmine.Spec.prototype.addToQueue = function (block) {
if (this.queue.isRunning()) {
- this.queue.insertNext(block);
+ this.queue.insertNext(block)
} else {
- this.queue.add(block);
+ this.queue.add(block)
}
-};
+}
/**
* @param {jasmine.ExpectationResult} result
*/
-jasmine.Spec.prototype.addMatcherResult = function(result) {
- this.results_.addResult(result);
-};
+jasmine.Spec.prototype.addMatcherResult = function (result) {
+ this.results_.addResult(result)
+}
-jasmine.Spec.prototype.expect = function(actual) {
- var positive = new (this.getMatchersClass_())(this.env, actual, this);
- positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);
- return positive;
-};
+jasmine.Spec.prototype.expect = function (actual) {
+ var positive = new (this.getMatchersClass_())(this.env, actual, this)
+ positive.not = new (this.getMatchersClass_())(this.env, actual, this, true)
+ return positive
+}
/**
* Waits a fixed time period before moving to the next block.
@@ -2278,11 +2255,11 @@ jasmine.Spec.prototype.expect = function(actual) {
* @deprecated Use waitsFor() instead
* @param {Number} timeout milliseconds to wait
*/
-jasmine.Spec.prototype.waits = function(timeout) {
- var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);
- this.addToQueue(waitsFunc);
- return this;
-};
+jasmine.Spec.prototype.waits = function (timeout) {
+ var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this)
+ this.addToQueue(waitsFunc)
+ return this
+}
/**
* Waits for the latchFunction to return true before proceeding to the next block.
@@ -2291,154 +2268,154 @@ jasmine.Spec.prototype.waits = function(timeout) {
* @param {String} optional_timeoutMessage
* @param {Number} optional_timeout
*/
-jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {
- var latchFunction_ = null;
- var optional_timeoutMessage_ = null;
- var optional_timeout_ = null;
+jasmine.Spec.prototype.waitsFor = function (latchFunction, optional_timeoutMessage, optional_timeout) {
+ var latchFunction_ = null
+ var optional_timeoutMessage_ = null
+ var optional_timeout_ = null
for (var i = 0; i < arguments.length; i++) {
- var arg = arguments[i];
+ var arg = arguments[i]
switch (typeof arg) {
case 'function':
- latchFunction_ = arg;
- break;
+ latchFunction_ = arg
+ break
case 'string':
- optional_timeoutMessage_ = arg;
- break;
+ optional_timeoutMessage_ = arg
+ break
case 'number':
- optional_timeout_ = arg;
- break;
+ optional_timeout_ = arg
+ break
}
}
- var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this);
- this.addToQueue(waitsForFunc);
- return this;
-};
+ var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this)
+ this.addToQueue(waitsForFunc)
+ return this
+}
jasmine.Spec.prototype.fail = function (e) {
var expectationResult = new jasmine.ExpectationResult({
passed: false,
message: e ? jasmine.util.formatException(e) : 'Exception',
trace: { stack: e.stack }
- });
- this.results_.addResult(expectationResult);
-};
-
-jasmine.Spec.prototype.getMatchersClass_ = function() {
- return this.matchersClass || this.env.matchersClass;
-};
-
-jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {
- var parent = this.getMatchersClass_();
- var newMatchersClass = function() {
- parent.apply(this, arguments);
- };
- jasmine.util.inherit(newMatchersClass, parent);
- jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);
- this.matchersClass = newMatchersClass;
-};
-
-jasmine.Spec.prototype.finishCallback = function() {
- this.env.reporter.reportSpecResults(this);
-};
-
-jasmine.Spec.prototype.finish = function(onComplete) {
- this.removeAllSpies();
- this.finishCallback();
+ })
+ this.results_.addResult(expectationResult)
+}
+
+jasmine.Spec.prototype.getMatchersClass_ = function () {
+ return this.matchersClass || this.env.matchersClass
+}
+
+jasmine.Spec.prototype.addMatchers = function (matchersPrototype) {
+ var parent = this.getMatchersClass_()
+ var newMatchersClass = function () {
+ parent.apply(this, arguments)
+ }
+ jasmine.util.inherit(newMatchersClass, parent)
+ jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass)
+ this.matchersClass = newMatchersClass
+}
+
+jasmine.Spec.prototype.finishCallback = function () {
+ this.env.reporter.reportSpecResults(this)
+}
+
+jasmine.Spec.prototype.finish = function (onComplete) {
+ this.removeAllSpies()
+ this.finishCallback()
if (onComplete) {
- onComplete();
+ onComplete()
}
-};
+}
-jasmine.Spec.prototype.after = function(doAfter) {
+jasmine.Spec.prototype.after = function (doAfter) {
if (this.queue.isRunning()) {
- this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
+ this.queue.add(new jasmine.Block(this.env, doAfter, this), true)
} else {
- this.afterCallbacks.unshift(doAfter);
+ this.afterCallbacks.unshift(doAfter)
}
-};
+}
-jasmine.Spec.prototype.execute = function(onComplete) {
- var spec = this;
+jasmine.Spec.prototype.execute = function (onComplete) {
+ var spec = this
if (!spec.env.specFilter(spec)) {
- spec.results_.skipped = true;
- spec.finish(onComplete);
- return;
+ spec.results_.skipped = true
+ spec.finish(onComplete)
+ return
}
- this.env.reporter.reportSpecStarting(this);
+ this.env.reporter.reportSpecStarting(this)
- spec.env.currentSpec = spec;
+ spec.env.currentSpec = spec
- spec.addBeforesAndAftersToQueue();
+ spec.addBeforesAndAftersToQueue()
spec.queue.start(function () {
- spec.finish(onComplete);
- });
-};
+ spec.finish(onComplete)
+ })
+}
-jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {
- var runner = this.env.currentRunner();
- var i;
+jasmine.Spec.prototype.addBeforesAndAftersToQueue = function () {
+ var runner = this.env.currentRunner()
+ var i
for (var suite = this.suite; suite; suite = suite.parentSuite) {
for (i = 0; i < suite.before_.length; i++) {
- this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));
+ this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this))
}
}
for (i = 0; i < runner.before_.length; i++) {
- this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));
+ this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this))
}
for (i = 0; i < this.afterCallbacks.length; i++) {
- this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);
+ this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true)
}
for (suite = this.suite; suite; suite = suite.parentSuite) {
for (i = 0; i < suite.after_.length; i++) {
- this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);
+ this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true)
}
}
for (i = 0; i < runner.after_.length; i++) {
- this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);
+ this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true)
}
-};
+}
-jasmine.Spec.prototype.explodes = function() {
- throw 'explodes function should not have been called';
-};
+jasmine.Spec.prototype.explodes = function () {
+ throw 'explodes function should not have been called'
+}
-jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
+jasmine.Spec.prototype.spyOn = function (obj, methodName, ignoreMethodDoesntExist) {
if (obj == jasmine.undefined) {
- throw "spyOn could not find an object to spy upon for " + methodName + "()";
+ throw 'spyOn could not find an object to spy upon for ' + methodName + '()'
}
if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
- throw methodName + '() method does not exist';
+ throw methodName + '() method does not exist'
}
if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
- throw new Error(methodName + ' has already been spied upon');
+ throw new Error(methodName + ' has already been spied upon')
}
- var spyObj = jasmine.createSpy(methodName);
+ var spyObj = jasmine.createSpy(methodName)
- this.spies_.push(spyObj);
- spyObj.baseObj = obj;
- spyObj.methodName = methodName;
- spyObj.originalValue = obj[methodName];
+ this.spies_.push(spyObj)
+ spyObj.baseObj = obj
+ spyObj.methodName = methodName
+ spyObj.originalValue = obj[methodName]
- obj[methodName] = spyObj;
+ obj[methodName] = spyObj
- return spyObj;
-};
+ return spyObj
+}
-jasmine.Spec.prototype.removeAllSpies = function() {
+jasmine.Spec.prototype.removeAllSpies = function () {
for (var i = 0; i < this.spies_.length; i++) {
- var spy = this.spies_[i];
- spy.baseObj[spy.methodName] = spy.originalValue;
+ var spy = this.spies_[i]
+ spy.baseObj[spy.methodName] = spy.originalValue
}
- this.spies_ = [];
-};
+ this.spies_ = []
+}
/**
* Internal representation of a Jasmine suite.
@@ -2449,94 +2426,94 @@ jasmine.Spec.prototype.removeAllSpies = function() {
* @param {Function} specDefinitions
* @param {jasmine.Suite} parentSuite
*/
-jasmine.Suite = function(env, description, specDefinitions, parentSuite) {
- var self = this;
- self.id = env.nextSuiteId ? env.nextSuiteId() : null;
- self.description = description;
- self.queue = new jasmine.Queue(env);
- self.parentSuite = parentSuite;
- self.env = env;
- self.before_ = [];
- self.after_ = [];
- self.children_ = [];
- self.suites_ = [];
- self.specs_ = [];
-};
-
-jasmine.Suite.prototype.getFullName = function() {
- var fullName = this.description;
+jasmine.Suite = function (env, description, specDefinitions, parentSuite) {
+ var self = this
+ self.id = env.nextSuiteId ? env.nextSuiteId() : null
+ self.description = description
+ self.queue = new jasmine.Queue(env)
+ self.parentSuite = parentSuite
+ self.env = env
+ self.before_ = []
+ self.after_ = []
+ self.children_ = []
+ self.suites_ = []
+ self.specs_ = []
+}
+
+jasmine.Suite.prototype.getFullName = function () {
+ var fullName = this.description
for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
- fullName = parentSuite.description + ' ' + fullName;
+ fullName = parentSuite.description + ' ' + fullName
}
- return fullName;
-};
+ return fullName
+}
-jasmine.Suite.prototype.finish = function(onComplete) {
- this.env.reporter.reportSuiteResults(this);
- this.finished = true;
- if (typeof(onComplete) == 'function') {
- onComplete();
+jasmine.Suite.prototype.finish = function (onComplete) {
+ this.env.reporter.reportSuiteResults(this)
+ this.finished = true
+ if (typeof (onComplete) === 'function') {
+ onComplete()
}
-};
+}
-jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {
- beforeEachFunction.typeName = 'beforeEach';
- this.before_.unshift(beforeEachFunction);
-};
+jasmine.Suite.prototype.beforeEach = function (beforeEachFunction) {
+ beforeEachFunction.typeName = 'beforeEach'
+ this.before_.unshift(beforeEachFunction)
+}
-jasmine.Suite.prototype.afterEach = function(afterEachFunction) {
- afterEachFunction.typeName = 'afterEach';
- this.after_.unshift(afterEachFunction);
-};
+jasmine.Suite.prototype.afterEach = function (afterEachFunction) {
+ afterEachFunction.typeName = 'afterEach'
+ this.after_.unshift(afterEachFunction)
+}
-jasmine.Suite.prototype.results = function() {
- return this.queue.results();
-};
+jasmine.Suite.prototype.results = function () {
+ return this.queue.results()
+}
-jasmine.Suite.prototype.add = function(suiteOrSpec) {
- this.children_.push(suiteOrSpec);
+jasmine.Suite.prototype.add = function (suiteOrSpec) {
+ this.children_.push(suiteOrSpec)
if (suiteOrSpec instanceof jasmine.Suite) {
- this.suites_.push(suiteOrSpec);
- this.env.currentRunner().addSuite(suiteOrSpec);
+ this.suites_.push(suiteOrSpec)
+ this.env.currentRunner().addSuite(suiteOrSpec)
} else {
- this.specs_.push(suiteOrSpec);
+ this.specs_.push(suiteOrSpec)
}
- this.queue.add(suiteOrSpec);
-};
+ this.queue.add(suiteOrSpec)
+}
-jasmine.Suite.prototype.specs = function() {
- return this.specs_;
-};
+jasmine.Suite.prototype.specs = function () {
+ return this.specs_
+}
-jasmine.Suite.prototype.suites = function() {
- return this.suites_;
-};
+jasmine.Suite.prototype.suites = function () {
+ return this.suites_
+}
-jasmine.Suite.prototype.children = function() {
- return this.children_;
-};
+jasmine.Suite.prototype.children = function () {
+ return this.children_
+}
-jasmine.Suite.prototype.execute = function(onComplete) {
- var self = this;
+jasmine.Suite.prototype.execute = function (onComplete) {
+ var self = this
this.queue.start(function () {
- self.finish(onComplete);
- });
-};
-jasmine.WaitsBlock = function(env, timeout, spec) {
- this.timeout = timeout;
- jasmine.Block.call(this, env, null, spec);
-};
+ self.finish(onComplete)
+ })
+}
+jasmine.WaitsBlock = function (env, timeout, spec) {
+ this.timeout = timeout
+ jasmine.Block.call(this, env, null, spec)
+}
-jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);
+jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block)
jasmine.WaitsBlock.prototype.execute = function (onComplete) {
if (jasmine.VERBOSE) {
- this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');
+ this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...')
}
this.env.setTimeout(function () {
- onComplete();
- }, this.timeout);
-};
+ onComplete()
+ }, this.timeout)
+}
/**
* A block which waits for some condition to become true, with timeout.
*
@@ -2548,53 +2525,53 @@ jasmine.WaitsBlock.prototype.execute = function (onComplete) {
* @param {String} message The message to display if the desired condition hasn't been met within the given time period.
* @param {jasmine.Spec} spec The Jasmine spec.
*/
-jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {
- this.timeout = timeout || env.defaultTimeoutInterval;
- this.latchFunction = latchFunction;
- this.message = message;
- this.totalTimeSpentWaitingForLatch = 0;
- jasmine.Block.call(this, env, null, spec);
-};
-jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);
+jasmine.WaitsForBlock = function (env, timeout, latchFunction, message, spec) {
+ this.timeout = timeout || env.defaultTimeoutInterval
+ this.latchFunction = latchFunction
+ this.message = message
+ this.totalTimeSpentWaitingForLatch = 0
+ jasmine.Block.call(this, env, null, spec)
+}
+jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block)
-jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;
+jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10
-jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
+jasmine.WaitsForBlock.prototype.execute = function (onComplete) {
if (jasmine.VERBOSE) {
- this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
+ this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'))
}
- var latchFunctionResult;
+ var latchFunctionResult
try {
- latchFunctionResult = this.latchFunction.apply(this.spec);
+ latchFunctionResult = this.latchFunction.apply(this.spec)
} catch (e) {
- this.spec.fail(e);
- onComplete();
- return;
+ this.spec.fail(e)
+ onComplete()
+ return
}
if (latchFunctionResult) {
- onComplete();
+ onComplete()
} else if (this.totalTimeSpentWaitingForLatch >= this.timeout) {
- var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen');
+ var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen')
this.spec.fail({
name: 'timeout',
message: message
- });
+ })
- this.abort = true;
- onComplete();
+ this.abort = true
+ onComplete()
} else {
- this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
- var self = this;
- this.env.setTimeout(function() {
- self.execute(onComplete);
- }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
- }
-};
-
-jasmine.version_= {
- "major": 1,
- "minor": 3,
- "build": 1,
- "revision": 1354556913
-};
+ this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT
+ var self = this
+ this.env.setTimeout(function () {
+ self.execute(onComplete)
+ }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT)
+ }
+}
+
+jasmine.version_ = {
+ major: 1,
+ minor: 3,
+ build: 1,
+ revision: 1354556913
+}
diff --git a/examples/jasmine/spec/PlayerSpec.js b/examples/jasmine/spec/PlayerSpec.js
index 79f1022..9f34547 100644
--- a/examples/jasmine/spec/PlayerSpec.js
+++ b/examples/jasmine/spec/PlayerSpec.js
@@ -1,58 +1,58 @@
-describe("Player", function() {
- var player;
- var song;
+describe('Player', function () {
+ var player
+ var song
- beforeEach(function() {
- player = new Player();
- song = new Song();
- });
+ beforeEach(function () {
+ player = new Player()
+ song = new Song()
+ })
- it("should be able to play a Song", function() {
- player.play(song);
- expect(player.currentlyPlayingSong).toEqual(song);
+ it('should be able to play a Song', function () {
+ player.play(song)
+ expect(player.currentlyPlayingSong).toEqual(song)
- //demonstrates use of custom matcher
- expect(player).toBePlaying(song);
- });
+ // demonstrates use of custom matcher
+ expect(player).toBePlaying(song)
+ })
- describe("when song has been paused", function() {
- beforeEach(function() {
- player.play(song);
- player.pause();
- });
+ describe('when song has been paused', function () {
+ beforeEach(function () {
+ player.play(song)
+ player.pause()
+ })
- it("should indicate that the song is currently paused", function() {
- expect(player.isPlaying).toBeFalsy();
+ it('should indicate that the song is currently paused', function () {
+ expect(player.isPlaying).toBeFalsy()
// demonstrates use of 'not' with a custom matcher
- expect(player).not.toBePlaying(song);
- });
+ expect(player).not.toBePlaying(song)
+ })
- it("should be possible to resume", function() {
- player.resume();
- expect(player.isPlaying).toBeTruthy();
- expect(player.currentlyPlayingSong).toEqual(song);
- });
- });
+ it('should be possible to resume', function () {
+ player.resume()
+ expect(player.isPlaying).toBeTruthy()
+ expect(player.currentlyPlayingSong).toEqual(song)
+ })
+ })
// demonstrates use of spies to intercept and test method calls
- it("tells the current song if the user has made it a favorite", function() {
- spyOn(song, 'persistFavoriteStatus');
-
- player.play(song);
- player.makeFavorite();
-
- expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true);
- });
-
- //demonstrates use of expected exceptions
- describe("#resume", function() {
- it("should throw an exception if song is already playing", function() {
- player.play(song);
-
- expect(function() {
- player.resume();
- }).toThrow("song is already playing");
- });
- });
-});
\ No newline at end of file
+ it('tells the current song if the user has made it a favorite', function () {
+ spyOn(song, 'persistFavoriteStatus')
+
+ player.play(song)
+ player.makeFavorite()
+
+ expect(song.persistFavoriteStatus).toHaveBeenCalledWith(true)
+ })
+
+ // demonstrates use of expected exceptions
+ describe('#resume', function () {
+ it('should throw an exception if song is already playing', function () {
+ player.play(song)
+
+ expect(function () {
+ player.resume()
+ }).toThrow('song is already playing')
+ })
+ })
+})
diff --git a/examples/jasmine/spec/SpecHelper.js b/examples/jasmine/spec/SpecHelper.js
index e9b8284..b391460 100644
--- a/examples/jasmine/spec/SpecHelper.js
+++ b/examples/jasmine/spec/SpecHelper.js
@@ -1,9 +1,9 @@
-beforeEach(function() {
+beforeEach(function () {
this.addMatchers({
- toBePlaying: function(expectedSong) {
- var player = this.actual;
- return player.currentlyPlayingSong === expectedSong &&
- player.isPlaying;
+ toBePlaying: function (expectedSong) {
+ var player = this.actual
+ return player.currentlyPlayingSong === expectedSong &&
+ player.isPlaying
}
- });
-});
+ })
+})
diff --git a/examples/jasmine/src/Player.js b/examples/jasmine/src/Player.js
index fcce826..a387a72 100644
--- a/examples/jasmine/src/Player.js
+++ b/examples/jasmine/src/Player.js
@@ -1,22 +1,22 @@
-function Player() {
+function Player () {
+}
+Player.prototype.play = function (song) {
+ this.currentlyPlayingSong = song
+ this.isPlaying = true
}
-Player.prototype.play = function(song) {
- this.currentlyPlayingSong = song;
- this.isPlaying = true;
-};
-Player.prototype.pause = function() {
- this.isPlaying = false;
-};
+Player.prototype.pause = function () {
+ this.isPlaying = false
+}
-Player.prototype.resume = function() {
+Player.prototype.resume = function () {
if (this.isPlaying) {
- throw new Error("song is already playing");
+ throw new Error('song is already playing')
}
- this.isPlaying = true;
-};
+ this.isPlaying = true
+}
-Player.prototype.makeFavorite = function() {
- this.currentlyPlayingSong.persistFavoriteStatus(true);
-};
\ No newline at end of file
+Player.prototype.makeFavorite = function () {
+ this.currentlyPlayingSong.persistFavoriteStatus(true)
+}
diff --git a/examples/jasmine/src/Song.js b/examples/jasmine/src/Song.js
index a8a3f2d..05baa85 100644
--- a/examples/jasmine/src/Song.js
+++ b/examples/jasmine/src/Song.js
@@ -1,7 +1,7 @@
-function Song() {
+function Song () {
}
-Song.prototype.persistFavoriteStatus = function(value) {
+Song.prototype.persistFavoriteStatus = function (value) {
// something complicated
- throw new Error("not yet implemented");
-};
\ No newline at end of file
+ throw new Error('not yet implemented')
+}
diff --git a/examples/mocha/Gruntfile.js b/examples/mocha/Gruntfile.js
index 3711917..af5c8c8 100644
--- a/examples/mocha/Gruntfile.js
+++ b/examples/mocha/Gruntfile.js
@@ -17,7 +17,7 @@ module.exports = function (grunt) {
browserName: 'internet explorer',
platform: 'VISTA',
version: '9'
- }];
+ }]
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
@@ -47,10 +47,10 @@ module.exports = function (grunt) {
}
},
watch: {}
- });
+ })
- grunt.loadNpmTasks('grunt-contrib-connect');
- grunt.loadNpmTasks('grunt-saucelabs');
+ grunt.loadNpmTasks('grunt-contrib-connect')
+ grunt.loadNpmTasks('grunt-saucelabs')
- grunt.registerTask('default', ['connect', 'saucelabs-mocha']);
-};
\ No newline at end of file
+ grunt.registerTask('default', ['connect', 'saucelabs-mocha'])
+}
diff --git a/examples/mocha/lib/expect/index.js b/examples/mocha/lib/expect/index.js
index b1e921d..09ea0f9 100644
--- a/examples/mocha/lib/expect/index.js
+++ b/examples/mocha/lib/expect/index.js
@@ -1,34 +1,33 @@
(function (global, module) {
-
- var exports = module.exports;
+ var exports = module.exports
/**
* Exports.
*/
- module.exports = expect;
- expect.Assertion = Assertion;
+ module.exports = expect
+ expect.Assertion = Assertion
/**
* Exports version.
*/
- expect.version = '0.3.1';
+ expect.version = '0.3.1'
/**
* Possible assertion flags.
*/
var flags = {
- not: ['to', 'be', 'have', 'include', 'only']
- , to: ['be', 'have', 'include', 'only', 'not']
- , only: ['have']
- , have: ['own']
- , be: ['an']
- };
+ not: ['to', 'be', 'have', 'include', 'only'],
+ to: ['be', 'have', 'include', 'only', 'not'],
+ only: ['have'],
+ have: ['own'],
+ be: ['an']
+ }
function expect (obj) {
- return new Assertion(obj);
+ return new Assertion(obj)
}
/**
@@ -38,44 +37,44 @@
*/
function Assertion (obj, flag, parent) {
- this.obj = obj;
- this.flags = {};
+ this.obj = obj
+ this.flags = {}
if (undefined != parent) {
- this.flags[flag] = true;
+ this.flags[flag] = true
for (var i in parent.flags) {
if (parent.flags.hasOwnProperty(i)) {
- this.flags[i] = true;
+ this.flags[i] = true
}
}
}
var $flags = flag ? flags[flag] : keys(flags)
- , self = this;
+ var self = this
if ($flags) {
for (var i = 0, l = $flags.length; i < l; i++) {
// avoid recursion
- if (this.flags[$flags[i]]) continue;
+ if (this.flags[$flags[i]]) continue
var name = $flags[i]
- , assertion = new Assertion(this.obj, name, this)
+ var assertion = new Assertion(this.obj, name, this)
- if ('function' == typeof Assertion.prototype[name]) {
+ if (typeof Assertion.prototype[name] === 'function') {
// clone the function, make sure we dont touch the prot reference
- var old = this[name];
+ var old = this[name]
this[name] = function () {
- return old.apply(self, arguments);
- };
+ return old.apply(self, arguments)
+ }
for (var fn in Assertion.prototype) {
if (Assertion.prototype.hasOwnProperty(fn) && fn != name) {
- this[name][fn] = bind(assertion[fn], assertion);
+ this[name][fn] = bind(assertion[fn], assertion)
}
}
} else {
- this[name] = assertion;
+ this[name] = assertion
}
}
}
@@ -89,21 +88,21 @@
Assertion.prototype.assert = function (truth, msg, error, expected) {
var msg = this.flags.not ? error : msg
- , ok = this.flags.not ? !truth : truth
- , err;
+ var ok = this.flags.not ? !truth : truth
+ var err
if (!ok) {
- err = new Error(msg.call(this));
+ err = new Error(msg.call(this))
if (arguments.length > 3) {
- err.actual = this.obj;
- err.expected = expected;
- err.showDiff = true;
+ err.actual = this.obj
+ err.expected = expected
+ err.showDiff = true
}
- throw err;
+ throw err
}
- this.and = new Assertion(this.obj);
- };
+ this.and = new Assertion(this.obj)
+ }
/**
* Check if the value is truthy
@@ -113,10 +112,10 @@
Assertion.prototype.ok = function () {
this.assert(
- !!this.obj
- , function(){ return 'expected ' + i(this.obj) + ' to be truthy' }
- , function(){ return 'expected ' + i(this.obj) + ' to be falsy' });
- };
+ !!this.obj
+ , function () { return 'expected ' + i(this.obj) + ' to be truthy' }
+ , function () { return 'expected ' + i(this.obj) + ' to be falsy' })
+ }
/**
* Creates an anonymous function which calls fn with arguments.
@@ -124,12 +123,12 @@
* @api public
*/
- Assertion.prototype.withArgs = function() {
- expect(this.obj).to.be.a('function');
- var fn = this.obj;
- var args = Array.prototype.slice.call(arguments);
- return expect(function() { fn.apply(null, args); });
- };
+ Assertion.prototype.withArgs = function () {
+ expect(this.obj).to.be.a('function')
+ var fn = this.obj
+ var args = Array.prototype.slice.call(arguments)
+ return expect(function () { fn.apply(null, args) })
+ }
/**
* Assert that the function throws.
@@ -140,39 +139,39 @@
Assertion.prototype.throwError =
Assertion.prototype.throwException = function (fn) {
- expect(this.obj).to.be.a('function');
+ expect(this.obj).to.be.a('function')
var thrown = false
- , not = this.flags.not;
+ var not = this.flags.not
try {
- this.obj();
+ this.obj()
} catch (e) {
if (isRegExp(fn)) {
- var subject = 'string' == typeof e ? e : e.message;
+ var subject = typeof e === 'string' ? e : e.message
if (not) {
- expect(subject).to.not.match(fn);
+ expect(subject).to.not.match(fn)
} else {
- expect(subject).to.match(fn);
+ expect(subject).to.match(fn)
}
- } else if ('function' == typeof fn) {
- fn(e);
+ } else if (typeof fn === 'function') {
+ fn(e)
}
- thrown = true;
+ thrown = true
}
if (isRegExp(fn) && not) {
// in the presence of a matcher, ensure the `not` only applies to
// the matching.
- this.flags.not = false;
+ this.flags.not = false
}
- var name = this.obj.name || 'fn';
+ var name = this.obj.name || 'fn'
this.assert(
- thrown
- , function(){ return 'expected ' + name + ' to throw an exception' }
- , function(){ return 'expected ' + name + ' not to throw an exception' });
- };
+ thrown
+ , function () { return 'expected ' + name + ' to throw an exception' }
+ , function () { return 'expected ' + name + ' not to throw an exception' })
+ }
/**
* Checks if the array is empty.
@@ -181,29 +180,29 @@
*/
Assertion.prototype.empty = function () {
- var expectation;
+ var expectation
- if ('object' == typeof this.obj && null !== this.obj && !isArray(this.obj)) {
- if ('number' == typeof this.obj.length) {
- expectation = !this.obj.length;
+ if (typeof this.obj === 'object' && this.obj !== null && !isArray(this.obj)) {
+ if (typeof this.obj.length === 'number') {
+ expectation = !this.obj.length
} else {
- expectation = !keys(this.obj).length;
+ expectation = !keys(this.obj).length
}
} else {
- if ('string' != typeof this.obj) {
- expect(this.obj).to.be.an('object');
+ if (typeof this.obj !== 'string') {
+ expect(this.obj).to.be.an('object')
}
- expect(this.obj).to.have.property('length');
- expectation = !this.obj.length;
+ expect(this.obj).to.have.property('length')
+ expectation = !this.obj.length
}
this.assert(
- expectation
- , function(){ return 'expected ' + i(this.obj) + ' to be empty' }
- , function(){ return 'expected ' + i(this.obj) + ' to not be empty' });
- return this;
- };
+ expectation
+ , function () { return 'expected ' + i(this.obj) + ' to be empty' }
+ , function () { return 'expected ' + i(this.obj) + ' to not be empty' })
+ return this
+ }
/**
* Checks if the obj exactly equals another.
@@ -214,11 +213,11 @@
Assertion.prototype.be =
Assertion.prototype.equal = function (obj) {
this.assert(
- obj === this.obj
- , function(){ return 'expected ' + i(this.obj) + ' to equal ' + i(obj) }
- , function(){ return 'expected ' + i(this.obj) + ' to not equal ' + i(obj) });
- return this;
- };
+ obj === this.obj
+ , function () { return 'expected ' + i(this.obj) + ' to equal ' + i(obj) }
+ , function () { return 'expected ' + i(this.obj) + ' to not equal ' + i(obj) })
+ return this
+ }
/**
* Checks if the obj sortof equals another.
@@ -228,12 +227,12 @@
Assertion.prototype.eql = function (obj) {
this.assert(
- expect.eql(this.obj, obj)
- , function(){ return 'expected ' + i(this.obj) + ' to sort of equal ' + i(obj) }
- , function(){ return 'expected ' + i(this.obj) + ' to sort of not equal ' + i(obj) }
- , obj);
- return this;
- };
+ expect.eql(this.obj, obj)
+ , function () { return 'expected ' + i(this.obj) + ' to sort of equal ' + i(obj) }
+ , function () { return 'expected ' + i(this.obj) + ' to sort of not equal ' + i(obj) }
+ , obj)
+ return this
+ }
/**
* Assert within start to finish (inclusive).
@@ -244,13 +243,13 @@
*/
Assertion.prototype.within = function (start, finish) {
- var range = start + '..' + finish;
+ var range = start + '..' + finish
this.assert(
- this.obj >= start && this.obj <= finish
- , function(){ return 'expected ' + i(this.obj) + ' to be within ' + range }
- , function(){ return 'expected ' + i(this.obj) + ' to not be within ' + range });
- return this;
- };
+ this.obj >= start && this.obj <= finish
+ , function () { return 'expected ' + i(this.obj) + ' to be within ' + range }
+ , function () { return 'expected ' + i(this.obj) + ' to not be within ' + range })
+ return this
+ }
/**
* Assert typeof / instance of
@@ -260,30 +259,30 @@
Assertion.prototype.a =
Assertion.prototype.an = function (type) {
- if ('string' == typeof type) {
+ if (typeof type === 'string') {
// proper english in error msg
- var n = /^[aeiou]/.test(type) ? 'n' : '';
+ var n = /^[aeiou]/.test(type) ? 'n' : ''
// typeof with support for 'array'
this.assert(
- 'array' == type ? isArray(this.obj) :
- 'regexp' == type ? isRegExp(this.obj) :
- 'object' == type
- ? 'object' == typeof this.obj && null !== this.obj
- : type == typeof this.obj
- , function(){ return 'expected ' + i(this.obj) + ' to be a' + n + ' ' + type }
- , function(){ return 'expected ' + i(this.obj) + ' not to be a' + n + ' ' + type });
+ type == 'array' ? isArray(this.obj)
+ : type == 'regexp' ? isRegExp(this.obj)
+ : type == 'object'
+ ? typeof this.obj === 'object' && this.obj !== null
+ : type === typeof this.obj
+ , function () { return 'expected ' + i(this.obj) + ' to be a' + n + ' ' + type }
+ , function () { return 'expected ' + i(this.obj) + ' not to be a' + n + ' ' + type })
} else {
// instanceof
- var name = type.name || 'supplied constructor';
+ var name = type.name || 'supplied constructor'
this.assert(
- this.obj instanceof type
- , function(){ return 'expected ' + i(this.obj) + ' to be an instance of ' + name }
- , function(){ return 'expected ' + i(this.obj) + ' not to be an instance of ' + name });
+ this.obj instanceof type
+ , function () { return 'expected ' + i(this.obj) + ' to be an instance of ' + name }
+ , function () { return 'expected ' + i(this.obj) + ' not to be an instance of ' + name })
}
- return this;
- };
+ return this
+ }
/**
* Assert numeric value above _n_.
@@ -295,11 +294,11 @@
Assertion.prototype.greaterThan =
Assertion.prototype.above = function (n) {
this.assert(
- this.obj > n
- , function(){ return 'expected ' + i(this.obj) + ' to be above ' + n }
- , function(){ return 'expected ' + i(this.obj) + ' to be below ' + n });
- return this;
- };
+ this.obj > n
+ , function () { return 'expected ' + i(this.obj) + ' to be above ' + n }
+ , function () { return 'expected ' + i(this.obj) + ' to be below ' + n })
+ return this
+ }
/**
* Assert numeric value below _n_.
@@ -311,11 +310,11 @@
Assertion.prototype.lessThan =
Assertion.prototype.below = function (n) {
this.assert(
- this.obj < n
- , function(){ return 'expected ' + i(this.obj) + ' to be below ' + n }
- , function(){ return 'expected ' + i(this.obj) + ' to be above ' + n });
- return this;
- };
+ this.obj < n
+ , function () { return 'expected ' + i(this.obj) + ' to be below ' + n }
+ , function () { return 'expected ' + i(this.obj) + ' to be above ' + n })
+ return this
+ }
/**
* Assert string value matches _regexp_.
@@ -326,11 +325,11 @@
Assertion.prototype.match = function (regexp) {
this.assert(
- regexp.exec(this.obj)
- , function(){ return 'expected ' + i(this.obj) + ' to match ' + regexp }
- , function(){ return 'expected ' + i(this.obj) + ' not to match ' + regexp });
- return this;
- };
+ regexp.exec(this.obj)
+ , function () { return 'expected ' + i(this.obj) + ' to match ' + regexp }
+ , function () { return 'expected ' + i(this.obj) + ' not to match ' + regexp })
+ return this
+ }
/**
* Assert property "length" exists and has value of _n_.
@@ -340,14 +339,14 @@
*/
Assertion.prototype.length = function (n) {
- expect(this.obj).to.have.property('length');
- var len = this.obj.length;
+ expect(this.obj).to.have.property('length')
+ var len = this.obj.length
this.assert(
- n == len
- , function(){ return 'expected ' + i(this.obj) + ' to have a length of ' + n + ' but got ' + len }
- , function(){ return 'expected ' + i(this.obj) + ' to not have a length of ' + len });
- return this;
- };
+ n == len
+ , function () { return 'expected ' + i(this.obj) + ' to have a length of ' + n + ' but got ' + len }
+ , function () { return 'expected ' + i(this.obj) + ' to not have a length of ' + len })
+ return this
+ }
/**
* Assert property _name_ exists, with optional _val_.
@@ -360,18 +359,18 @@
Assertion.prototype.property = function (name, val) {
if (this.flags.own) {
this.assert(
- Object.prototype.hasOwnProperty.call(this.obj, name)
- , function(){ return 'expected ' + i(this.obj) + ' to have own property ' + i(name) }
- , function(){ return 'expected ' + i(this.obj) + ' to not have own property ' + i(name) });
- return this;
+ Object.prototype.hasOwnProperty.call(this.obj, name)
+ , function () { return 'expected ' + i(this.obj) + ' to have own property ' + i(name) }
+ , function () { return 'expected ' + i(this.obj) + ' to not have own property ' + i(name) })
+ return this
}
if (this.flags.not && undefined !== val) {
if (undefined === this.obj[name]) {
- throw new Error(i(this.obj) + ' has no property ' + i(name));
+ throw new Error(i(this.obj) + ' has no property ' + i(name))
}
} else {
- var hasProp;
+ var hasProp
try {
hasProp = name in this.obj
} catch (e) {
@@ -379,23 +378,27 @@
}
this.assert(
- hasProp
- , function(){ return 'expected ' + i(this.obj) + ' to have a property ' + i(name) }
- , function(){ return 'expected ' + i(this.obj) + ' to not have a property ' + i(name) });
+ hasProp
+ , function () { return 'expected ' + i(this.obj) + ' to have a property ' + i(name) }
+ , function () { return 'expected ' + i(this.obj) + ' to not have a property ' + i(name) })
}
if (undefined !== val) {
this.assert(
- val === this.obj[name]
- , function(){ return 'expected ' + i(this.obj) + ' to have a property ' + i(name)
- + ' of ' + i(val) + ', but got ' + i(this.obj[name]) }
- , function(){ return 'expected ' + i(this.obj) + ' to not have a property ' + i(name)
- + ' of ' + i(val) });
+ val === this.obj[name]
+ , function () {
+ return 'expected ' + i(this.obj) + ' to have a property ' + i(name) +
+ ' of ' + i(val) + ', but got ' + i(this.obj[name])
+ }
+ , function () {
+ return 'expected ' + i(this.obj) + ' to not have a property ' + i(name) +
+ ' of ' + i(val)
+ })
}
- this.obj = this.obj[name];
- return this;
- };
+ this.obj = this.obj[name]
+ return this
+ }
/**
* Assert that the array contains _obj_ or string contains _obj_.
@@ -406,19 +409,19 @@
Assertion.prototype.string =
Assertion.prototype.contain = function (obj) {
- if ('string' == typeof this.obj) {
+ if (typeof this.obj === 'string') {
this.assert(
- ~this.obj.indexOf(obj)
- , function(){ return 'expected ' + i(this.obj) + ' to contain ' + i(obj) }
- , function(){ return 'expected ' + i(this.obj) + ' to not contain ' + i(obj) });
+ ~this.obj.indexOf(obj)
+ , function () { return 'expected ' + i(this.obj) + ' to contain ' + i(obj) }
+ , function () { return 'expected ' + i(this.obj) + ' to not contain ' + i(obj) })
} else {
this.assert(
- ~indexOf(this.obj, obj)
- , function(){ return 'expected ' + i(this.obj) + ' to contain ' + i(obj) }
- , function(){ return 'expected ' + i(this.obj) + ' to not contain ' + i(obj) });
+ ~indexOf(this.obj, obj)
+ , function () { return 'expected ' + i(this.obj) + ' to contain ' + i(obj) }
+ , function () { return 'expected ' + i(this.obj) + ' to not contain ' + i(obj) })
}
- return this;
- };
+ return this
+ }
/**
* Assert exact keys or inclusion of keys by using
@@ -431,52 +434,52 @@
Assertion.prototype.key =
Assertion.prototype.keys = function ($keys) {
var str
- , ok = true;
+ var ok = true
$keys = isArray($keys)
? $keys
- : Array.prototype.slice.call(arguments);
+ : Array.prototype.slice.call(arguments)
- if (!$keys.length) throw new Error('keys required');
+ if (!$keys.length) throw new Error('keys required')
var actual = keys(this.obj)
- , len = $keys.length;
+ var len = $keys.length
// Inclusion
ok = every($keys, function (key) {
- return ~indexOf(actual, key);
- });
+ return ~indexOf(actual, key)
+ })
// Strict
if (!this.flags.not && this.flags.only) {
- ok = ok && $keys.length == actual.length;
+ ok = ok && $keys.length == actual.length
}
// Key string
if (len > 1) {
$keys = map($keys, function (key) {
- return i(key);
- });
- var last = $keys.pop();
- str = $keys.join(', ') + ', and ' + last;
+ return i(key)
+ })
+ var last = $keys.pop()
+ str = $keys.join(', ') + ', and ' + last
} else {
- str = i($keys[0]);
+ str = i($keys[0])
}
// Form
- str = (len > 1 ? 'keys ' : 'key ') + str;
+ str = (len > 1 ? 'keys ' : 'key ') + str
// Have / include
- str = (!this.flags.only ? 'include ' : 'only have ') + str;
+ str = (!this.flags.only ? 'include ' : 'only have ') + str
// Assertion
this.assert(
- ok
- , function(){ return 'expected ' + i(this.obj) + ' to ' + str }
- , function(){ return 'expected ' + i(this.obj) + ' to not ' + str });
+ ok
+ , function () { return 'expected ' + i(this.obj) + ' to ' + str }
+ , function () { return 'expected ' + i(this.obj) + ' to not ' + str })
- return this;
- };
+ return this
+ }
/**
* Assert a failure.
@@ -485,10 +488,10 @@
* @api public
*/
Assertion.prototype.fail = function (msg) {
- var error = function() { return msg || "explicit failure"; }
- this.assert(false, error, error);
- return this;
- };
+ var error = function () { return msg || 'explicit failure' }
+ this.assert(false, error, error)
+ return this
+ }
/**
* Function bind implementation.
@@ -496,7 +499,7 @@
function bind (fn, scope) {
return function () {
- return fn.apply(scope, arguments);
+ return fn.apply(scope, arguments)
}
}
@@ -508,13 +511,13 @@
*/
function every (arr, fn, thisObj) {
- var scope = thisObj || global;
+ var scope = thisObj || global
for (var i = 0, j = arr.length; i < j; ++i) {
if (!fn.call(scope, arr[i], i, arr)) {
- return false;
+ return false
}
}
- return true;
+ return true
}
/**
@@ -526,47 +529,47 @@
function indexOf (arr, o, i) {
if (Array.prototype.indexOf) {
- return Array.prototype.indexOf.call(arr, o, i);
+ return Array.prototype.indexOf.call(arr, o, i)
}
if (arr.length === undefined) {
- return -1;
+ return -1
}
for (var j = arr.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0
- ; i < j && arr[i] !== o; i++);
+ ; i < j && arr[i] !== o; i++);
- return j <= i ? -1 : i;
+ return j <= i ? -1 : i
}
// https://gist.github.com/1044128/
- var getOuterHTML = function(element) {
- if ('outerHTML' in element) return element.outerHTML;
- var ns = "http://www.w3.org/1999/xhtml";
- var container = document.createElementNS(ns, '_');
- var xmlSerializer = new XMLSerializer();
- var html;
+ var getOuterHTML = function (element) {
+ if ('outerHTML' in element) return element.outerHTML
+ var ns = 'http://www.w3.org/1999/xhtml'
+ var container = document.createElementNS(ns, '_')
+ var xmlSerializer = new XMLSerializer()
+ var html
if (document.xmlVersion) {
- return xmlSerializer.serializeToString(element);
+ return xmlSerializer.serializeToString(element)
} else {
- container.appendChild(element.cloneNode(false));
- html = container.innerHTML.replace('><', '>' + element.innerHTML + '<');
- container.innerHTML = '';
- return html;
+ container.appendChild(element.cloneNode(false))
+ html = container.innerHTML.replace('><', '>' + element.innerHTML + '<')
+ container.innerHTML = ''
+ return html
}
- };
+ }
// Returns true if object is a DOM element.
var isDOMElement = function (object) {
if (typeof HTMLElement === 'object') {
- return object instanceof HTMLElement;
+ return object instanceof HTMLElement
} else {
return object &&
typeof object === 'object' &&
object.nodeType === 1 &&
- typeof object.nodeName === 'string';
+ typeof object.nodeName === 'string'
}
- };
+ }
/**
* Inspects an object.
@@ -576,10 +579,10 @@
*/
function i (obj, showHidden, depth) {
- var seen = [];
+ var seen = []
function stylize (str) {
- return str;
+ return str
}
function format (value, recurseTimes) {
@@ -590,163 +593,163 @@
value !== exports &&
// Also filter out any prototype objects using the circular check.
!(value.constructor && value.constructor.prototype === value)) {
- return value.inspect(recurseTimes);
+ return value.inspect(recurseTimes)
}
// Primitive types cannot have properties
switch (typeof value) {
case 'undefined':
- return stylize('undefined', 'undefined');
+ return stylize('undefined', 'undefined')
case 'string':
var simple = '\'' + json.stringify(value).replace(/^"|"$/g, '')
- .replace(/'/g, "\\'")
- .replace(/\\"/g, '"') + '\'';
- return stylize(simple, 'string');
+ .replace(/'/g, "\\'")
+ .replace(/\\"/g, '"') + '\''
+ return stylize(simple, 'string')
case 'number':
- return stylize('' + value, 'number');
+ return stylize('' + value, 'number')
case 'boolean':
- return stylize('' + value, 'boolean');
+ return stylize('' + value, 'boolean')
}
// For some reason typeof null is "object", so special case here.
if (value === null) {
- return stylize('null', 'null');
+ return stylize('null', 'null')
}
if (isDOMElement(value)) {
- return getOuterHTML(value);
+ return getOuterHTML(value)
}
// Look up the keys of the object.
- var visible_keys = keys(value);
- var $keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys;
+ var visible_keys = keys(value)
+ var $keys = showHidden ? Object.getOwnPropertyNames(value) : visible_keys
// Functions without properties can be shortcutted.
if (typeof value === 'function' && $keys.length === 0) {
if (isRegExp(value)) {
- return stylize('' + value, 'regexp');
+ return stylize('' + value, 'regexp')
} else {
- var name = value.name ? ': ' + value.name : '';
- return stylize('[Function' + name + ']', 'special');
+ var name = value.name ? ': ' + value.name : ''
+ return stylize('[Function' + name + ']', 'special')
}
}
// Dates without properties can be shortcutted
if (isDate(value) && $keys.length === 0) {
- return stylize(value.toUTCString(), 'date');
+ return stylize(value.toUTCString(), 'date')
}
-
+
// Error objects can be shortcutted
if (value instanceof Error) {
- return stylize("["+value.toString()+"]", 'Error');
+ return stylize('[' + value.toString() + ']', 'Error')
}
- var base, type, braces;
+ var base, type, braces
// Determine the object type
if (isArray(value)) {
- type = 'Array';
- braces = ['[', ']'];
+ type = 'Array'
+ braces = ['[', ']']
} else {
- type = 'Object';
- braces = ['{', '}'];
+ type = 'Object'
+ braces = ['{', '}']
}
// Make functions say that they are functions
if (typeof value === 'function') {
- var n = value.name ? ': ' + value.name : '';
- base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']';
+ var n = value.name ? ': ' + value.name : ''
+ base = (isRegExp(value)) ? ' ' + value : ' [Function' + n + ']'
} else {
- base = '';
+ base = ''
}
// Make dates with properties first say the date
if (isDate(value)) {
- base = ' ' + value.toUTCString();
+ base = ' ' + value.toUTCString()
}
if ($keys.length === 0) {
- return braces[0] + base + braces[1];
+ return braces[0] + base + braces[1]
}
if (recurseTimes < 0) {
if (isRegExp(value)) {
- return stylize('' + value, 'regexp');
+ return stylize('' + value, 'regexp')
} else {
- return stylize('[Object]', 'special');
+ return stylize('[Object]', 'special')
}
}
- seen.push(value);
+ seen.push(value)
var output = map($keys, function (key) {
- var name, str;
+ var name, str
if (value.__lookupGetter__) {
if (value.__lookupGetter__(key)) {
if (value.__lookupSetter__(key)) {
- str = stylize('[Getter/Setter]', 'special');
+ str = stylize('[Getter/Setter]', 'special')
} else {
- str = stylize('[Getter]', 'special');
+ str = stylize('[Getter]', 'special')
}
} else {
if (value.__lookupSetter__(key)) {
- str = stylize('[Setter]', 'special');
+ str = stylize('[Setter]', 'special')
}
}
}
if (indexOf(visible_keys, key) < 0) {
- name = '[' + key + ']';
+ name = '[' + key + ']'
}
if (!str) {
if (indexOf(seen, value[key]) < 0) {
if (recurseTimes === null) {
- str = format(value[key]);
+ str = format(value[key])
} else {
- str = format(value[key], recurseTimes - 1);
+ str = format(value[key], recurseTimes - 1)
}
if (str.indexOf('\n') > -1) {
if (isArray(value)) {
str = map(str.split('\n'), function (line) {
- return ' ' + line;
- }).join('\n').substr(2);
+ return ' ' + line
+ }).join('\n').substr(2)
} else {
str = '\n' + map(str.split('\n'), function (line) {
- return ' ' + line;
- }).join('\n');
+ return ' ' + line
+ }).join('\n')
}
}
} else {
- str = stylize('[Circular]', 'special');
+ str = stylize('[Circular]', 'special')
}
}
if (typeof name === 'undefined') {
if (type === 'Array' && key.match(/^\d+$/)) {
- return str;
+ return str
}
- name = json.stringify('' + key);
+ name = json.stringify('' + key)
if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) {
- name = name.substr(1, name.length - 2);
- name = stylize(name, 'name');
+ name = name.substr(1, name.length - 2)
+ name = stylize(name, 'name')
} else {
name = name.replace(/'/g, "\\'")
- .replace(/\\"/g, '"')
- .replace(/(^"|"$)/g, "'");
- name = stylize(name, 'string');
+ .replace(/\\"/g, '"')
+ .replace(/(^"|"$)/g, "'")
+ name = stylize(name, 'string')
}
}
- return name + ': ' + str;
- });
+ return name + ': ' + str
+ })
- seen.pop();
+ seen.pop()
- var numLinesEst = 0;
+ var numLinesEst = 0
var length = reduce(output, function (prev, cur) {
- numLinesEst++;
- if (indexOf(cur, '\n') >= 0) numLinesEst++;
- return prev + cur.length + 1;
- }, 0);
+ numLinesEst++
+ if (indexOf(cur, '\n') >= 0) numLinesEst++
+ return prev + cur.length + 1
+ }, 0)
if (length > 50) {
output = braces[0] +
@@ -754,114 +757,109 @@
' ' +
output.join(',\n ') +
' ' +
- braces[1];
-
+ braces[1]
} else {
- output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1];
+ output = braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]
}
- return output;
+ return output
}
- return format(obj, (typeof depth === 'undefined' ? 2 : depth));
+ return format(obj, (typeof depth === 'undefined' ? 2 : depth))
}
- expect.stringify = i;
+ expect.stringify = i
function isArray (ar) {
- return Object.prototype.toString.call(ar) === '[object Array]';
+ return Object.prototype.toString.call(ar) === '[object Array]'
}
- function isRegExp(re) {
- var s;
+ function isRegExp (re) {
+ var s
try {
- s = '' + re;
+ s = '' + re
} catch (e) {
- return false;
+ return false
}
return re instanceof RegExp || // easy case
// duck-type for context-switching evalcx case
- typeof(re) === 'function' &&
+ typeof (re) === 'function' &&
re.constructor.name === 'RegExp' &&
re.compile &&
re.test &&
re.exec &&
- s.match(/^\/.*\/[gim]{0,3}$/);
+ s.match(/^\/.*\/[gim]{0,3}$/)
}
- function isDate(d) {
- return d instanceof Date;
+ function isDate (d) {
+ return d instanceof Date
}
function keys (obj) {
if (Object.keys) {
- return Object.keys(obj);
+ return Object.keys(obj)
}
- var keys = [];
+ var keys = []
for (var i in obj) {
if (Object.prototype.hasOwnProperty.call(obj, i)) {
- keys.push(i);
+ keys.push(i)
}
}
- return keys;
+ return keys
}
function map (arr, mapper, that) {
if (Array.prototype.map) {
- return Array.prototype.map.call(arr, mapper, that);
+ return Array.prototype.map.call(arr, mapper, that)
}
- var other= new Array(arr.length);
+ var other = new Array(arr.length)
- for (var i= 0, n = arr.length; i%s
%s
%e', str)); - } + el.appendChild(fragment('
%e', str)) + } - // toggle code - // TODO: defer - if (!test.pending) { - var h2 = el.getElementsByTagName('h2')[0]; + // toggle code + // TODO: defer + if (!test.pending) { + var h2 = el.getElementsByTagName('h2')[0] - on(h2, 'click', function(){ - pre.style.display = 'none' == pre.style.display - ? 'block' - : 'none'; - }); + on(h2, 'click', function () { + pre.style.display = pre.style.display == 'none' + ? 'block' + : 'none' + }) - var pre = fragment('
%e
', utils.clean(test.fn.toString()));
- el.appendChild(pre);
- pre.style.display = 'none';
- }
+ var pre = fragment('%e
', utils.clean(test.fn.toString()))
+ el.appendChild(pre)
+ pre.style.display = 'none'
+ }
- // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
- if (stack[0]) stack[0].appendChild(el);
- });
-}
+ // Don't call .appendChild if #mocha-report was already .shift()'ed off the stack.
+ if (stack[0]) stack[0].appendChild(el)
+ })
+ }
-/**
+ /**
* Provide suite URL
*
* @param {Object} [suite]
*/
-HTML.prototype.suiteURL = function(suite){
- return '?grep=' + encodeURIComponent(suite.fullTitle());
-};
+ HTML.prototype.suiteURL = function (suite) {
+ return '?grep=' + encodeURIComponent(suite.fullTitle())
+ }
-/**
+ /**
* Provide test URL
*
* @param {Object} [test]
*/
-HTML.prototype.testURL = function(test){
- return '?grep=' + encodeURIComponent(test.fullTitle());
-};
+ HTML.prototype.testURL = function (test) {
+ return '?grep=' + encodeURIComponent(test.fullTitle())
+ }
-/**
+ /**
* Display error `msg`.
*/
-function error(msg) {
- document.body.appendChild(fragment('Expected: | " + expected + " |
---|---|
Result: | " + actual + " |
Diff: | " + QUnit.diff( expected, actual ) + " |
Source: | " + escapeText( source ) + " |
Result: | " + escapeText( actual ) + " |
---|---|
Source: | " + escapeText( source ) + " |
Expected: | " + expected + ' |
---|---|
Result: | " + actual + ' |
Diff: | " + QUnit.diff(expected, actual) + ' |
Source: | " + escapeText(source) + ' |
Result: | " + escapeText(actual) + ' |
---|---|
Source: | " + escapeText(source) + ' |