-var isCommonJS = typeof window == "undefined" && typeof exports == "object";\r
-\r
-/**\r
- * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.\r
- *\r
- * @namespace\r
- */\r
-var jasmine = {};\r
-if (isCommonJS) exports.jasmine = jasmine;\r
-/**\r
- * @private\r
- */\r
-jasmine.unimplementedMethod_ = function() {\r
- throw new Error("unimplemented method");\r
-};\r
-\r
-/**\r
- * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just\r
- * a plain old variable and may be redefined by somebody else.\r
- *\r
- * @private\r
- */\r
-jasmine.undefined = jasmine.___undefined___;\r
-\r
-/**\r
- * Show diagnostic messages in the console if set to true\r
- *\r
- */\r
-jasmine.VERBOSE = false;\r
-\r
-/**\r
- * 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.\r
- *\r
- */\r
-jasmine.DEFAULT_UPDATE_INTERVAL = 250;\r
-\r
-/**\r
- * Maximum levels of nesting that will be included when an object is pretty-printed\r
- */\r
-jasmine.MAX_PRETTY_PRINT_DEPTH = 40;\r
-\r
-/**\r
- * Default timeout interval in milliseconds for waitsFor() blocks.\r
- */\r
-jasmine.DEFAULT_TIMEOUT_INTERVAL = 5000;\r
-\r
-/**\r
- * 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.\r
- * Set to false to let the exception bubble up in the browser.\r
- *\r
- */\r
-jasmine.CATCH_EXCEPTIONS = true;\r
-\r
-jasmine.getGlobal = function() {\r
- function getGlobal() {\r
- return this;\r
- }\r
-\r
- return getGlobal();\r
-};\r
-\r
-/**\r
- * Allows for bound functions to be compared. Internal use only.\r
- *\r
- * @ignore\r
- * @private\r
- * @param base {Object} bound 'this' for the function\r
- * @param name {Function} function to find\r
- */\r
-jasmine.bindOriginal_ = function(base, name) {\r
- var original = base[name];\r
- if (original.apply) {\r
- return function() {\r
- return original.apply(base, arguments);\r
- };\r
- } else {\r
- // IE support\r
- return jasmine.getGlobal()[name];\r
- }\r
-};\r
-\r
-jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout');\r
-jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout');\r
-jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval');\r
-jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval');\r
-\r
-jasmine.MessageResult = function(values) {\r
- this.type = 'log';\r
- this.values = values;\r
- this.trace = new Error(); // todo: test better\r
-};\r
-\r
-jasmine.MessageResult.prototype.toString = function() {\r
- var text = "";\r
- for (var i = 0; i < this.values.length; i++) {\r
- if (i > 0) text += " ";\r
- if (jasmine.isString_(this.values[i])) {\r
- text += this.values[i];\r
- } else {\r
- text += jasmine.pp(this.values[i]);\r
- }\r
- }\r
- return text;\r
-};\r
-\r
-jasmine.ExpectationResult = function(params) {\r
- this.type = 'expect';\r
- this.matcherName = params.matcherName;\r
- this.passed_ = params.passed;\r
- this.expected = params.expected;\r
- this.actual = params.actual;\r
- this.message = this.passed_ ? 'Passed.' : params.message;\r
-\r
- var trace = (params.trace || new Error(this.message));\r
- this.trace = this.passed_ ? '' : trace;\r
-};\r
-\r
-jasmine.ExpectationResult.prototype.toString = function () {\r
- return this.message;\r
-};\r
-\r
-jasmine.ExpectationResult.prototype.passed = function () {\r
- return this.passed_;\r
-};\r
-\r
-/**\r
- * Getter for the Jasmine environment. Ensures one gets created\r
- */\r
-jasmine.getEnv = function() {\r
- var env = jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env();\r
- return env;\r
-};\r
-\r
-/**\r
- * @ignore\r
- * @private\r
- * @param value\r
- * @returns {Boolean}\r
- */\r
-jasmine.isArray_ = function(value) {\r
- return jasmine.isA_("Array", value);\r
-};\r
-\r
-/**\r
- * @ignore\r
- * @private\r
- * @param value\r
- * @returns {Boolean}\r
- */\r
-jasmine.isString_ = function(value) {\r
- return jasmine.isA_("String", value);\r
-};\r
-\r
-/**\r
- * @ignore\r
- * @private\r
- * @param value\r
- * @returns {Boolean}\r
- */\r
-jasmine.isNumber_ = function(value) {\r
- return jasmine.isA_("Number", value);\r
-};\r
-\r
-/**\r
- * @ignore\r
- * @private\r
- * @param {String} typeName\r
- * @param value\r
- * @returns {Boolean}\r
- */\r
-jasmine.isA_ = function(typeName, value) {\r
- return Object.prototype.toString.apply(value) === '[object ' + typeName + ']';\r
-};\r
-\r
-/**\r
- * Pretty printer for expecations. Takes any object and turns it into a human-readable string.\r
- *\r
- * @param value {Object} an object to be outputted\r
- * @returns {String}\r
- */\r
-jasmine.pp = function(value) {\r
- var stringPrettyPrinter = new jasmine.StringPrettyPrinter();\r
- stringPrettyPrinter.format(value);\r
- return stringPrettyPrinter.string;\r
-};\r
-\r
-/**\r
- * Returns true if the object is a DOM Node.\r
- *\r
- * @param {Object} obj object to check\r
- * @returns {Boolean}\r
- */\r
-jasmine.isDomNode = function(obj) {\r
- return obj.nodeType > 0;\r
-};\r
-\r
-/**\r
- * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter.\r
- *\r
- * @example\r
- * // don't care about which function is passed in, as long as it's a function\r
- * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));\r
- *\r
- * @param {Class} clazz\r
- * @returns matchable object of the type clazz\r
- */\r
-jasmine.any = function(clazz) {\r
- return new jasmine.Matchers.Any(clazz);\r
-};\r
-\r
-/**\r
- * Returns a matchable subset of a JSON object. For use in expectations when you don't care about all of the\r
- * attributes on the object.\r
- *\r
- * @example\r
- * // don't care about any other attributes than foo.\r
- * expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});\r
- *\r
- * @param sample {Object} sample\r
- * @returns matchable object for the sample\r
- */\r
-jasmine.objectContaining = function (sample) {\r
- return new jasmine.Matchers.ObjectContaining(sample);\r
-};\r
-\r
-/**\r
- * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks.\r
- *\r
- * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine\r
- * expectation syntax. Spies can be checked if they were called or not and what the calling params were.\r
- *\r
- * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).\r
- *\r
- * Spies are torn down at the end of every spec.\r
- *\r
- * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.\r
- *\r
- * @example\r
- * // a stub\r
- * var myStub = jasmine.createSpy('myStub'); // can be used anywhere\r
- *\r
- * // spy example\r
- * var foo = {\r
- * not: function(bool) { return !bool; }\r
- * }\r
- *\r
- * // actual foo.not will not be called, execution stops\r
- * spyOn(foo, 'not');\r
-\r
- // foo.not spied upon, execution will continue to implementation\r
- * spyOn(foo, 'not').andCallThrough();\r
- *\r
- * // fake example\r
- * var foo = {\r
- * not: function(bool) { return !bool; }\r
- * }\r
- *\r
- * // foo.not(val) will return val\r
- * spyOn(foo, 'not').andCallFake(function(value) {return value;});\r
- *\r
- * // mock example\r
- * foo.not(7 == 7);\r
- * expect(foo.not).toHaveBeenCalled();\r
- * expect(foo.not).toHaveBeenCalledWith(true);\r
- *\r
- * @constructor\r
- * @see spyOn, jasmine.createSpy, jasmine.createSpyObj\r
- * @param {String} name\r
- */\r
-jasmine.Spy = function(name) {\r
- /**\r
- * The name of the spy, if provided.\r
- */\r
- this.identity = name || 'unknown';\r
- /**\r
- * Is this Object a spy?\r
- */\r
- this.isSpy = true;\r
- /**\r
- * The actual function this spy stubs.\r
- */\r
- this.plan = function() {\r
- };\r
- /**\r
- * Tracking of the most recent call to the spy.\r
- * @example\r
- * var mySpy = jasmine.createSpy('foo');\r
- * mySpy(1, 2);\r
- * mySpy.mostRecentCall.args = [1, 2];\r
- */\r
- this.mostRecentCall = {};\r
-\r
- /**\r
- * Holds arguments for each call to the spy, indexed by call count\r
- * @example\r
- * var mySpy = jasmine.createSpy('foo');\r
- * mySpy(1, 2);\r
- * mySpy(7, 8);\r
- * mySpy.mostRecentCall.args = [7, 8];\r
- * mySpy.argsForCall[0] = [1, 2];\r
- * mySpy.argsForCall[1] = [7, 8];\r
- */\r
- this.argsForCall = [];\r
- this.calls = [];\r
-};\r
-\r
-/**\r
- * Tells a spy to call through to the actual implemenatation.\r
- *\r
- * @example\r
- * var foo = {\r
- * bar: function() { // do some stuff }\r
- * }\r
- *\r
- * // defining a spy on an existing property: foo.bar\r
- * spyOn(foo, 'bar').andCallThrough();\r
- */\r
-jasmine.Spy.prototype.andCallThrough = function() {\r
- this.plan = this.originalValue;\r
- return this;\r
-};\r
-\r
-/**\r
- * For setting the return value of a spy.\r
- *\r
- * @example\r
- * // defining a spy from scratch: foo() returns 'baz'\r
- * var foo = jasmine.createSpy('spy on foo').andReturn('baz');\r
- *\r
- * // defining a spy on an existing property: foo.bar() returns 'baz'\r
- * spyOn(foo, 'bar').andReturn('baz');\r
- *\r
- * @param {Object} value\r
- */\r
-jasmine.Spy.prototype.andReturn = function(value) {\r
- this.plan = function() {\r
- return value;\r
- };\r
- return this;\r
-};\r
-\r
-/**\r
- * For throwing an exception when a spy is called.\r
- *\r
- * @example\r
- * // defining a spy from scratch: foo() throws an exception w/ message 'ouch'\r
- * var foo = jasmine.createSpy('spy on foo').andThrow('baz');\r
- *\r
- * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'\r
- * spyOn(foo, 'bar').andThrow('baz');\r
- *\r
- * @param {String} exceptionMsg\r
- */\r
-jasmine.Spy.prototype.andThrow = function(exceptionMsg) {\r
- this.plan = function() {\r
- throw exceptionMsg;\r
- };\r
- return this;\r
-};\r
-\r
-/**\r
- * Calls an alternate implementation when a spy is called.\r
- *\r
- * @example\r
- * var baz = function() {\r
- * // do some stuff, return something\r
- * }\r
- * // defining a spy from scratch: foo() calls the function baz\r
- * var foo = jasmine.createSpy('spy on foo').andCall(baz);\r
- *\r
- * // defining a spy on an existing property: foo.bar() calls an anonymnous function\r
- * spyOn(foo, 'bar').andCall(function() { return 'baz';} );\r
- *\r
- * @param {Function} fakeFunc\r
- */\r
-jasmine.Spy.prototype.andCallFake = function(fakeFunc) {\r
- this.plan = fakeFunc;\r
- return this;\r
-};\r
-\r
-/**\r
- * Resets all of a spy's the tracking variables so that it can be used again.\r
- *\r
- * @example\r
- * spyOn(foo, 'bar');\r
- *\r
- * foo.bar();\r
- *\r
- * expect(foo.bar.callCount).toEqual(1);\r
- *\r
- * foo.bar.reset();\r
- *\r
- * expect(foo.bar.callCount).toEqual(0);\r
- */\r
-jasmine.Spy.prototype.reset = function() {\r
- this.wasCalled = false;\r
- this.callCount = 0;\r
- this.argsForCall = [];\r
- this.calls = [];\r
- this.mostRecentCall = {};\r
-};\r
-\r
-jasmine.createSpy = function(name) {\r
-\r
- var spyObj = function() {\r
- spyObj.wasCalled = true;\r
- spyObj.callCount++;\r
- var args = jasmine.util.argsToArray(arguments);\r
- spyObj.mostRecentCall.object = this;\r
- spyObj.mostRecentCall.args = args;\r
- spyObj.argsForCall.push(args);\r
- spyObj.calls.push({object: this, args: args});\r
- return spyObj.plan.apply(this, arguments);\r
- };\r
-\r
- var spy = new jasmine.Spy(name);\r
-\r
- for (var prop in spy) {\r
- spyObj[prop] = spy[prop];\r
- }\r
-\r
- spyObj.reset();\r
-\r
- return spyObj;\r
-};\r
-\r
-/**\r
- * Determines whether an object is a spy.\r
- *\r
- * @param {jasmine.Spy|Object} putativeSpy\r
- * @returns {Boolean}\r
- */\r
-jasmine.isSpy = function(putativeSpy) {\r
- return putativeSpy && putativeSpy.isSpy;\r
-};\r
-\r
-/**\r
- * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something\r
- * large in one call.\r
- *\r
- * @param {String} baseName name of spy class\r
- * @param {Array} methodNames array of names of methods to make spies\r
- */\r
-jasmine.createSpyObj = function(baseName, methodNames) {\r
- if (!jasmine.isArray_(methodNames) || methodNames.length === 0) {\r
- throw new Error('createSpyObj requires a non-empty array of method names to create spies for');\r
- }\r
- var obj = {};\r
- for (var i = 0; i < methodNames.length; i++) {\r
- obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);\r
- }\r
- return obj;\r
-};\r
-\r
-/**\r
- * All parameters are pretty-printed and concatenated together, then written to the current spec's output.\r
- *\r
- * Be careful not to leave calls to <code>jasmine.log</code> in production code.\r
- */\r
-jasmine.log = function() {\r
- var spec = jasmine.getEnv().currentSpec;\r
- spec.log.apply(spec, arguments);\r
-};\r
-\r
-/**\r
- * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy.\r
- *\r
- * @example\r
- * // spy example\r
- * var foo = {\r
- * not: function(bool) { return !bool; }\r
- * }\r
- * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops\r
- *\r
- * @see jasmine.createSpy\r
- * @param obj\r
- * @param methodName\r
- * @return {jasmine.Spy} a Jasmine spy that can be chained with all spy methods\r
- */\r
-var spyOn = function(obj, methodName) {\r
- return jasmine.getEnv().currentSpec.spyOn(obj, methodName);\r
-};\r
-if (isCommonJS) exports.spyOn = spyOn;\r
-\r
-/**\r
- * Creates a Jasmine spec that will be added to the current suite.\r
- *\r
- * // TODO: pending tests\r
- *\r
- * @example\r
- * it('should be true', function() {\r
- * expect(true).toEqual(true);\r
- * });\r
- *\r
- * @param {String} desc description of this specification\r
- * @param {Function} func defines the preconditions and expectations of the spec\r
- */\r
-var it = function(desc, func) {\r
- return jasmine.getEnv().it(desc, func);\r
-};\r
-if (isCommonJS) exports.it = it;\r
-\r
-/**\r
- * Creates a <em>disabled</em> Jasmine spec.\r
- *\r
- * A convenience method that allows existing specs to be disabled temporarily during development.\r
- *\r
- * @param {String} desc description of this specification\r
- * @param {Function} func defines the preconditions and expectations of the spec\r
- */\r
-var xit = function(desc, func) {\r
- return jasmine.getEnv().xit(desc, func);\r
-};\r
-if (isCommonJS) exports.xit = xit;\r
-\r
-/**\r
- * Starts a chain for a Jasmine expectation.\r
- *\r
- * It is passed an Object that is the actual value and should chain to one of the many\r
- * jasmine.Matchers functions.\r
- *\r
- * @param {Object} actual Actual value to test against and expected value\r
- * @return {jasmine.Matchers}\r
- */\r
-var expect = function(actual) {\r
- return jasmine.getEnv().currentSpec.expect(actual);\r
-};\r
-if (isCommonJS) exports.expect = expect;\r
-\r
-/**\r
- * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs.\r
- *\r
- * @param {Function} func Function that defines part of a jasmine spec.\r
- */\r
-var runs = function(func) {\r
- jasmine.getEnv().currentSpec.runs(func);\r
-};\r
-if (isCommonJS) exports.runs = runs;\r
-\r
-/**\r
- * Waits a fixed time period before moving to the next block.\r
- *\r
- * @deprecated Use waitsFor() instead\r
- * @param {Number} timeout milliseconds to wait\r
- */\r
-var waits = function(timeout) {\r
- jasmine.getEnv().currentSpec.waits(timeout);\r
-};\r
-if (isCommonJS) exports.waits = waits;\r
-\r
-/**\r
- * Waits for the latchFunction to return true before proceeding to the next block.\r
- *\r
- * @param {Function} latchFunction\r
- * @param {String} optional_timeoutMessage\r
- * @param {Number} optional_timeout\r
- */\r
-var waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {\r
- jasmine.getEnv().currentSpec.waitsFor.apply(jasmine.getEnv().currentSpec, arguments);\r
-};\r
-if (isCommonJS) exports.waitsFor = waitsFor;\r
-\r
-/**\r
- * A function that is called before each spec in a suite.\r
- *\r
- * Used for spec setup, including validating assumptions.\r
- *\r
- * @param {Function} beforeEachFunction\r
- */\r
-var beforeEach = function(beforeEachFunction) {\r
- jasmine.getEnv().beforeEach(beforeEachFunction);\r
-};\r
-if (isCommonJS) exports.beforeEach = beforeEach;\r
-\r
-/**\r
- * A function that is called after each spec in a suite.\r
- *\r
- * Used for restoring any state that is hijacked during spec execution.\r
- *\r
- * @param {Function} afterEachFunction\r
- */\r
-var afterEach = function(afterEachFunction) {\r
- jasmine.getEnv().afterEach(afterEachFunction);\r
-};\r
-if (isCommonJS) exports.afterEach = afterEach;\r
-\r
-/**\r
- * Defines a suite of specifications.\r
- *\r
- * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared\r
- * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization\r
- * of setup in some tests.\r
- *\r
- * @example\r
- * // TODO: a simple suite\r
- *\r
- * // TODO: a simple suite with a nested describe block\r
- *\r
- * @param {String} description A string, usually the class under test.\r
- * @param {Function} specDefinitions function that defines several specs.\r
- */\r
-var describe = function(description, specDefinitions) {\r
- return jasmine.getEnv().describe(description, specDefinitions);\r
-};\r
-if (isCommonJS) exports.describe = describe;\r
-\r
-/**\r
- * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.\r
- *\r
- * @param {String} description A string, usually the class under test.\r
- * @param {Function} specDefinitions function that defines several specs.\r
- */\r
-var xdescribe = function(description, specDefinitions) {\r
- return jasmine.getEnv().xdescribe(description, specDefinitions);\r
-};\r
-if (isCommonJS) exports.xdescribe = xdescribe;\r
-\r
-\r
-// Provide the XMLHttpRequest class for IE 5.x-6.x:\r
-jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {\r
- function tryIt(f) {\r
- try {\r
- return f();\r
- } catch(e) {\r
- }\r
- return null;\r
- }\r
-\r
- var xhr = tryIt(function() {\r
- return new ActiveXObject("Msxml2.XMLHTTP.6.0");\r
- }) ||\r
- tryIt(function() {\r
- return new ActiveXObject("Msxml2.XMLHTTP.3.0");\r
- }) ||\r
- tryIt(function() {\r
- return new ActiveXObject("Msxml2.XMLHTTP");\r
- }) ||\r
- tryIt(function() {\r
- return new ActiveXObject("Microsoft.XMLHTTP");\r
- });\r
-\r
- if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");\r
-\r
- return xhr;\r
-} : XMLHttpRequest;\r
-jasmine.MAX_PRETTY_PRINT_DEPTH = 1;\r
-\r
-jasmine.hashes = {};\r
-\r
-jasmine.hashString = function (s, hash) {\r
- hash = hash || 0;\r
- \r
- // see http://www.cse.yorku.ca/~oz/hash.html\r
- for (var c, i = 0, n = s.length; i < n; ++i) {\r
- c = s.charCodeAt(i);\r
- hash = c + (hash << 6) + (hash << 16) - hash;\r
- }\r
- \r
- if (jasmine.hashes[hash]) {\r
- console.log("Identical hash detected: " + s);\r
- }\r
- \r
- jasmine.hashes[hash] = true;\r
- return hash;\r
-};\r
-\r
-jasmine.toMap = function (items) {\r
- var map = {},\r
- k;\r
-\r
- for (k = items.length; k--; ) {\r
- map[items[k]] = true;\r
- }\r
-\r
- return map;\r
-};\r
-\r
-\r
-jasmine.setCurrentScript = function(file){\r
- if(typeof Ext !== "undefined" && Ext.cmd && Ext.cmd.api && Ext.cmd.api.adapter) {\r
- Ext.cmd.api.adapter.setCurrentScript(file);\r
- }\r
-};\r
-\r
-jasmine.getCurrentScript = function() {\r
- if(typeof Ext !== "undefined" && Ext.cmd && Ext.cmd.api && Ext.cmd.api.adapter) {\r
- return Ext.cmd.api.adapter.getCurrentScript();\r
- }\r
- return null;\r
-};\r
-\r
-jasmine.setOptions = function(jsonString) {\r
- jasmine._options = JSON.parse(jsonString);\r
-};\r
-\r
-jasmine.getOptions = function() {\r
- return jasmine._options || {};\r
-};\r
-\r
-jasmine.initDebug = function() {\r
- var spec = jasmine.getOptions().spec;\r
- if (spec) {\r
- var specId = parseInt(spec);\r
- this.getEnv().specFilter = function(spec) {\r
- if (spec.id === specId) {\r
- spec.debugBlocks = true;\r
- return true;\r
- } else {\r
- return false;\r
- }\r
- }\r
- }\r
-};\r
-\r
-jasmine.generateDebuggableBlock = function(fn) {\r
- return function() {\r
- debugger;\r
- /* Step into the function below */\r
- fn.apply(this, arguments);\r
- };\r
-};\r
-\r
-jasmine.showDebugPrompt = function(callback) {\r
- if (navigator.userAgent.toLowerCase().match(/chrome|safari|msie/)) {\r
- var div = document.createElement("div");\r
- \r
- div.setAttribute("style",[ \r
- "background:#E5E4E2;",\r
- "z-index:99999;",\r
- "position:absolute;",\r
- "left:25%;",\r
- "right:25%;",\r
- "top:100px;",\r
- "border-radius: 5px;",\r
- "border:1px solid #777;",\r
- "text-align:center;",\r
- "box-shadow: 5px 5px 5px #888;"\r
- ].join(""));\r
- \r
- div.innerHTML = [\r
- '<p>Open the developer tools to debug and press ok.</p>',\r
- '<button id="sencha-debug-button">OK</button>',\r
- '<p></p>'\r
- ].join("");\r
- \r
- document.body.appendChild(div);\r
- \r
- var button = document.getElementById("sencha-debug-button");\r
- \r
- var onClick = function() {\r
- if (button.removeEventListener) {\r
- button.removeEventListener("click", onClick, false);\r
- } else {\r
- button.detachEvent("onmousedown", onClick);\r
- }\r
- document.body.removeChild(div);\r
- div = null;\r
- callback();\r
- };\r
- \r
- if (button.addEventListener) {\r
- button.addEventListener("click", onClick, false);\r
- } else {\r
- button.attachEvent("onmousedown", onClick);\r
- }\r
- } else {\r
- callback();\r
- }\r
-};\r
-\r
-\r
-addGlobal = function() {};\r
-\r
-jasmine.getByIds = function (items, ids) {\r
- var result = [],\r
- length = items.length,\r
- i, id, item;\r
-\r
- for (i = 0; i < length; ++i) {\r
- item = items[i];\r
- id = item.id;\r
- if (ids[id]) {\r
- result.push(item);\r
- }\r
- }\r
-\r
- return result;\r
-};\r
-\r
-var specFor = function(object, specForFn) {\r
- jasmine.getEnv().specFor(object, specForFn);\r
-};\r
-\r
-var xspecFor = function(object, specForFn) {\r
- jasmine.getEnv().xspecFor(object, specForFn);\r
-};\r
-\r
-var xdescribe = function(description, specDefinitions, coverageFile) {\r
- return jasmine.getEnv().describe(description, specDefinitions, coverageFile).disable();\r
-};\r
-\r
-var xit = function(desc, func) {\r
- return jasmine.getEnv().it(desc, func).disable();\r
-};\r
-/**\r
- * @namespace\r
- */\r
-jasmine.util = {};\r
-\r
-/**\r
- * Declare that a child class inherit it's prototype from the parent class.\r
- *\r
- * @private\r
- * @param {Function} childClass\r
- * @param {Function} parentClass\r
- */\r
-jasmine.util.inherit = function(childClass, parentClass) {\r
- /**\r
- * @private\r
- */\r
- var subclass = function() {\r
- };\r
- subclass.prototype = parentClass.prototype;\r
- childClass.prototype = new subclass();\r
-};\r
-\r
-jasmine.util.formatException = function(e) {\r
- var lineNumber;\r
- if (e.line) {\r
- lineNumber = e.line;\r
- }\r
- else if (e.lineNumber) {\r
- lineNumber = e.lineNumber;\r
- }\r
-\r
- var file;\r
-\r
- if (e.sourceURL) {\r
- file = e.sourceURL;\r
- }\r
- else if (e.fileName) {\r
- file = e.fileName;\r
- }\r
-\r
- var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();\r
-\r
- if (file && lineNumber) {\r
- message += ' in ' + file + ' (line ' + lineNumber + ')';\r
- }\r
-\r
- return message;\r
-};\r
-\r
-jasmine.util.htmlEscape = function(str) {\r
- if (!str) return str;\r
- return str.replace(/&/g, '&')\r
- .replace(/</g, '<')\r
- .replace(/>/g, '>');\r
-};\r
-\r
-jasmine.util.argsToArray = function(args) {\r
- var arrayOfArgs = [];\r
- for (var i = 0; i < args.length; i++) arrayOfArgs.push(args[i]);\r
- return arrayOfArgs;\r
-};\r
-\r
-jasmine.util.extend = function(destination, source) {\r
- for (var property in source) destination[property] = source[property];\r
- return destination;\r
-};\r
-\r
-jasmine.util.getOrigin = function() {\r
- var port = window.location.port;\r
- var origin;\r
-\r
- origin = window.location.protocol + "//" + window.location.hostname;\r
-\r
- if (port) {\r
- origin += ":" + port;\r
- }\r
-\r
- return origin;\r
-};\r
-\r
-jasmine.util.getFileFromContextMapping = function(file) {\r
- var contextMapping = jasmine.contextMapping;\r
- if (file && contextMapping) {\r
- var origin = jasmine.util.getOrigin();\r
- for (var context in contextMapping) {\r
- file = file.replace(origin + context, contextMapping[context]);\r
- }\r
- }\r
- return file;\r
-};\r
-\r
-jasmine.util.formatException = function(e) {\r
- var lineNumber;\r
- if (e.line) {\r
- lineNumber = e.line;\r
- }\r
- else if (e.lineNumber) {\r
- lineNumber = e.lineNumber;\r
- }\r
-\r
- var file;\r
-\r
- if (e.sourceURL) {\r
- file = e.sourceURL;\r
- }\r
- else if (e.fileName) {\r
- file = e.fileName;\r
- }\r
-\r
- file = jasmine.util.getFileFromContextMapping(file);\r
- \r
- var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();\r
-\r
- if (file && lineNumber) {\r
- message += ' in ' + file + ' (line ' + lineNumber + ')';\r
- }\r
-\r
- return message;\r
-};/**\r
- * Environment for Jasmine\r
- *\r
- * @constructor\r
- */\r
-jasmine.Env = function() {\r
- this.currentSpec = null;\r
- this.currentSuite = null;\r
- this.currentRunner_ = new jasmine.Runner(this);\r
-\r
- this.reporter = new jasmine.MultiReporter();\r
-\r
- this.updateInterval = jasmine.DEFAULT_UPDATE_INTERVAL;\r
- this.defaultTimeoutInterval = jasmine.DEFAULT_TIMEOUT_INTERVAL;\r
- this.lastUpdate = 0;\r
- this.specFilter = function() {\r
- return true;\r
- };\r
-\r
- this.nextSpecId_ = 0;\r
- this.nextSuiteId_ = 0;\r
- this.equalityTesters_ = [];\r
-\r
- // wrap matchers\r
- this.matchersClass = function() {\r
- jasmine.Matchers.apply(this, arguments);\r
- };\r
- jasmine.util.inherit(this.matchersClass, jasmine.Matchers);\r
-\r
- jasmine.Matchers.wrapInto_(jasmine.Matchers.prototype, this.matchersClass);\r
-};\r
-\r
-\r
-jasmine.Env.prototype.setTimeout = jasmine.setTimeout;\r
-jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout;\r
-jasmine.Env.prototype.setInterval = jasmine.setInterval;\r
-jasmine.Env.prototype.clearInterval = jasmine.clearInterval;\r
-\r
-/**\r
- * @returns an object containing jasmine version build info, if set.\r
- */\r
-jasmine.Env.prototype.version = function () {\r
- if (jasmine.version_) {\r
- return jasmine.version_;\r
- } else {\r
- throw new Error('Version not set');\r
- }\r
-};\r
-\r
-/**\r
- * @returns string containing jasmine version build info, if set.\r
- */\r
-jasmine.Env.prototype.versionString = function() {\r
- if (!jasmine.version_) {\r
- return "version unknown";\r
- }\r
-\r
- var version = this.version();\r
- var versionString = version.major + "." + version.minor + "." + version.build;\r
- if (version.release_candidate) {\r
- versionString += ".rc" + version.release_candidate;\r
- }\r
- versionString += " revision " + version.revision;\r
- return versionString;\r
-};\r
-\r
-/**\r
- * @returns a sequential integer starting at 0\r
- */\r
-jasmine.Env.prototype.nextSpecId = function () {\r
- return this.nextSpecId_++;\r
-};\r
-\r
-/**\r
- * @returns a sequential integer starting at 0\r
- */\r
-jasmine.Env.prototype.nextSuiteId = function () {\r
- return this.nextSuiteId_++;\r
-};\r
-\r
-/**\r
- * Register a reporter to receive status updates from Jasmine.\r
- * @param {jasmine.Reporter} reporter An object which will receive status updates.\r
- */\r
-jasmine.Env.prototype.addReporter = function(reporter) {\r
- this.reporter.addReporter(reporter);\r
-};\r
-\r
-jasmine.Env.prototype.execute = function() {\r
- this.currentRunner_.execute();\r
-};\r
-\r
-jasmine.Env.prototype.describe = function(description, specDefinitions) {\r
- var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);\r
-\r
- var parentSuite = this.currentSuite;\r
- if (parentSuite) {\r
- parentSuite.add(suite);\r
- } else {\r
- this.currentRunner_.add(suite);\r
- }\r
-\r
- this.currentSuite = suite;\r
-\r
- var declarationError = null;\r
- try {\r
- specDefinitions.call(suite);\r
- } catch(e) {\r
- declarationError = e;\r
- }\r
-\r
- if (declarationError) {\r
- this.it("encountered a declaration exception", function() {\r
- throw declarationError;\r
- });\r
- }\r
-\r
- this.currentSuite = parentSuite;\r
-\r
- return suite;\r
-};\r
-\r
-jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {\r
- if (this.currentSuite) {\r
- this.currentSuite.beforeEach(beforeEachFunction);\r
- } else {\r
- this.currentRunner_.beforeEach(beforeEachFunction);\r
- }\r
-};\r
-\r
-jasmine.Env.prototype.currentRunner = function () {\r
- return this.currentRunner_;\r
-};\r
-\r
-jasmine.Env.prototype.afterEach = function(afterEachFunction) {\r
- if (this.currentSuite) {\r
- this.currentSuite.afterEach(afterEachFunction);\r
- } else {\r
- this.currentRunner_.afterEach(afterEachFunction);\r
- }\r
-\r
-};\r
-\r
-jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {\r
- return {\r
- execute: function() {\r
- }\r
- };\r
-};\r
-\r
-jasmine.Env.prototype.it = function(description, func) {\r
- var spec = new jasmine.Spec(this, this.currentSuite, description);\r
- this.currentSuite.add(spec);\r
- this.currentSpec = spec;\r
-\r
- if (func) {\r
- spec.runs(func);\r
- }\r
-\r
- return spec;\r
-};\r
-\r
-jasmine.Env.prototype.xit = function(desc, func) {\r
- return {\r
- id: this.nextSpecId(),\r
- runs: function() {\r
- }\r
- };\r
-};\r
-\r
-jasmine.Env.prototype.compareRegExps_ = function(a, b, mismatchKeys, mismatchValues) {\r
- if (a.source != b.source)\r
- mismatchValues.push("expected pattern /" + b.source + "/ is not equal to the pattern /" + a.source + "/");\r
-\r
- if (a.ignoreCase != b.ignoreCase)\r
- mismatchValues.push("expected modifier i was" + (b.ignoreCase ? " " : " not ") + "set and does not equal the origin modifier");\r
-\r
- if (a.global != b.global)\r
- mismatchValues.push("expected modifier g was" + (b.global ? " " : " not ") + "set and does not equal the origin modifier");\r
-\r
- if (a.multiline != b.multiline)\r
- mismatchValues.push("expected modifier m was" + (b.multiline ? " " : " not ") + "set and does not equal the origin modifier");\r
-\r
- if (a.sticky != b.sticky)\r
- mismatchValues.push("expected modifier y was" + (b.sticky ? " " : " not ") + "set and does not equal the origin modifier");\r
-\r
- return (mismatchValues.length === 0);\r
-};\r
-\r
-jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {\r
- if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {\r
- return true;\r
- }\r
-\r
- a.__Jasmine_been_here_before__ = b;\r
- b.__Jasmine_been_here_before__ = a;\r
-\r
- var hasKey = function(obj, keyName) {\r
- return obj !== null && obj[keyName] !== jasmine.undefined;\r
- };\r
-\r
- for (var property in b) {\r
- if (!hasKey(a, property) && hasKey(b, property)) {\r
- mismatchKeys.push("expected has key '" + property + "', but missing from actual.");\r
- }\r
- }\r
- for (property in a) {\r
- if (!hasKey(b, property) && hasKey(a, property)) {\r
- mismatchKeys.push("expected missing key '" + property + "', but present in actual.");\r
- }\r
- }\r
- for (property in b) {\r
- if (property == '__Jasmine_been_here_before__') continue;\r
- if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) {\r
- 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.");\r
- }\r
- }\r
-\r
- if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) {\r
- mismatchValues.push("arrays were not the same length");\r
- }\r
-\r
- delete a.__Jasmine_been_here_before__;\r
- delete b.__Jasmine_been_here_before__;\r
- return (mismatchKeys.length === 0 && mismatchValues.length === 0);\r
-};\r
-\r
-jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) {\r
- mismatchKeys = mismatchKeys || [];\r
- mismatchValues = mismatchValues || [];\r
-\r
- for (var i = 0; i < this.equalityTesters_.length; i++) {\r
- var equalityTester = this.equalityTesters_[i];\r
- var result = equalityTester(a, b, this, mismatchKeys, mismatchValues);\r
- if (result !== jasmine.undefined) return result;\r
- }\r
-\r
- if (a === b) return true;\r
-\r
- if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {\r
- return (a == jasmine.undefined && b == jasmine.undefined);\r
- }\r
-\r
- if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {\r
- return a === b;\r
- }\r
-\r
- if (a instanceof Date && b instanceof Date) {\r
- return a.getTime() == b.getTime();\r
- }\r
-\r
- if (a.jasmineMatches) {\r
- return a.jasmineMatches(b);\r
- }\r
-\r
- if (b.jasmineMatches) {\r
- return b.jasmineMatches(a);\r
- }\r
-\r
- if (a instanceof jasmine.Matchers.ObjectContaining) {\r
- return a.matches(b);\r
- }\r
-\r
- if (b instanceof jasmine.Matchers.ObjectContaining) {\r
- return b.matches(a);\r
- }\r
-\r
- if (jasmine.isString_(a) && jasmine.isString_(b)) {\r
- return (a == b);\r
- }\r
-\r
- if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {\r
- return (a == b);\r
- }\r
-\r
- if (a instanceof RegExp && b instanceof RegExp) {\r
- return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);\r
- }\r
-\r
- if (typeof a === "object" && typeof b === "object") {\r
- return this.compareObjects_(a, b, mismatchKeys, mismatchValues);\r
- }\r
-\r
- //Straight check\r
- return (a === b);\r
-};\r
-\r
-jasmine.Env.prototype.contains_ = function(haystack, needle) {\r
- if (jasmine.isArray_(haystack)) {\r
- for (var i = 0; i < haystack.length; i++) {\r
- if (this.equals_(haystack[i], needle)) return true;\r
- }\r
- return false;\r
- }\r
- return haystack.indexOf(needle) >= 0;\r
-};\r
-\r
-jasmine.Env.prototype.addEqualityTester = function(equalityTester) {\r
- this.equalityTesters_.push(equalityTester);\r
-};\r
-/**\r
- * Basic browsers detection.\r
- */\r
-jasmine.browser = {};\r
-jasmine.browser.isIE = !!window.ActiveXObject;\r
-jasmine.browser.isIE6 = jasmine.browser.isIE && !window.XMLHttpRequest;\r
-jasmine.browser.isIE7 = jasmine.browser.isIE && !!window.XMLHttpRequest && !document.documentMode;\r
-jasmine.browser.isIE8 = jasmine.browser.isIE && !!window.XMLHttpRequest && !!document.documentMode && !window.performance;\r
-jasmine.browser.isIE9 = jasmine.browser.isIE && !!window.performance;\r
-jasmine.browser.isSafari3 = /safari/.test(navigator.userAgent.toLowerCase()) && /version\/3/.test(navigator.userAgent.toLowerCase());\r
-jasmine.browser.isOpera = !!window.opera;\r
-jasmine.browser.isOpera11 = jasmine.browser.isOpera && parseInt(window.opera.version(), 10) > 10;\r
-\r
-jasmine.array = {};\r
-\r
- /**\r
- * Checks whether or not the specified item exists in the array.\r
- * Array.prototype.indexOf is missing in Internet Explorer, unfortunately.\r
- * We always have to use this static method instead for consistency\r
- * @param {Array} array The array to check\r
- * @param {Mixed} item The item to look for\r
- * @param {Number} from (Optional) The index at which to begin the search\r
- * @return {Number} The index of item in the array (or -1 if it is not found)\r
- */\r
-jasmine.array.indexOf = function(array, item, from){\r
- if (array.indexOf) {\r
- return array.indexOf(item, from);\r
- }\r
- \r
- var i, length = array.length;\r
-\r
- for (i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){\r
- if (array[i] === item) {\r
- return i;\r
- }\r
- }\r
-\r
- return -1;\r
-};\r
-\r
- /**\r
- * Removes the specified item from the array. If the item is not found nothing happens.\r
- * @param {Array} array The array\r
- * @param {Mixed} item The item to remove\r
- * @return {Array} The passed array itself\r
- */\r
-jasmine.array.remove = function(array, item) {\r
- var index = this.indexOf(array, item);\r
-\r
- if (index !== -1) {\r
- array.splice(index, 1);\r
- }\r
- \r
- return array;\r
-};\r
-\r
-jasmine.Env.prototype.it = function(description, func, timeout) {\r
- var spec = new jasmine.Spec(this, this.currentSuite, description);\r
- this.currentSuite.add(spec);\r
- this.currentSpec = spec;\r
-\r
- // override\r
- if (func) {\r
- func.typeName = 'it';\r
- var block = new jasmine.Block(spec.env, func, spec);\r
- block.timeout = parseInt(timeout);\r
- spec.addToQueue(block);\r
- }\r
- // end of override\r
- \r
- return spec;\r
-};\r
-\r
-jasmine.Env.prototype.specFor = function(object, specForFn) {\r
- var index = 0,\r
- property;\r
-\r
- for (property in object) {\r
- if (!object.hasOwnProperty(property)) {\r
- continue;\r
- }\r
- specForFn.call(this, property, object[property], index, object);\r
- index = index + 1;\r
- }\r
-};\r
-\r
-jasmine.Env.prototype.xspecFor = function(object, specForFn) {};/** No-op base class for Jasmine reporters.\r
- *\r
- * @constructor\r
- */\r
-jasmine.Reporter = function() {\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.Reporter.prototype.reportRunnerResults = function(runner) {\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.Reporter.prototype.reportSuiteResults = function(suite) {\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.Reporter.prototype.reportSpecStarting = function(spec) {\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.Reporter.prototype.reportSpecResults = function(spec) {\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.Reporter.prototype.log = function(str) {\r
-};\r
-\r
-/**\r
- * Blocks are functions with executable code that make up a spec.\r
- *\r
- * @constructor\r
- * @param {jasmine.Env} env\r
- * @param {Function} func\r
- * @param {jasmine.Spec} spec\r
- */\r
-jasmine.Block = function(env, func, spec) {\r
- this.env = env;\r
- this.func = func;\r
- this.spec = spec;\r
-};\r
-\r
-jasmine.Block.prototype.execute = function(onComplete) {\r
- if (!jasmine.CATCH_EXCEPTIONS) {\r
- this.func.apply(this.spec);\r
- }\r
- else {\r
- try {\r
- this.func.apply(this.spec);\r
- } catch (e) {\r
- this.spec.fail(e);\r
- }\r
- }\r
- onComplete();\r
-};\r
-jasmine.Block.prototype.execute = function(onComplete) {\r
- if (this.func.length === 1) {\r
- \r
- var timeOutId = setTimeout(function(){\r
- onComplete();\r
- }, this.timeout || jasmine.DEFAULT_TIMEOUT_INTERVAL);\r
- \r
- if (!jasmine.CATCH_EXCEPTIONS) {\r
- this.func.call(this.spec, function() {\r
- clearTimeout(timeOutId);\r
- onComplete();\r
- });\r
- } else {\r
- try {\r
- this.func.call(this.spec, function() {\r
- clearTimeout(timeOutId);\r
- onComplete();\r
- });\r
- } catch (e) {\r
- this.spec.fail(e);\r
- onComplete();\r
- }\r
- } \r
- } else {\r
- if (!jasmine.CATCH_EXCEPTIONS) {\r
- this.func.apply(this.spec);\r
- } else {\r
- try {\r
- this.func.apply(this.spec);\r
- } catch (e) {\r
- this.spec.fail(e);\r
- }\r
- }\r
- onComplete();\r
- }\r
-};/** JavaScript API reporter.\r
- *\r
- * @constructor\r
- */\r
-jasmine.JsApiReporter = function() {\r
- this.started = false;\r
- this.finished = false;\r
- this.suites_ = [];\r
- this.results_ = {};\r
-};\r
-\r
-jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) {\r
- this.started = true;\r
- var suites = runner.topLevelSuites();\r
- for (var i = 0; i < suites.length; i++) {\r
- var suite = suites[i];\r
- this.suites_.push(this.summarize_(suite));\r
- }\r
-};\r
-\r
-jasmine.JsApiReporter.prototype.suites = function() {\r
- return this.suites_;\r
-};\r
-\r
-jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {\r
- var isSuite = suiteOrSpec instanceof jasmine.Suite;\r
- var summary = {\r
- id: suiteOrSpec.id,\r
- name: suiteOrSpec.description,\r
- type: isSuite ? 'suite' : 'spec',\r
- children: []\r
- };\r
- \r
- if (isSuite) {\r
- var children = suiteOrSpec.children();\r
- for (var i = 0; i < children.length; i++) {\r
- summary.children.push(this.summarize_(children[i]));\r
- }\r
- }\r
- return summary;\r
-};\r
-\r
-jasmine.JsApiReporter.prototype.results = function() {\r
- return this.results_;\r
-};\r
-\r
-jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) {\r
- return this.results_[specId];\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) {\r
- this.finished = true;\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) {\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {\r
- this.results_[spec.id] = {\r
- messages: spec.results().getItems(),\r
- result: spec.results().failedCount > 0 ? "failed" : "passed"\r
- };\r
-};\r
-\r
-//noinspection JSUnusedLocalSymbols\r
-jasmine.JsApiReporter.prototype.log = function(str) {\r
-};\r
-\r
-jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){\r
- var results = {};\r
- for (var i = 0; i < specIds.length; i++) {\r
- var specId = specIds[i];\r
- results[specId] = this.summarizeResult_(this.results_[specId]);\r
- }\r
- return results;\r
-};\r
-\r
-jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){\r
- var summaryMessages = [];\r
- var messagesLength = result.messages.length;\r
- for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) {\r
- var resultMessage = result.messages[messageIndex];\r
- summaryMessages.push({\r
- text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,\r
- passed: resultMessage.passed ? resultMessage.passed() : true,\r
- type: resultMessage.type,\r
- message: resultMessage.message,\r
- trace: {\r
- stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined\r
- }\r
- });\r
- }\r
-\r
- return {\r
- result : result.result,\r
- messages : summaryMessages\r
- };\r
-};\r
-\r
-/**\r
- * @constructor\r
- * @param {jasmine.Env} env\r
- * @param actual\r
- * @param {jasmine.Spec} spec\r
- */\r
-jasmine.Matchers = function(env, actual, spec, opt_isNot) {\r
- this.env = env;\r
- this.actual = actual;\r
- this.spec = spec;\r
- this.isNot = opt_isNot || false;\r
- this.reportWasCalled_ = false;\r
-};\r
-\r
-// todo: @deprecated as of Jasmine 0.11, remove soon [xw]\r
-jasmine.Matchers.pp = function(str) {\r
- throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!");\r
-};\r
-\r
-// todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw]\r
-jasmine.Matchers.prototype.report = function(result, failing_message, details) {\r
- throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs");\r
-};\r
-\r
-jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) {\r
- for (var methodName in prototype) {\r
- if (methodName == 'report') continue;\r
- var orig = prototype[methodName];\r
- matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig);\r
- }\r
-};\r
-\r
-jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) {\r
- return function() {\r
- var matcherArgs = jasmine.util.argsToArray(arguments);\r
- var result = matcherFunction.apply(this, arguments);\r
-\r
- if (this.isNot) {\r
- result = !result;\r
- }\r
-\r
- if (this.reportWasCalled_) return result;\r
-\r
- var message;\r
- if (!result) {\r
- if (this.message) {\r
- message = this.message.apply(this, arguments);\r
- if (jasmine.isArray_(message)) {\r
- message = message[this.isNot ? 1 : 0];\r
- }\r
- } else {\r
- var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); });\r
- message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate;\r
- if (matcherArgs.length > 0) {\r
- for (var i = 0; i < matcherArgs.length; i++) {\r
- if (i > 0) message += ",";\r
- message += " " + jasmine.pp(matcherArgs[i]);\r
- }\r
- }\r
- message += ".";\r
- }\r
- }\r
- var expectationResult = new jasmine.ExpectationResult({\r
- matcherName: matcherName,\r
- passed: result,\r
- expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],\r
- actual: this.actual,\r
- message: message\r
- });\r
- this.spec.addMatcherResult(expectationResult);\r
- return jasmine.undefined;\r
- };\r
-};\r
-\r
-\r
-\r
-\r
-/**\r
- * toBe: compares the actual to the expected using ===\r
- * @param expected\r
- */\r
-jasmine.Matchers.prototype.toBe = function(expected) {\r
- return this.actual === expected;\r
-};\r
-\r
-/**\r
- * toNotBe: compares the actual to the expected using !==\r
- * @param expected\r
- * @deprecated as of 1.0. Use not.toBe() instead.\r
- */\r
-jasmine.Matchers.prototype.toNotBe = function(expected) {\r
- return this.actual !== expected;\r
-};\r
-\r
-/**\r
- * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc.\r
- *\r
- * @param expected\r
- */\r
-jasmine.Matchers.prototype.toEqual = function(expected) {\r
- return this.env.equals_(this.actual, expected);\r
-};\r
-\r
-/**\r
- * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual\r
- * @param expected\r
- * @deprecated as of 1.0. Use not.toEqual() instead.\r
- */\r
-jasmine.Matchers.prototype.toNotEqual = function(expected) {\r
- return !this.env.equals_(this.actual, expected);\r
-};\r
-\r
-/**\r
- * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes\r
- * a pattern or a String.\r
- *\r
- * @param expected\r
- */\r
-jasmine.Matchers.prototype.toMatch = function(expected) {\r
- return new RegExp(expected).test(this.actual);\r
-};\r
-\r
-/**\r
- * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch\r
- * @param expected\r
- * @deprecated as of 1.0. Use not.toMatch() instead.\r
- */\r
-jasmine.Matchers.prototype.toNotMatch = function(expected) {\r
- return !(new RegExp(expected).test(this.actual));\r
-};\r
-\r
-/**\r
- * Matcher that compares the actual to jasmine.undefined.\r
- */\r
-jasmine.Matchers.prototype.toBeDefined = function() {\r
- return (this.actual !== jasmine.undefined);\r
-};\r
-\r
-/**\r
- * Matcher that compares the actual to jasmine.undefined.\r
- */\r
-jasmine.Matchers.prototype.toBeUndefined = function() {\r
- return (this.actual === jasmine.undefined);\r
-};\r
-\r
-/**\r
- * Matcher that compares the actual to null.\r
- */\r
-jasmine.Matchers.prototype.toBeNull = function() {\r
- return (this.actual === null);\r
-};\r
-\r
-/**\r
- * Matcher that compares the actual to NaN.\r
- */\r
-jasmine.Matchers.prototype.toBeNaN = function() {\r
- this.message = function() {\r
- return [ "Expected " + jasmine.pp(this.actual) + " to be NaN." ];\r
- };\r
-\r
- return (this.actual !== this.actual);\r
-};\r
-\r
-/**\r
- * Matcher that boolean not-nots the actual.\r
- */\r
-jasmine.Matchers.prototype.toBeTruthy = function() {\r
- return !!this.actual;\r
-};\r
-\r
-\r
-/**\r
- * Matcher that boolean nots the actual.\r
- */\r
-jasmine.Matchers.prototype.toBeFalsy = function() {\r
- return !this.actual;\r
-};\r
-\r
-\r
-/**\r
- * Matcher that checks to see if the actual, a Jasmine spy, was called.\r
- */\r
-jasmine.Matchers.prototype.toHaveBeenCalled = function() {\r
- if (arguments.length > 0) {\r
- throw new Error('toHaveBeenCalled does not take arguments, use toHaveBeenCalledWith');\r
- }\r
-\r
- if (!jasmine.isSpy(this.actual)) {\r
- throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');\r
- }\r
-\r
- this.message = function() {\r
- return [\r
- "Expected spy " + this.actual.identity + " to have been called.",\r
- "Expected spy " + this.actual.identity + " not to have been called."\r
- ];\r
- };\r
-\r
- return this.actual.wasCalled;\r
-};\r
-\r
-/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */\r
-jasmine.Matchers.prototype.wasCalled = jasmine.Matchers.prototype.toHaveBeenCalled;\r
-\r
-/**\r
- * Matcher that checks to see if the actual, a Jasmine spy, was not called.\r
- *\r
- * @deprecated Use expect(xxx).not.toHaveBeenCalled() instead\r
- */\r
-jasmine.Matchers.prototype.wasNotCalled = function() {\r
- if (arguments.length > 0) {\r
- throw new Error('wasNotCalled does not take arguments');\r
- }\r
-\r
- if (!jasmine.isSpy(this.actual)) {\r
- throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');\r
- }\r
-\r
- this.message = function() {\r
- return [\r
- "Expected spy " + this.actual.identity + " to not have been called.",\r
- "Expected spy " + this.actual.identity + " to have been called."\r
- ];\r
- };\r
-\r
- return !this.actual.wasCalled;\r
-};\r
-\r
-/**\r
- * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.\r
- *\r
- * @example\r
- *\r
- */\r
-jasmine.Matchers.prototype.toHaveBeenCalledWith = function() {\r
- var expectedArgs = jasmine.util.argsToArray(arguments);\r
- if (!jasmine.isSpy(this.actual)) {\r
- throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');\r
- }\r
- this.message = function() {\r
- var invertedMessage = "Expected spy " + this.actual.identity + " not to have been called with " + jasmine.pp(expectedArgs) + " but it was.";\r
- var positiveMessage = "";\r
- if (this.actual.callCount === 0) {\r
- positiveMessage = "Expected spy " + this.actual.identity + " to have been called with " + jasmine.pp(expectedArgs) + " but it was never called.";\r
- } else {\r
- 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, '')\r
- }\r
- return [positiveMessage, invertedMessage];\r
- };\r
-\r
- return this.env.contains_(this.actual.argsForCall, expectedArgs);\r
-};\r
-\r
-/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */\r
-jasmine.Matchers.prototype.wasCalledWith = jasmine.Matchers.prototype.toHaveBeenCalledWith;\r
-\r
-/** @deprecated Use expect(xxx).not.toHaveBeenCalledWith() instead */\r
-jasmine.Matchers.prototype.wasNotCalledWith = function() {\r
- var expectedArgs = jasmine.util.argsToArray(arguments);\r
- if (!jasmine.isSpy(this.actual)) {\r
- throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');\r
- }\r
-\r
- this.message = function() {\r
- return [\r
- "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was",\r
- "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was"\r
- ];\r
- };\r
-\r
- return !this.env.contains_(this.actual.argsForCall, expectedArgs);\r
-};\r
-\r
-/**\r
- * Matcher that checks that the expected item is an element in the actual Array.\r
- *\r
- * @param {Object} expected\r
- */\r
-jasmine.Matchers.prototype.toContain = function(expected) {\r
- return this.env.contains_(this.actual, expected);\r
-};\r
-\r
-/**\r
- * Matcher that checks that the expected item is NOT an element in the actual Array.\r
- *\r
- * @param {Object} expected\r
- * @deprecated as of 1.0. Use not.toContain() instead.\r
- */\r
-jasmine.Matchers.prototype.toNotContain = function(expected) {\r
- return !this.env.contains_(this.actual, expected);\r
-};\r
-\r
-jasmine.Matchers.prototype.toBeLessThan = function(expected) {\r
- return this.actual < expected;\r
-};\r
-\r
-jasmine.Matchers.prototype.toBeGreaterThan = function(expected) {\r
- return this.actual > expected;\r
-};\r
-\r
-/**\r
- * Matcher that checks that the expected item is equal to the actual item\r
- * up to a given level of decimal precision (default 2).\r
- *\r
- * @param {Number} expected\r
- * @param {Number} precision, as number of decimal places\r
- */\r
-jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {\r
- if (!(precision === 0)) {\r
- precision = precision || 2;\r
- }\r
- return Math.abs(expected - this.actual) < (Math.pow(10, -precision) / 2);\r
-};\r
-\r
-/**\r
- * Matcher that checks that the expected exception was thrown by the actual.\r
- *\r
- * @param {String} [expected]\r
- */\r
-jasmine.Matchers.prototype.toThrow = function(expected) {\r
- var result = false;\r
- var exception;\r
- if (typeof this.actual != 'function') {\r
- throw new Error('Actual is not a function');\r
- }\r
- try {\r
- this.actual();\r
- } catch (e) {\r
- exception = e;\r
- }\r
- if (exception) {\r
- result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));\r
- }\r
-\r
- var not = this.isNot ? "not " : "";\r
-\r
- this.message = function() {\r
- if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) {\r
- return ["Expected function " + not + "to throw", expected ? expected.message || expected : "an exception", ", but it threw", exception.message || exception].join(' ');\r
- } else {\r
- return "Expected function to throw an exception.";\r
- }\r
- };\r
-\r
- return result;\r
-};\r
-\r
-jasmine.Matchers.Any = function(expectedClass) {\r
- this.expectedClass = expectedClass;\r
-};\r
-\r
-jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {\r
- if (this.expectedClass == String) {\r
- return typeof other == 'string' || other instanceof String;\r
- }\r
-\r
- if (this.expectedClass == Number) {\r
- return typeof other == 'number' || other instanceof Number;\r
- }\r
-\r
- if (this.expectedClass == Function) {\r
- return typeof other == 'function' || other instanceof Function;\r
- }\r
-\r
- if (this.expectedClass == Object) {\r
- return typeof other == 'object';\r
- }\r
-\r
- return other instanceof this.expectedClass;\r
-};\r
-\r
-jasmine.Matchers.Any.prototype.jasmineToString = function() {\r
- return '<jasmine.any(' + this.expectedClass + ')>';\r
-};\r
-\r
-jasmine.Matchers.ObjectContaining = function (sample) {\r
- this.sample = sample;\r
-};\r
-\r
-jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {\r
- mismatchKeys = mismatchKeys || [];\r
- mismatchValues = mismatchValues || [];\r
-\r
- var env = jasmine.getEnv();\r
-\r
- var hasKey = function(obj, keyName) {\r
- return obj != null && obj[keyName] !== jasmine.undefined;\r
- };\r
-\r
- for (var property in this.sample) {\r
- if (!hasKey(other, property) && hasKey(this.sample, property)) {\r
- mismatchKeys.push("expected has key '" + property + "', but missing from actual.");\r
- }\r
- else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) {\r
- mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");\r
- }\r
- }\r
-\r
- return (mismatchKeys.length === 0 && mismatchValues.length === 0);\r
-};\r
-\r
-jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () {\r
- return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";\r
-};\r
-/**\r
- * Override of toThrow special opera 10 !!! \r
- */\r
-jasmine.Matchers.prototype.toThrow = function(expected) {\r
- var result = false;\r
- var exception;\r
- if (typeof this.actual != 'function') {\r
- throw new Error('Actual is not a function');\r
- }\r
- try {\r
- this.actual();\r
- } catch (e) {\r
- exception = e;\r
- }\r
- if (exception) {\r
- result = (expected === jasmine.undefined || this.env.contains_(exception.message || exception, expected.message || expected));\r
- }\r
-\r
- var not = this.isNot ? "not " : "";\r
-\r
- this.message = function() {\r
- if (exception && (expected === jasmine.undefined || !this.env.contains_(exception.message || exception, expected.message || expected))) {\r
- return ["Expected function " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", exception.message || exception].join(' ');\r
- } else {\r
- return "Expected function to throw an exception.";\r
- }\r
- };\r
-\r
- return result;\r
-};\r
-\r
-jasmine.Matchers.prototype.toRaiseExtError = function(expected) {\r
- var result = false,\r
- global = Ext.global,\r
- extError;\r
- if (typeof this.actual != 'function') {\r
- throw new Error('Actual is not a function');\r
- }\r
- \r
- // mock the console to avoid logging to the real console during the tests\r
- Ext.global = {\r
- console: {\r
- dir: function(s) {\r
- return s;\r
- },\r
- log: function(s) {\r
- return s;\r
- },\r
- error: function(s) {\r
- return s;\r
- },\r
- warn: function(s) {\r
- return s;\r
- }\r
- }\r
- };\r
- \r
- try {\r
- this.actual();\r
- } catch (e) {\r
- extError = e;\r
- }\r
-\r
- \r
- Ext.global = global;\r
-\r
- if (extError && extError instanceof Error) {\r
- result = (expected === jasmine.undefined || this.env.contains_(extError.toString(), expected.message || expected));\r
- }\r
-\r
- \r
- var not = this.isNot ? "not " : "";\r
-\r
- this.message = function() {\r
- if (!extError instanceof Error) {\r
- return "Exception thrown is not an instance of Ext.Error";\r
- } else if (extError && (expected === jasmine.undefined || !this.env.contains_(extError.toString(), expected.message || expected))) {\r
- return ["Expected function " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", extError.toString()].join(' ');\r
- } else {\r
- return "Expected function to throw an exception.";\r
- }\r
- };\r
-\r
- return result;\r
-};\r
-\r
-jasmine.Matchers.prototype.hasHTML = function(expected) {\r
- var me = this;\r
- \r
- if (!me.actual || !me.actual.tagName) {\r
- throw new Error('Actual is not a dom element');\r
- }\r
- if (jasmine.browser.isSafari3) {\r
- expected = expected.replace(/>/g, '>');\r
- }\r
- // this normalize innerHTML which could vary a lot\r
- var normalizedHTML = me.actual.innerHTML.replace(/<[^>]*>/g, function(match1) {\r
- return match1.toLowerCase().replace(/=\w+/g, function(match2) { \r
- return '="' + match2.split('=')[1] + '"'; \r
- });\r
- });\r
-\r
- me.message = function() {\r
- return [\r
- "Expected dom element innerHTML to be " + expected + " but was " + normalizedHTML,\r
- "Expected dom element innerHTML to not be " + expected + "."\r
- ];\r
- };\r
- \r
- return normalizedHTML === expected;\r
-};\r
-\r
-jasmine.Matchers.prototype.toHaveCls = function(cls) {\r
- return Ext.fly(this.actual).hasCls(cls);\r
-};\r
-\r
-jasmine.Matchers.prototype.toEqualTime = function(hour, minute, second, ms) {\r
- var actual = this.actual;\r
- return actual instanceof Date &&\r
- actual.getHours() === hour &&\r
- actual.getMinutes() === (minute || 0) &&\r
- actual.getSeconds() === (second || 0) &&\r
- actual.getMilliseconds() === (ms || 0);\r
-\r
-};\r
-\r
-jasmine.Matchers.prototype.toBePositionedAt = function(x, y) {\r
- var xy = this.actual.getXY();\r
- this.message = function() {\r
- return "Expected Ext.Element to be positioned at (" + x + "," + y + ") but was positioned at (" + xy[0] + "," + xy[1] + ")";\r
- };\r
- return xy[0] === x && xy[1] === y;\r
-};\r
-\r
-(function () {\r
- var elementPropGetters = {\r
- x: function (el, root) {\r
- var x = el.getX(),\r
- x0 = root ? root.el.getX() : el.getX();\r
- return x - x0;\r
- },\r
- y: function (el, root) {\r
- var y = el.getY(),\r
- y0 = root ? root.el.getY() : el.getY();\r
- return y - y0;\r
- },\r
- w: function (el) {\r
- return el.getWidth();\r
- },\r
- h: function (el) {\r
- return el.getHeight();\r
- },\r
- xywh: function(el, root) {\r
- var x= el.getX(),\r
- x0 = root ? root.el.getX() : el.getX(),\r
- y = el.getY(),\r
- y0 = root ? root.el.getY() : el.getY(),\r
- w = el.getWidth(),\r
- h = el.getHeight(),\r
- dims = [];\r
- dims.push(x - x0, y - y0, w, h);\r
- return dims.join(' ');\r
- },\r
- cls: function (el) {\r
- return el.dom.className;\r
- }\r
- },\r
- browsers = [\r
- "IE6", "IE7", "IE8", "IE9", "IE",\r
- "Gecko3", "Gecko4", "Gecko5", "Gecko10", "Gecko",\r
- "FF3_6", "FF4", "FF5",\r
- "Chrome",\r
- "Safari2", "Safari3", "Safari4", "Safari5", "Safari"\r
- ],\r
- blen = browsers.length,\r
- b, browser,\r
- browserCheck = function(expected){\r
- if(Ext.isNumeric(expected) || Ext.isArray(expected)) {\r
- return expected;\r
- }\r
- for (b = 0; b < blen; b++) {\r
- browser = browsers[b];\r
- if (expected.hasOwnProperty(browser) && Ext["is" + browser]){\r
- return expected[browser];\r
- }\r
- }\r
- return expected['*'] || expected;\r
- };\r
-\r
-\r
- function checkLayout (comp, layout, root, path) {\r
- Ext.Object.each(layout, function (name, value) {\r
- if (name == 'items' || name == 'dockedItems') {\r
- Ext.Object.each(value, function (id, sub) {\r
- var isNum = String(parseInt(id,10)) == id,\r
- child = isNum ? comp[name].items[parseInt(id,10)]\r
- : (comp.getComponent(id) || comp.child(id));\r
-\r
- if (isNum) {\r
- id = '.' + name + '[' + id + ']';\r
- } else if (id.charAt(0) != ':') {\r
- id = '_' + id;\r
- }\r
-\r
- if (child) {\r
- checkLayout(child, sub, comp, path + id);\r
- } else {\r
- expect(id).toBe('found!');\r
- }\r
- });\r
- } else {\r
- // the name is an element name like 'body'\r
- var el = comp[name];\r
-\r
- if (!el) {\r
- // no child el matched, assume the key is a CSS selector\r
- el = comp.el.selectNode(name, false);\r
- }\r
-\r
- if (el.isComponent) {\r
- checkLayout(el, value, el.ownerCt, path + '_' + name);\r
- } else if (el.dom) {\r
- value = browserCheck(value);\r
- if (value.xywh) {\r
- var dims = value.xywh.split(' ');\r
- value.x = eval('(' + dims[0] + ')');\r
- value.y = eval('(' + dims[1] + ')');\r
- value.w = eval('(' + dims[2] + ')');\r
- value.h = eval('(' + dims[3] + ')');\r
- delete value.xywh;\r
- }\r
- Ext.Object.each(value, function (prop, expected) {\r
- var actual = elementPropGetters[prop](el, root || comp.el),\r
- pfx = path + '.' + name + '.' + prop + '=';\r
-\r
- if (Ext.isArray(expected)) {\r
- if (actual < expected[0] || actual > expected[1]) {\r
- expect(pfx + '=' + actual).\r
- toBe('in [' + expected[0] + ',' + expected[1] + ']');\r
- }\r
- } else if (actual != expected) {\r
- expect(pfx + actual).toEqual(expected);\r
- }\r
- });\r
- }\r
- }\r
- });\r
- }\r
-\r
- jasmine.Matchers.prototype.toHaveLayout = function(expected) {\r
- var comp = this.actual;\r
- checkLayout(comp, expected, comp.ownerCt, comp.getXType());\r
- return true;\r
- };\r
-\r
- jasmine.Matchers.prototype.toBeLessThanOrEqual = function(expected) {\r
- return this.actual <= expected;\r
- };\r
-\r
- jasmine.Matchers.prototype.toBeGreaterThanOrEqual = function(expected) {\r
- return this.actual >= expected;\r
- };\r
-\r
-})();\r
-\r
-\r
- jasmine.Matchers.prototype.toHaveFiredEvents = function() {\r
- var calls = this.actual.fireEvent.calls,\r
- i = 0,\r
- ret = true,\r
- expectedEvents = Array.prototype.slice.call(arguments, 0),\r
- length = expectedEvents.length,\r
- actualEvents = [], \r
- actualEvent,\r
- expectedEvent;\r
-\r
-\r
- \r
- for (;i < length; i++) {\r
- expectedEvent = expectedEvents[i];\r
- try {\r
- actualEvent = calls[i].args[0];\r
- } catch (e) {\r
- actualEvent = null;\r
- }\r
- if (actualEvent) {\r
- actualEvents.push(actualEvent);\r
- }\r
-\r
- if (actualEvent != expectedEvent) {\r
- ret = false;\r
- }\r
- }\r
- \r
- this.message = function() {\r
- return "Expected events flow to be (" + expectedEvents.length + " events): \n" + expectedEvents.join('\n') + "\nBut it was (" + actualEvents.length + " events): \n"+ actualEvents.join('\n');\r
- };\r
- return ret;\r
- };/**\r
- * @constructor\r
- */\r
-jasmine.MultiReporter = function() {\r
- this.subReporters_ = [];\r
-};\r
-jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);\r
-\r
-jasmine.MultiReporter.prototype.addReporter = function(reporter) {\r
- this.subReporters_.push(reporter);\r
-};\r
-\r
-(function() {\r
- var functionNames = [\r
- "reportRunnerStarting",\r
- "reportRunnerResults",\r
- "reportSuiteStarting",\r
- "reportSuiteResults",\r
- "reportSpecStarting",\r
- "reportSpecResults",\r
- "log"\r
- ];\r
- for (var i = 0; i < functionNames.length; i++) {\r
- var functionName = functionNames[i];\r
- jasmine.MultiReporter.prototype[functionName] = (function(functionName) {\r
- return function() {\r
- for (var j = 0; j < this.subReporters_.length; j++) {\r
- var subReporter = this.subReporters_[j];\r
- if (subReporter[functionName]) {\r
- subReporter[functionName].apply(subReporter, arguments);\r
- }\r
- }\r
- };\r
- })(functionName);\r
- }\r
-})();/**\r
- * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults\r
- *\r
- * @constructor\r
- */\r
-jasmine.NestedResults = function() {\r
- /**\r
- * The total count of results\r
- */\r
- this.totalCount = 0;\r
- /**\r
- * Number of passed results\r
- */\r
- this.passedCount = 0;\r
- /**\r
- * Number of failed results\r
- */\r
- this.failedCount = 0;\r
- /**\r
- * Was this suite/spec skipped?\r
- */\r
- this.skipped = false;\r
- /**\r
- * @ignore\r
- */\r
- this.items_ = [];\r
-};\r
-\r
-/**\r
- * Roll up the result counts.\r
- *\r
- * @param result\r
- */\r
-jasmine.NestedResults.prototype.rollupCounts = function(result) {\r
- this.totalCount += result.totalCount;\r
- this.passedCount += result.passedCount;\r
- this.failedCount += result.failedCount;\r
-};\r
-\r
-/**\r
- * Adds a log message.\r
- * @param values Array of message parts which will be concatenated later.\r
- */\r
-jasmine.NestedResults.prototype.log = function(values) {\r
- this.items_.push(new jasmine.MessageResult(values));\r
-};\r
-\r
-/**\r
- * Getter for the results: message & results.\r
- */\r
-jasmine.NestedResults.prototype.getItems = function() {\r
- return this.items_;\r
-};\r
-\r
-/**\r
- * Adds a result, tracking counts (total, passed, & failed)\r
- * @param {jasmine.ExpectationResult|jasmine.NestedResults} result\r
- */\r
-jasmine.NestedResults.prototype.addResult = function(result) {\r
- if (result.type != 'log') {\r
- if (result.items_) {\r
- this.rollupCounts(result);\r
- } else {\r
- this.totalCount++;\r
- if (result.passed()) {\r
- this.passedCount++;\r
- } else {\r
- this.failedCount++;\r
- }\r
- }\r
- }\r
- this.items_.push(result);\r
-};\r
-\r
-/**\r
- * @returns {Boolean} True if <b>everything</b> below passed\r
- */\r
-jasmine.NestedResults.prototype.passed = function() {\r
- return this.passedCount === this.totalCount;\r
-};\r
-/**\r
- * Base class for pretty printing for expectation results.\r
- */\r
-jasmine.PrettyPrinter = function() {\r
- this.ppNestLevel_ = 0;\r
-};\r
-\r
-/**\r
- * Formats a value in a nice, human-readable string.\r
- *\r
- * @param value\r
- */\r
-jasmine.PrettyPrinter.prototype.format = function(value) {\r
- this.ppNestLevel_++;\r
- try {\r
- if (value === jasmine.undefined) {\r
- this.emitScalar('undefined');\r
- } else if (value === null) {\r
- this.emitScalar('null');\r
- } else if (value === jasmine.getGlobal()) {\r
- this.emitScalar('<global>');\r
- } else if (value.jasmineToString) {\r
- this.emitScalar(value.jasmineToString());\r
- } else if (typeof value === 'string') {\r
- this.emitString(value);\r
- } else if (jasmine.isSpy(value)) {\r
- this.emitScalar("spy on " + value.identity);\r
- } else if (value instanceof RegExp) {\r
- this.emitScalar(value.toString());\r
- } else if (typeof value === 'function') {\r
- this.emitScalar('Function');\r
- } else if (typeof value.nodeType === 'number') {\r
- this.emitScalar('HTMLNode');\r
- } else if (value instanceof Date) {\r
- this.emitScalar('Date(' + value + ')');\r
- } else if (value.__Jasmine_been_here_before__) {\r
- this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');\r
- } else if (jasmine.isArray_(value) || typeof value == 'object') {\r
- value.__Jasmine_been_here_before__ = true;\r
- if (jasmine.isArray_(value)) {\r
- this.emitArray(value);\r
- } else {\r
- this.emitObject(value);\r
- }\r
- delete value.__Jasmine_been_here_before__;\r
- } else {\r
- this.emitScalar(value.toString());\r
- }\r
- } finally {\r
- this.ppNestLevel_--;\r
- }\r
-};\r
-\r
-jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {\r
- for (var property in obj) {\r
- if (!obj.hasOwnProperty(property)) continue;\r
- if (property == '__Jasmine_been_here_before__') continue;\r
- fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && \r
- obj.__lookupGetter__(property) !== null) : false);\r
- }\r
-};\r
-\r
-jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;\r
-jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;\r
-jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;\r
-jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;\r
-\r
-jasmine.StringPrettyPrinter = function() {\r
- jasmine.PrettyPrinter.call(this);\r
-\r
- this.string = '';\r
-};\r
-jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);\r
-\r
-jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {\r
- this.append(value);\r
-};\r
-\r
-jasmine.StringPrettyPrinter.prototype.emitString = function(value) {\r
- this.append("'" + value + "'");\r
-};\r
-\r
-jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {\r
- if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {\r
- this.append("Array");\r
- return;\r
- }\r
-\r
- this.append('[ ');\r
- for (var i = 0; i < array.length; i++) {\r
- if (i > 0) {\r
- this.append(', ');\r
- }\r
- this.format(array[i]);\r
- }\r
- this.append(' ]');\r
-};\r
-\r
-jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {\r
- if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {\r
- this.append("Object");\r
- return;\r
- }\r
-\r
- var self = this;\r
- this.append('{ ');\r
- var first = true;\r
-\r
- this.iterateObject(obj, function(property, isGetter) {\r
- if (first) {\r
- first = false;\r
- } else {\r
- self.append(', ');\r
- }\r
-\r
- self.append(property);\r
- self.append(' : ');\r
- if (isGetter) {\r
- self.append('<getter>');\r
- } else {\r
- self.format(obj[property]);\r
- }\r
- });\r
-\r
- this.append(' }');\r
-};\r
-\r
-jasmine.StringPrettyPrinter.prototype.append = function(value) {\r
- this.string += value;\r
-};\r
-(function() {\r
- var prototype = jasmine.PrettyPrinter.prototype,\r
- superFormat = prototype.format;\r
-\r
- prototype.format = function(value) {\r
- if (value && value.$className) {\r
- // support for pretty printing instances of Ext classes\r
- this.emitScalar(value.$className + '#' + value.id);\r
- } else {\r
- superFormat.call(this, value);\r
- }\r
- };\r
-})();jasmine.Queue = function(env) {\r
- this.env = env;\r
-\r
- // parallel to blocks. each true value in this array means the block will\r
- // get executed even if we abort\r
- this.ensured = [];\r
- this.blocks = [];\r
- this.running = false;\r
- this.index = 0;\r
- this.offset = 0;\r
- this.abort = false;\r
-};\r
-\r
-jasmine.Queue.prototype.addBefore = function(block, ensure) {\r
- if (ensure === jasmine.undefined) {\r
- ensure = false;\r
- }\r
-\r
- this.blocks.unshift(block);\r
- this.ensured.unshift(ensure);\r
-};\r
-\r
-jasmine.Queue.prototype.add = function(block, ensure) {\r
- if (ensure === jasmine.undefined) {\r
- ensure = false;\r
- }\r
-\r
- this.blocks.push(block);\r
- this.ensured.push(ensure);\r
-};\r
-\r
-jasmine.Queue.prototype.insertNext = function(block, ensure) {\r
- if (ensure === jasmine.undefined) {\r
- ensure = false;\r
- }\r
-\r
- this.ensured.splice((this.index + this.offset + 1), 0, ensure);\r
- this.blocks.splice((this.index + this.offset + 1), 0, block);\r
- this.offset++;\r
-};\r
-\r
-jasmine.Queue.prototype.start = function(onComplete) {\r
- this.running = true;\r
- this.onComplete = onComplete;\r
- this.next_();\r
-};\r
-\r
-jasmine.Queue.prototype.isRunning = function() {\r
- return this.running;\r
-};\r
-\r
-jasmine.Queue.LOOP_DONT_RECURSE = true;\r
-\r
-jasmine.Queue.prototype.next_ = function() {\r
- var self = this;\r
- var goAgain = true;\r
-\r
- while (goAgain) {\r
- goAgain = false;\r
- \r
- if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {\r
- var calledSynchronously = true;\r
- var completedSynchronously = false;\r
-\r
- var onComplete = function () {\r
- if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {\r
- completedSynchronously = true;\r
- return;\r
- }\r
-\r
- if (self.blocks[self.index].abort) {\r
- self.abort = true;\r
- }\r
-\r
- self.offset = 0;\r
- self.index++;\r
-\r
- var now = new Date().getTime();\r
- if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {\r
- self.env.lastUpdate = now;\r
- self.env.setTimeout(function() {\r
- self.next_();\r
- }, 0);\r
- } else {\r
- if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {\r
- goAgain = true;\r
- } else {\r
- self.next_();\r
- }\r
- }\r
- };\r
- self.blocks[self.index].execute(onComplete);\r
-\r
- calledSynchronously = false;\r
- if (completedSynchronously) {\r
- onComplete();\r
- }\r
- \r
- } else {\r
- self.running = false;\r
- if (self.onComplete) {\r
- self.onComplete();\r
- }\r
- }\r
- }\r
-};\r
-\r
-jasmine.Queue.prototype.results = function() {\r
- var results = new jasmine.NestedResults();\r
- for (var i = 0; i < this.blocks.length; i++) {\r
- if (this.blocks[i].results) {\r
- results.addResult(this.blocks[i].results());\r
- }\r
- }\r
- return results;\r
-};\r
-\r
-\r
-/**\r
- * Runner\r
- *\r
- * @constructor\r
- * @param {jasmine.Env} env\r
- */\r
-jasmine.Runner = function(env) {\r
- var self = this;\r
- self.env = env;\r
- self.queue = new jasmine.Queue(env);\r
- self.before_ = [];\r
- self.after_ = [];\r
- self.suites_ = [];\r
-};\r
-\r
-jasmine.Runner.prototype.execute = function() {\r
- var self = this;\r
- if (self.env.reporter.reportRunnerStarting) {\r
- self.env.reporter.reportRunnerStarting(this);\r
- }\r
- self.queue.start(function () {\r
- self.finishCallback();\r
- });\r
-};\r
-\r
-jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {\r
- beforeEachFunction.typeName = 'beforeEach';\r
- this.before_.splice(0,0,beforeEachFunction);\r
-};\r
-\r
-jasmine.Runner.prototype.afterEach = function(afterEachFunction) {\r
- afterEachFunction.typeName = 'afterEach';\r
- this.after_.splice(0,0,afterEachFunction);\r
-};\r
-\r
-\r
-jasmine.Runner.prototype.finishCallback = function() {\r
- this.env.reporter.reportRunnerResults(this);\r
-};\r
-\r
-jasmine.Runner.prototype.addSuite = function(suite) {\r
- this.suites_.push(suite);\r
-};\r
-\r
-jasmine.Runner.prototype.add = function(block) {\r
- if (block instanceof jasmine.Suite) {\r
- this.addSuite(block);\r
- }\r
- this.queue.add(block);\r
-};\r
-\r
-jasmine.Runner.prototype.specs = function () {\r
- var suites = this.suites();\r
- var specs = [];\r
- for (var i = 0; i < suites.length; i++) {\r
- specs = specs.concat(suites[i].specs());\r
- }\r
- return specs;\r
-};\r
-\r
-jasmine.Runner.prototype.suites = function() {\r
- return this.suites_;\r
-};\r
-\r
-jasmine.Runner.prototype.topLevelSuites = function() {\r
- var topLevelSuites = [];\r
- for (var i = 0; i < this.suites_.length; i++) {\r
- if (!this.suites_[i].parentSuite) {\r
- topLevelSuites.push(this.suites_[i]);\r
- }\r
- }\r
- return topLevelSuites;\r
-};\r
-\r
-jasmine.Runner.prototype.results = function() {\r
- return this.queue.results();\r
-};\r
-jasmine.Runner.prototype.filter = function (suiteIds, specIds) {\r
- // convert [1, 2] into { 1: true, 2: true }\r
- //\r
- if (typeof suiteIds.length == 'number') {\r
- suiteIds = jasmine.toMap(suiteIds);\r
- }\r
- if (typeof specIds.length == 'number') {\r
- specIds = jasmine.toMap(specIds);\r
- }\r
-\r
- var specs = jasmine.getByIds(this.specs(), specIds),\r
- suites = jasmine.getByIds(this.suites(), suiteIds),\r
- blocks = [], \r
- i, length, suite;\r
- \r
- length = specs.length;\r
- for (i = 0; i < length; i++) {\r
- suite = specs[i].getRootSuite();\r
- if (jasmine.array.indexOf(blocks, suite) === -1) {\r
- suite.filter(suiteIds, specIds);\r
- blocks.push(suite);\r
- }\r
- }\r
- \r
- length = suites.length;\r
- for (i = 0; i < length; i++) {\r
- suite = suites[i].getRootSuite();\r
- if (jasmine.array.indexOf(blocks, suite) === -1) {\r
- suite.filter(suiteIds, specIds);\r
- blocks.push(suite);\r
- }\r
- }\r
-\r
- if (blocks.length) {\r
- this.queue.blocks = blocks;\r
- }\r
-\r
- return this;\r
-};\r
-/**\r
- * Internal representation of a Jasmine specification, or test.\r
- *\r
- * @constructor\r
- * @param {jasmine.Env} env\r
- * @param {jasmine.Suite} suite\r
- * @param {String} description\r
- */\r
-jasmine.Spec = function(env, suite, description) {\r
- if (!env) {\r
- throw new Error('jasmine.Env() required');\r
- }\r
- if (!suite) {\r
- throw new Error('jasmine.Suite() required');\r
- }\r
- var spec = this;\r
- spec.id = env.nextSpecId ? env.nextSpecId() : null;\r
- spec.env = env;\r
- spec.suite = suite;\r
- spec.description = description;\r
- spec.queue = new jasmine.Queue(env);\r
-\r
- spec.afterCallbacks = [];\r
- spec.spies_ = [];\r
-\r
- spec.results_ = new jasmine.NestedResults();\r
- spec.results_.description = description;\r
- spec.matchersClass = null;\r
-};\r
-\r
-jasmine.Spec.prototype.getFullName = function() {\r
- return this.suite.getFullName() + ' ' + this.description + '.';\r
-};\r
-\r
-\r
-jasmine.Spec.prototype.results = function() {\r
- return this.results_;\r
-};\r
-\r
-/**\r
- * All parameters are pretty-printed and concatenated together, then written to the spec's output.\r
- *\r
- * Be careful not to leave calls to <code>jasmine.log</code> in production code.\r
- */\r
-jasmine.Spec.prototype.log = function() {\r
- return this.results_.log(arguments);\r
-};\r
-\r
-jasmine.Spec.prototype.runs = function (func) {\r
- var block = new jasmine.Block(this.env, func, this);\r
- this.addToQueue(block);\r
- return this;\r
-};\r
-\r
-jasmine.Spec.prototype.addToQueue = function (block) {\r
- if (this.queue.isRunning()) {\r
- this.queue.insertNext(block);\r
- } else {\r
- this.queue.add(block);\r
- }\r
-};\r
-\r
-/**\r
- * @param {jasmine.ExpectationResult} result\r
- */\r
-jasmine.Spec.prototype.addMatcherResult = function(result) {\r
- this.results_.addResult(result);\r
-};\r
-\r
-jasmine.Spec.prototype.expect = function(actual) {\r
- var positive = new (this.getMatchersClass_())(this.env, actual, this);\r
- positive.not = new (this.getMatchersClass_())(this.env, actual, this, true);\r
- return positive;\r
-};\r
-\r
-/**\r
- * Waits a fixed time period before moving to the next block.\r
- *\r
- * @deprecated Use waitsFor() instead\r
- * @param {Number} timeout milliseconds to wait\r
- */\r
-jasmine.Spec.prototype.waits = function(timeout) {\r
- var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this);\r
- this.addToQueue(waitsFunc);\r
- return this;\r
-};\r
-\r
-/**\r
- * Waits for the latchFunction to return true before proceeding to the next block.\r
- *\r
- * @param {Function} latchFunction\r
- * @param {String} optional_timeoutMessage\r
- * @param {Number} optional_timeout\r
- */\r
-jasmine.Spec.prototype.waitsFor = function(latchFunction, optional_timeoutMessage, optional_timeout) {\r
- var latchFunction_ = null;\r
- var optional_timeoutMessage_ = null;\r
- var optional_timeout_ = null;\r
-\r
- for (var i = 0; i < arguments.length; i++) {\r
- var arg = arguments[i];\r
- switch (typeof arg) {\r
- case 'function':\r
- latchFunction_ = arg;\r
- break;\r
- case 'string':\r
- optional_timeoutMessage_ = arg;\r
- break;\r
- case 'number':\r
- optional_timeout_ = arg;\r
- break;\r
- }\r
- }\r
-\r
- var waitsForFunc = new jasmine.WaitsForBlock(this.env, optional_timeout_, latchFunction_, optional_timeoutMessage_, this);\r
- this.addToQueue(waitsForFunc);\r
- return this;\r
-};\r
-\r
-jasmine.Spec.prototype.fail = function (e) {\r
- var expectationResult = new jasmine.ExpectationResult({\r
- passed: false,\r
- message: e ? jasmine.util.formatException(e) : 'Exception',\r
- trace: { stack: e.stack }\r
- });\r
- this.results_.addResult(expectationResult);\r
-};\r
-\r
-jasmine.Spec.prototype.getMatchersClass_ = function() {\r
- return this.matchersClass || this.env.matchersClass;\r
-};\r
-\r
-jasmine.Spec.prototype.addMatchers = function(matchersPrototype) {\r
- var parent = this.getMatchersClass_();\r
- var newMatchersClass = function() {\r
- parent.apply(this, arguments);\r
- };\r
- jasmine.util.inherit(newMatchersClass, parent);\r
- jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass);\r
- this.matchersClass = newMatchersClass;\r
-};\r
-\r
-jasmine.Spec.prototype.finishCallback = function() {\r
- this.env.reporter.reportSpecResults(this);\r
-};\r
-\r
-jasmine.Spec.prototype.finish = function(onComplete) {\r
- this.removeAllSpies();\r
- this.finishCallback();\r
- if (onComplete) {\r
- onComplete();\r
- }\r
-};\r
-\r
-jasmine.Spec.prototype.after = function(doAfter) {\r
- if (this.queue.isRunning()) {\r
- this.queue.add(new jasmine.Block(this.env, doAfter, this), true);\r
- } else {\r
- this.afterCallbacks.unshift(doAfter);\r
- }\r
-};\r
-\r
-jasmine.Spec.prototype.execute = function(onComplete) {\r
- var spec = this;\r
- if (!spec.env.specFilter(spec)) {\r
- spec.results_.skipped = true;\r
- spec.finish(onComplete);\r
- return;\r
- }\r
-\r
- this.env.reporter.reportSpecStarting(this);\r
-\r
- spec.env.currentSpec = spec;\r
-\r
- spec.addBeforesAndAftersToQueue();\r
-\r
- spec.queue.start(function () {\r
- spec.finish(onComplete);\r
- });\r
-};\r
-\r
-jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() {\r
- var runner = this.env.currentRunner();\r
- var i;\r
-\r
- for (var suite = this.suite; suite; suite = suite.parentSuite) {\r
- for (i = 0; i < suite.before_.length; i++) {\r
- this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this));\r
- }\r
- }\r
- for (i = 0; i < runner.before_.length; i++) {\r
- this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this));\r
- }\r
- for (i = 0; i < this.afterCallbacks.length; i++) {\r
- this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this), true);\r
- }\r
- for (suite = this.suite; suite; suite = suite.parentSuite) {\r
- for (i = 0; i < suite.after_.length; i++) {\r
- this.queue.add(new jasmine.Block(this.env, suite.after_[i], this), true);\r
- }\r
- }\r
- for (i = 0; i < runner.after_.length; i++) {\r
- this.queue.add(new jasmine.Block(this.env, runner.after_[i], this), true);\r
- }\r
-};\r
-\r
-jasmine.Spec.prototype.explodes = function() {\r
- throw 'explodes function should not have been called';\r
-};\r
-\r
-jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {\r
- if (obj == jasmine.undefined) {\r
- throw "spyOn could not find an object to spy upon for " + methodName + "()";\r
- }\r
-\r
- if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {\r
- throw methodName + '() method does not exist';\r
- }\r
-\r
- if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {\r
- throw new Error(methodName + ' has already been spied upon');\r
- }\r
-\r
- var spyObj = jasmine.createSpy(methodName);\r
-\r
- this.spies_.push(spyObj);\r
- spyObj.baseObj = obj;\r
- spyObj.methodName = methodName;\r
- spyObj.originalValue = obj[methodName];\r
-\r
- obj[methodName] = spyObj;\r
-\r
- return spyObj;\r
-};\r
-\r
-jasmine.Spec.prototype.removeAllSpies = function() {\r
- for (var i = 0; i < this.spies_.length; i++) {\r
- var spy = this.spies_[i];\r
- spy.baseObj[spy.methodName] = spy.originalValue;\r
- }\r
- this.spies_ = [];\r
-};\r
-\r
-(function () {\r
- var _Spec = jasmine.Spec,\r
- proto = _Spec.prototype;\r
-\r
- jasmine.Spec = function () {\r
- _Spec.apply(this, arguments);\r
- this.fileName = jasmine.getCurrentScript();\r
- this.id = jasmine.hashString(this.getFullName(), this.suite.id);\r
- };\r
-\r
- jasmine.Spec.prototype = proto;\r
-\r
- // Override: adds the error to the result\r
- proto.fail = function (e) {\r
- var expectationResult = new jasmine.ExpectationResult({\r
- passed: false,\r
- message: e ? jasmine.util.formatException(e) : 'Exception'\r
- });\r
- // Modification start\r
- if (e instanceof Error) {\r
- expectationResult.error = e;\r
- }\r
- // Modification end\r
- this.results_.addResult(expectationResult);\r
- };\r
-\r
- proto.execute = function(onComplete) {\r
- var spec = this;\r
- if (!spec.env.specFilter(spec)) {\r
- spec.results_.skipped = true;\r
- onComplete();\r
- return;\r
- }\r
-\r
- this.env.reporter.reportSpecStarting(this);\r
-\r
- if (spec.isDisabled()) {\r
- spec.results_.skipped = true;\r
- spec.finish(onComplete);\r
- return;\r
- }\r
-\r
- spec.env.currentSpec = spec;\r
-\r
- spec.addBeforesAndAftersToQueue();\r
-\r
- if (spec.debugBlocks && jasmine.getOptions().debug === true) {\r
- var blockIdx = jasmine.getOptions().block;\r
- if (typeof blockIdx !== 'undefined') {\r
- blockIdx = parseInt(blockIdx);\r
- var blocks = this.queue.blocks,\r
- length = blocks.length,\r
- i = 0,\r
- block;\r
-\r
- for (; i < length; i++) {\r
- block = blocks[i];\r
- if (i === blockIdx) {\r
- block.func = jasmine.generateDebuggableBlock(block.func);\r
- }\r
- }\r
- }\r
- jasmine.showDebugPrompt(function() {\r
- spec.queue.start(function () {\r
- spec.finish(onComplete);\r
- });\r
- });\r
- } else {\r
- spec.queue.start(function () {\r
- spec.finish(onComplete);\r
- });\r
- }\r
- };\r
-\r
- proto.enabled = true;\r
-\r
- proto.isEnabled = function() {\r
- return this.enabled;\r
- };\r
-\r
- proto.isDisabled = function() {\r
- return !this.enabled;\r
- };\r
-\r
- proto.disable = function() {\r
- this.enabled = false;\r
-\r
- return this;\r
- };\r
-\r
- proto.enable = function() {\r
- this.enabled = true;\r
-\r
- return this;\r
- };\r
-\r
- proto.getRootSuite = function() {\r
- var suite = this.suite;\r
-\r
- while (suite.parentSuite) {\r
- suite = suite.parentSuite;\r
- }\r
-\r
- return suite;\r
- };\r
-})();\r
-\r
-/**\r
- * Works just like waits() and waitsFor(), except waits for the next animationFrame\r
- */\r
-function waitsForAnimation() {\r
- runs(function() {\r
- var done = false;\r
- Ext.Function.requestAnimationFrame(function() {\r
- done = true;\r
- });\r
- waitsFor(function() {\r
- return done;\r
- });\r
- });\r
-}\r
-/**\r
- * Internal representation of a Jasmine suite.\r
- *\r
- * @constructor\r
- * @param {jasmine.Env} env\r
- * @param {String} description\r
- * @param {Function} specDefinitions\r
- * @param {jasmine.Suite} parentSuite\r
- */\r
-jasmine.Suite = function(env, description, specDefinitions, parentSuite) {\r
- var self = this;\r
- self.id = env.nextSuiteId ? env.nextSuiteId() : null;\r
- self.description = description;\r
- self.queue = new jasmine.Queue(env);\r
- self.parentSuite = parentSuite;\r
- self.env = env;\r
- self.before_ = [];\r
- self.after_ = [];\r
- self.children_ = [];\r
- self.suites_ = [];\r
- self.specs_ = [];\r
-};\r
-\r
-jasmine.Suite.prototype.getFullName = function() {\r
- var fullName = this.description;\r
- for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {\r
- fullName = parentSuite.description + ' ' + fullName;\r
- }\r
- return fullName;\r
-};\r
-\r
-jasmine.Suite.prototype.finish = function(onComplete) {\r
- this.env.reporter.reportSuiteResults(this);\r
- this.finished = true;\r
- if (typeof(onComplete) == 'function') {\r
- onComplete();\r
- }\r
-};\r
-\r
-jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) {\r
- beforeEachFunction.typeName = 'beforeEach';\r
- this.before_.unshift(beforeEachFunction);\r
-};\r
-\r
-jasmine.Suite.prototype.afterEach = function(afterEachFunction) {\r
- afterEachFunction.typeName = 'afterEach';\r
- this.after_.unshift(afterEachFunction);\r
-};\r
-\r
-jasmine.Suite.prototype.results = function() {\r
- return this.queue.results();\r
-};\r
-\r
-jasmine.Suite.prototype.add = function(suiteOrSpec) {\r
- this.children_.push(suiteOrSpec);\r
- if (suiteOrSpec instanceof jasmine.Suite) {\r
- this.suites_.push(suiteOrSpec);\r
- this.env.currentRunner().addSuite(suiteOrSpec);\r
- } else {\r
- this.specs_.push(suiteOrSpec);\r
- }\r
- this.queue.add(suiteOrSpec);\r
-};\r
-\r
-jasmine.Suite.prototype.specs = function() {\r
- return this.specs_;\r
-};\r
-\r
-jasmine.Suite.prototype.suites = function() {\r
- return this.suites_;\r
-};\r
-\r
-jasmine.Suite.prototype.children = function() {\r
- return this.children_;\r
-};\r
-\r
-jasmine.Suite.prototype.execute = function(onComplete) {\r
- var self = this;\r
- this.queue.start(function () {\r
- self.finish(onComplete);\r
- });\r
-};\r
-(function () {\r
- var _Suite = jasmine.Suite,\r
- proto = _Suite.prototype;\r
-\r
- jasmine.Suite = function () {\r
- _Suite.apply(this, arguments);\r
-\r
- var parentSuite = this.parentSuite;\r
- this.fileName = jasmine.getCurrentScript();\r
- this.id = jasmine.hashString(this.getFullName(), parentSuite ? parentSuite.id : 0);\r
- };\r
- \r
- jasmine.Suite.prototype = proto;\r
- \r
- proto.execute = function(onComplete) {\r
- var self = this;\r
- self.env.reporter.reportSuiteStarting(self); // override\r
-\r
- if (self.isDisabled()) {\r
- self.results = self.forceSkippedResults;\r
- self.disableChildren();\r
- }\r
-\r
- this.queue.start(function () {\r
- self.finish(onComplete);\r
- });\r
- };\r
-\r
- proto.enabled = true;\r
-\r
- proto.isEnabled = function() {\r
- return this.enabled;\r
- };\r
-\r
- proto.isDisabled = function() {\r
- return !this.enabled;\r
- };\r
-\r
- proto.disable = function() {\r
- this.enabled = false;\r
- return this;\r
- };\r
-\r
- proto.enable = function() {\r
- this.enabled = true;\r
- return this;\r
- };\r
-\r
- proto.forceSkippedResults = function() {\r
- var results = this.queue.results();\r
- results.skipped = true;\r
- return results;\r
- };\r
-\r
- proto.disableChildren = function() {\r
- var children = this.children(),\r
- length = children.length,\r
- i = 0;\r
-\r
- for (; i < length; i++) {\r
- children[i].disable();\r
- }\r
-\r
- return this;\r
- };\r
-\r
- proto.filter = function (suiteIds, specIds) {\r
-\r
- if (!suiteIds[this.id]) {\r
- var specs = this.specs(),\r
- suites = this.suites(),\r
- spec, i, suite, length;\r
-\r
- length = specs.length;\r
-\r
- for (i = 0; i < length; i++) {\r
- spec = specs[i];\r
- if (!specIds[spec.id]) {\r
- jasmine.array.remove(this.queue.blocks, spec);\r
- }\r
- }\r
-\r
- length = suites.length;\r
-\r
- for (i = 0; i < length; i++) {\r
- suite = suites[i];\r
- suite.filter(suiteIds, specIds);\r
- if (suite.empty) {\r
- jasmine.array.remove(this.queue.blocks, suite);\r
- }\r
- }\r
-\r
- if (this.queue.blocks.length === 0) {\r
- this.empty = true;\r
- }\r
- }\r
-\r
- return this;\r
- };\r
-\r
- proto.getRootSuite = function() {\r
- var suite = this;\r
-\r
- while (suite.parentSuite) {\r
- suite = suite.parentSuite;\r
- }\r
-\r
- return suite;\r
- };\r
-\r
-})();\r
-jasmine.WaitsBlock = function(env, timeout, spec) {\r
- this.timeout = timeout;\r
- jasmine.Block.call(this, env, null, spec);\r
-};\r
-\r
-jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block);\r
-\r
-jasmine.WaitsBlock.prototype.execute = function (onComplete) {\r
- if (jasmine.VERBOSE) {\r
- this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...');\r
- }\r
- this.env.setTimeout(function () {\r
- onComplete();\r
- }, this.timeout);\r
-};\r
-/**\r
- * A block which waits for some condition to become true, with timeout.\r
- *\r
- * @constructor\r
- * @extends jasmine.Block\r
- * @param {jasmine.Env} env The Jasmine environment.\r
- * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true.\r
- * @param {Function} latchFunction A function which returns true when the desired condition has been met.\r
- * @param {String} message The message to display if the desired condition hasn't been met within the given time period.\r
- * @param {jasmine.Spec} spec The Jasmine spec.\r
- */\r
-jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) {\r
- this.timeout = timeout || env.defaultTimeoutInterval;\r
- this.latchFunction = latchFunction;\r
- this.message = message;\r
- this.totalTimeSpentWaitingForLatch = 0;\r
- jasmine.Block.call(this, env, null, spec);\r
-};\r
-jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block);\r
-\r
-jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 10;\r
-\r
-jasmine.WaitsForBlock.prototype.execute = function(onComplete) {\r
- if (jasmine.VERBOSE) {\r
- this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));\r
- }\r
- var latchFunctionResult;\r
- try {\r
- latchFunctionResult = this.latchFunction.apply(this.spec);\r
- } catch (e) {\r
- this.spec.fail(e);\r
- onComplete();\r
- return;\r
- }\r
-\r
- if (latchFunctionResult) {\r
- onComplete();\r
- } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) {\r
- var message = 'timed out after ' + this.timeout + ' msec waiting for ' + (this.message || 'something to happen');\r
- this.spec.fail({\r
- name: 'timeout',\r
- message: message\r
- });\r
-\r
- this.abort = true;\r
- onComplete();\r
- } else {\r
- this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;\r
- var self = this;\r
- this.env.setTimeout(function() {\r
- self.execute(onComplete);\r
- }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);\r
- }\r
-};\r
-// Mock setTimeout, clearTimeout\r
-// Contributed by Pivotal Computer Systems, www.pivotalsf.com\r
-\r
-jasmine.FakeTimer = function() {\r
- this.reset();\r
-\r
- var self = this;\r
- self.setTimeout = function(funcToCall, millis) {\r
- self.timeoutsMade++;\r
- self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);\r
- return self.timeoutsMade;\r
- };\r
-\r
- self.setInterval = function(funcToCall, millis) {\r
- self.timeoutsMade++;\r
- self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);\r
- return self.timeoutsMade;\r
- };\r
-\r
- self.clearTimeout = function(timeoutKey) {\r
- self.scheduledFunctions[timeoutKey] = jasmine.undefined;\r
- };\r
-\r
- self.clearInterval = function(timeoutKey) {\r
- self.scheduledFunctions[timeoutKey] = jasmine.undefined;\r
- };\r
-\r
-};\r
-\r
-jasmine.FakeTimer.prototype.reset = function() {\r
- this.timeoutsMade = 0;\r
- this.scheduledFunctions = {};\r
- this.nowMillis = 0;\r
-};\r
-\r
-jasmine.FakeTimer.prototype.tick = function(millis) {\r
- var oldMillis = this.nowMillis;\r
- var newMillis = oldMillis + millis;\r
- this.runFunctionsWithinRange(oldMillis, newMillis);\r
- this.nowMillis = newMillis;\r
-};\r
-\r
-jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {\r
- var scheduledFunc;\r
- var funcsToRun = [];\r
- for (var timeoutKey in this.scheduledFunctions) {\r
- scheduledFunc = this.scheduledFunctions[timeoutKey];\r
- if (scheduledFunc != jasmine.undefined &&\r
- scheduledFunc.runAtMillis >= oldMillis &&\r
- scheduledFunc.runAtMillis <= nowMillis) {\r
- funcsToRun.push(scheduledFunc);\r
- this.scheduledFunctions[timeoutKey] = jasmine.undefined;\r
- }\r
- }\r
-\r
- if (funcsToRun.length > 0) {\r
- funcsToRun.sort(function(a, b) {\r
- return a.runAtMillis - b.runAtMillis;\r
- });\r
- for (var i = 0; i < funcsToRun.length; ++i) {\r
- try {\r
- var funcToRun = funcsToRun[i];\r
- this.nowMillis = funcToRun.runAtMillis;\r
- funcToRun.funcToCall();\r
- if (funcToRun.recurring) {\r
- this.scheduleFunction(funcToRun.timeoutKey,\r
- funcToRun.funcToCall,\r
- funcToRun.millis,\r
- true);\r
- }\r
- } catch(e) {\r
- }\r
- }\r
- this.runFunctionsWithinRange(oldMillis, nowMillis);\r
- }\r
-};\r
-\r
-jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {\r
- this.scheduledFunctions[timeoutKey] = {\r
- runAtMillis: this.nowMillis + millis,\r
- funcToCall: funcToCall,\r
- recurring: recurring,\r
- timeoutKey: timeoutKey,\r
- millis: millis\r
- };\r
-};\r
-\r
-/**\r
- * @namespace\r
- */\r
-jasmine.Clock = {\r
- defaultFakeTimer: new jasmine.FakeTimer(),\r
-\r
- reset: function() {\r
- jasmine.Clock.assertInstalled();\r
- jasmine.Clock.defaultFakeTimer.reset();\r
- },\r
-\r
- tick: function(millis) {\r
- jasmine.Clock.assertInstalled();\r
- jasmine.Clock.defaultFakeTimer.tick(millis);\r
- },\r
-\r
- runFunctionsWithinRange: function(oldMillis, nowMillis) {\r
- jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);\r
- },\r
-\r
- scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {\r
- jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);\r
- },\r
-\r
- useMock: function() {\r
- if (!jasmine.Clock.isInstalled()) {\r
- var spec = jasmine.getEnv().currentSpec;\r
- spec.after(jasmine.Clock.uninstallMock);\r
-\r
- jasmine.Clock.installMock();\r
- }\r
- },\r
-\r
- installMock: function() {\r
- jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;\r
- },\r
-\r
- uninstallMock: function() {\r
- jasmine.Clock.assertInstalled();\r
- jasmine.Clock.installed = jasmine.Clock.real;\r
- },\r
-\r
- real: {\r
- setTimeout: jasmine.getGlobal().setTimeout,\r
- clearTimeout: jasmine.getGlobal().clearTimeout,\r
- setInterval: jasmine.getGlobal().setInterval,\r
- clearInterval: jasmine.getGlobal().clearInterval\r
- },\r
-\r
- assertInstalled: function() {\r
- if (!jasmine.Clock.isInstalled()) {\r
- throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");\r
- }\r
- },\r
-\r
- isInstalled: function() {\r
- return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;\r
- },\r
-\r
- installed: null\r
-};\r
-jasmine.Clock.installed = jasmine.Clock.real;\r
-\r
-//else for IE support\r
-jasmine.getGlobal().setTimeout = function(funcToCall, millis) {\r
- if (jasmine.Clock.installed.setTimeout.apply) {\r
- return jasmine.Clock.installed.setTimeout.apply(this, arguments);\r
- } else {\r
- return jasmine.Clock.installed.setTimeout(funcToCall, millis);\r
- }\r
-};\r
-\r
-jasmine.getGlobal().setInterval = function(funcToCall, millis) {\r
- if (jasmine.Clock.installed.setInterval.apply) {\r
- return jasmine.Clock.installed.setInterval.apply(this, arguments);\r
- } else {\r
- return jasmine.Clock.installed.setInterval(funcToCall, millis);\r
- }\r
-};\r
-\r
-jasmine.getGlobal().clearTimeout = function(timeoutKey) {\r
- if (jasmine.Clock.installed.clearTimeout.apply) {\r
- return jasmine.Clock.installed.clearTimeout.apply(this, arguments);\r
- } else {\r
- return jasmine.Clock.installed.clearTimeout(timeoutKey);\r
- }\r
-};\r
-\r
-jasmine.getGlobal().clearInterval = function(timeoutKey) {\r
- if (jasmine.Clock.installed.clearTimeout.apply) {\r
- return jasmine.Clock.installed.clearInterval.apply(this, arguments);\r
- } else {\r
- return jasmine.Clock.installed.clearInterval(timeoutKey);\r
- }\r
-};\r
-\r
-/**\r
- * Utility function to fire a fake mouse event to a given target element\r
- */\r
-jasmine.fireMouseEvent = function (target, type, x, y, button) {\r
- var e,\r
- doc,\r
- docEl,\r
- body,\r
- ret;\r
- \r
- target = Ext.getDom(target);\r
- doc = target.ownerDocument || document;\r
- x = x || 0;\r
- y = y || 0;\r
- \r
- if (doc.createEventObject){ // IE event model\r
- e = doc.createEventObject();\r
- docEl = doc.documentElement;\r
- body = doc.body;\r
- x = x + (docEl && docEl.clientLeft || 0) + (body && body.clientLeft || 0);\r
- y = y + (docEl && docEl.clientTop || 0) + (body && body.clientLeft || 0);\r
- Ext.apply(e, {\r
- bubbles: true,\r
- cancelable: true,\r
- screenX: x,\r
- screenY: y,\r
- clientX: x,\r
- clientY: y,\r
- button: button || 1\r
- });\r
- ret = target.fireEvent('on' + type, e);\r
- } else {\r
- e = doc.createEvent("MouseEvents");\r
- e.initMouseEvent(type, true, true, doc.defaultView || doc.parentWindow, 1, x, y, x, y, false, false, false, false, button || 0, null);\r
- ret = target.dispatchEvent(e);\r
- }\r
- \r
- return (ret === false ? ret : e);\r
-};\r
-\r
-/**\r
- * Fires a pointer event. Since PointerEvents cannot yet be directly constructed,\r
- * we fake it by constructing a mouse event and setting its pointer id. This method\r
- * should typically be used when (Ext.supports.PointerEvents || Ext.supports.MSPointerEvents).\r
- * @param {String/Ext.Element/HTMLElement} target\r
- * @param {String} type The name of the event to fire\r
- * @param {Number} pointerId A unique id for the pointer, for more on pointerId see\r
- * http://www.w3.org/TR/pointerevents/\r
- * @param {Number} x The x coordinate\r
- * @param {Number} y The y coordinate\r
- * @param {Number} button\r
- * @return {Boolean} true if the event was successfully dispatched\r
- */\r
-jasmine.firePointerEvent = function(target, type, pointerId, x, y, button) {\r
- var doc = document,\r
- e = doc.createEvent("MouseEvents"),\r
- target = Ext.getDom(target),\r
- dispatched;\r
-\r
- e.initMouseEvent(\r
- type, // type\r
- true, // canBubble\r
- true, // cancelable\r
- doc.defaultView || doc.parentWindow, // view\r
- 1, // detail\r
- x, // screenX\r
- y, // screenY\r
- x, // clientX\r
- y, // clientY\r
- false, // ctrlKey\r
- false, // altKey\r
- false, // shiftKey\r
- false, // metaKey\r
- button || 0, // button\r
- null // relatedTarget\r
- );\r
- e.pointerId = pointerId || 1;\r
- target.setPointerCapture = Ext.emptyFn;\r
-\r
- dispatched = target.dispatchEvent(e);\r
-\r
- delete target.setPointerCapture;\r
-\r
- return dispatched;\r
-};\r
-\r
-jasmine.createTouchList = function(touchList, target) {\r
- var doc = document,\r
- i = 0,\r
- ln = touchList.length,\r
- touches = [],\r
- touchCfg;\r
-\r
- for (; i < ln; i++) {\r
- touchCfg = touchList[i];\r
- touches.push(doc.createTouch(\r
- doc.defaultView || doc.parentWindow,\r
- touchCfg.target || target,\r
- // use 1 as the default ID, so that tests that are only concerned with a single\r
- // touch event don't need to worry about providing an ID\r
- touchCfg.identifier || 1,\r
- touchCfg.pageX,\r
- touchCfg.pageY,\r
- touchCfg.screenX || touchCfg.pageX, // use pageX/Y as the default for screenXY\r
- touchCfg.screenY || touchCfg.pageY\r
- ));\r
- }\r
-\r
- return doc.createTouchList.apply(doc, touches);\r
-};\r
-\r
-/**\r
- * Utility for emulating a touch event. This method should typically only be used when\r
- * Ext.supports.TouchEvents. Recommended reading for understanding how touch events work:\r
- * http://www.w3.org/TR/touch-events/\r
- * @param {String/Ext.Element/HTMLElement} target\r
- * @param {String} type The name of the event to fire\r
- * @param {Object[]} touches An array of config objects for constructing the event object's\r
- * "touches". The config objects conform to the following interface:\r
- * http://www.w3.org/TR/touch-events/#idl-def-Touch The only required properties\r
- * are pageX and pageY. this method provides defaults for the others.\r
- * @param {Object[]} changedTouches An array of config objects for constructing the event\r
- * object's "changedTouches" (defaults to the same value as the `touches` param)\r
- * @param {Object[]} targetTouches An array of config objects for constructing the event\r
- * object's "targetTouches" (defaults to the same value as the `touches` param)\r
- * @param {Number} scale\r
- * @param {Number} rotation\r
- * @return {Boolean} true if the event was successfully dispatched\r
- */\r
-jasmine.fireTouchEvent = function(target, type, touches, changedTouches, targetTouches) {\r
- var doc = document,\r
- // Couldn't figure out how to set touches, changedTouches targetTouches on a "real"\r
- // TouchEvent, initTouchEvent seems to ignore the parameters documented here:\r
- // https://developer.apple.com/library/safari/documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.htmlTouchLists\r
- // Apparently directly assigning to e.touches after creating a TouchEvent doesn't\r
- // work either so the best we can do is just make a CustomEvent and fake it.\r
- e = new CustomEvent(type, {\r
- bubbles: true,\r
- cancelable: true\r
- }),\r
- target = Ext.getDom(target);\r
-\r
- Ext.apply(e, {\r
- target: target,\r
- touches: jasmine.createTouchList(touches, target),\r
- changedTouches: jasmine.createTouchList(changedTouches ? changedTouches : touches, target),\r
- targetTouches: jasmine.createTouchList(targetTouches ? targetTouches : touches, target)\r
- });\r
-\r
- return target.dispatchEvent(e);\r
-};\r
-\r
-/**\r
- * Utility function to fire a fake key event to a given target element\r
- */\r
-jasmine.fireKeyEvent = function(target, type, key) {\r
- var e,\r
- doc;\r
- target = Ext.getDom(target);\r
- doc = target.ownerDocument || document;\r
- if (doc.createEventObject) { //IE event model\r
- e = doc.createEventObject();\r
- Ext.apply(e, {\r
- bubbles: true,\r
- cancelable: true,\r
- keyCode: key\r
- });\r
- return target.fireEvent('on' + type, e);\r
- } else {\r
- e = doc.createEvent("Events");\r
- e.initEvent(type, true, true);\r
- e.keyCode = key;\r
- return target.dispatchEvent(e);\r
- }\r
-};\r
-\r
-/*\r
-This version is commented out because there is a bug in WebKit that prevents\r
-key events to be fired with both options and a valid keycode. When the bug gets fixed\r
-this method can be reintroduced. See https://bugs.webkit.org/show_bug.cgi?id=16735\r
-jasmine.fireKeyEvent = function(target, type, key, options) {\r
- var e, ret, prop;\r
- \r
- options = options || {};\r
- target = Ext.getDom(target);\r
- if (document.createEventObject) { //IE event model\r
- e = document.createEventObject();\r
- Ext.apply(e, {\r
- bubbles: true,\r
- cancelable: true,\r
- keyCode: key\r
- });\r
- if (options) {\r
- for (prop in options) {\r
- if (options.hasOwnProperty(prop)) {\r
- e[prop] = options[prop];\r
- }\r
- }\r
- }\r
- return target.fireEvent('on' + type, e);\r
- }\r
- else {\r
- e = document.createEvent('KeyboardEvent');\r
- if (typeof e.initKeyboardEvent != 'undefined') {\r
- e.initKeyboardEvent(type, true, true, window,\r
- false,\r
- false,\r
- false,\r
- false, 97, 97);\r
- } else {\r
- e.initKeyEvent(type, true, true, window,\r
- options.ctrlKey || false,\r
- options.altKey || false,\r
- options.shiftKey || false,\r
- options.metaKey || false, key, key);\r
- }\r
- return target.dispatchEvent(e);\r
- }\r
-};\r
-*/\r
-var fakeScope = {\r
- id: "fakeScope",\r
- fakeScope: true\r
-};\r
-/**\r
- * Class to act as a bridge between the MockAjax class and Ext.data.Connection\r
- */\r
-var MockAjaxManager = {\r
- \r
- getXhrInstance: null,\r
- \r
- /**\r
- * Pushes methods onto the Connection prototype to make it easier to deal with\r
- */\r
- addMethods: function(){\r
- var Connection = Ext.data.Connection,\r
- proto = Connection.prototype;\r
- \r
- Connection.requestId = 0;\r
- MockAjaxManager.getXhrInstance = proto.getXhrInstance;\r
- \r
- /**\r
- * Template method to create the AJAX request\r
- */\r
- proto.getXhrInstance = function(){\r
- return new MockAjax(); \r
- };\r
- \r
- /**\r
- * Method to simulate a request completing\r
- * @param {Object} response The response\r
- * @param {String} id (optional) The id of the completed request\r
- */\r
- proto.mockComplete = function(response, id){\r
- this.mockGetRequestXHR(id).xhr.complete(response);\r
- };\r
- \r
- /**\r
- * Get a particular request\r
- * @param {String} id (optional) The id of the request\r
- */\r
- proto.mockGetRequestXHR = function(id){\r
- var request;\r
- \r
- if (id) {\r
- request = this.requests[id];\r
- } else {\r
- // get the first one\r
- request = this.mockGetAllRequests()[0];\r
- }\r
- return request ? request : null;\r
- };\r
- \r
- /**\r
- * Gets all the requests from the Connection\r
- */\r
- proto.mockGetAllRequests = function(){\r
- var requests = this.requests,\r
- id,\r
- request,\r
- out = [];\r
- \r
- for (id in requests) {\r
- if (requests.hasOwnProperty(id)) {\r
- out.push(requests[id]);\r
- }\r
- }\r
- return out;\r
- };\r
-\r
- this.originalExtAjax = Ext.Ajax;\r
- Ext.Ajax = new Connection({autoAbort : false});\r
- },\r
- \r
- /**\r
- * Restore any changes made by addMethods\r
- */\r
- removeMethods: function(){\r
- var proto = Ext.data.Connection.prototype;\r
- delete proto.mockComplete;\r
- delete proto.mockGetRequestXHR;\r
- proto.getXhrInstance = MockAjaxManager.getXhrInstance;\r
- Ext.Ajax = this.originalExtAjax;\r
- }\r
-};\r
-\r
-/**\r
- * Simple Mock class to represent an XMLHttpRequest\r
- */\r
-var MockAjax = function(){\r
- /**\r
- * Contains all request headers\r
- */\r
- this.headers = {};\r
- \r
- /**\r
- * Contains any options specified during sending\r
- */\r
- this.ajaxOptions = {};\r
- \r
- this.readyState = 0;\r
- \r
- this.status = null;\r
- \r
- this.responseText = this.responseXML = null;\r
-};\r
-\r
-/**\r
- * Contains a default response for any synchronous request.\r
- */\r
-MockAjax.prototype.syncDefaults = {\r
- responseText: 'data',\r
- status: 200,\r
- statusText: '',\r
- responseXML: null,\r
- responseHeaders: {"Content-type": "application/json" }\r
-};\r
-\r
-MockAjax.prototype.readyChange = function() {\r
- if (this.onreadystatechange) {\r
- this.onreadystatechange();\r
- }\r
-};\r
-\r
-/**\r
- * Simulate the XHR open method\r
- * @param {Object} method\r
- * @param {Object} url\r
- * @param {Object} async\r
- * @param {Object} username\r
- * @param {Object} password\r
- */\r
-MockAjax.prototype.open = function(method, url, async, username, password){\r
- var options = this.ajaxOptions;\r
- options.method = method;\r
- options.url = url;\r
- options.async = async;\r
- options.username = username;\r
- options.password = password;\r
- this.readyState = 1;\r
- this.readyChange();\r
-};\r
-\r
-/**\r
- * Simulate the XHR send method\r
- * @param {Object} data\r
- */\r
-MockAjax.prototype.send = function(data){\r
- this.ajaxOptions.data = data;\r
- this.readyState = 2;\r
- // if it's a synchronous request, let's just assume it's already finished\r
- if (!this.ajaxOptions.async) {\r
- this.complete(this.syncDefaults);\r
- } else {\r
- this.readyChange();\r
- }\r
-};\r
-\r
-/**\r
- * Simulate the XHR abort method\r
- */\r
-MockAjax.prototype.abort = function(){\r
- this.readyState = 0;\r
- this.readyChange();\r
-};\r
-\r
-/**\r
- * Simulate the XHR setRequestHeader method\r
- * @param {Object} header\r
- * @param {Object} value\r
- */\r
-MockAjax.prototype.setRequestHeader = function(header, value){\r
- this.headers[header] = value;\r
-};\r
-\r
-/**\r
- * Simulate the XHR getAllResponseHeaders method\r
- */\r
-MockAjax.prototype.getAllResponseHeaders = function(){\r
- return '';\r
-};\r
-\r
-/**\r
- * Simulate the XHR getResponseHeader method\r
- * @param {Object} name\r
- */\r
-MockAjax.prototype.getResponseHeader = function(name){\r
- return this.headers[header];\r
-};\r
-\r
-/**\r
- * Simulate the XHR onreadystatechange method\r
- */\r
-MockAjax.prototype.onreadystatechange = function(){\r
-};\r
-\r
-/**\r
- * Method for triggering a response completion\r
- */\r
-MockAjax.prototype.complete = function(response){\r
- this.responseText = response.responseText || '';\r
- this.status = response.status;\r
- this.statusText = response.statusText;\r
- this.responseXML = response.responseXML || this.xmlDOM(response.responseText);\r
- this.responseHeaders = response.responseHeaders || {"Content-type": response.contentType || "application/json" };\r
- this.readyState = 4;\r
- this.readyChange();\r
-};\r
-\r
-/**\r
- * Converts string to XML DOM\r
- */\r
-MockAjax.prototype.xmlDOM = function(xml) {\r
- // IE DOMParser support\r
- if (!window.DOMParser && window.ActiveXObject) {\r
- doc = new ActiveXObject('Microsoft.XMLDOM');\r
- doc.async = 'false';\r
- DOMParser = function() {};\r
- DOMParser.prototype.parseFromString = function(xmlString) {\r
- var doc = new ActiveXObject('Microsoft.XMLDOM');\r
- doc.async = 'false';\r
- doc.loadXML(xmlString);\r
- return doc;\r
- };\r
- } \r
-\r
- try {\r
- return (new DOMParser()).parseFromString(xml, "text/xml");\r
- } catch (e) {\r
- return null;\r
- }\r
-};\r
-SenchaTestRunner = {\r
- allowedGlobals: {},\r
- \r
- specTimeout: 10 * 1000, // 10 secs\r
-\r
- isRunning: function() {\r
- if (!this.reporter) {\r
- return false;\r
- }\r
- \r
- var isRunning = this.reporter.isRunning,\r
- currentSpec = jasmine.getEnv().currentSpec,\r
- testResult = currentSpec._testResult;\r
- \r
- if (!isRunning || !currentSpec) {\r
- return isRunning;\r
- }\r
- \r
- if (jasmine.getOptions().debug !== true && testResult) {\r
- var duration = (new Date).getTime() - parseInt(testResult.startTime);\r
- if (duration > this.specTimeout) {\r
- throw new Error ("The spec '" + currentSpec.getFullName() + "' is taking more than " + (this.specTimeout/1000) + " seconds to complete.");\r
- }\r
- }\r
-\r
- this.currentSpec = currentSpec;\r
- \r
- return isRunning;\r
- \r
- },\r
-\r
- /**\r
- * initializes the allowed globals object with all the propeties in the current\r
- * window. Should be called after frameworks are loaded but before specs are loaded.\r
- */\r
- initGlobals: function() {\r
- var me = this,\r
- allowedGlobals = me.allowedGlobals,\r
- prop;\r
-\r
- for (prop in window) {\r
- allowedGlobals[prop] = true;\r
- }\r
-\r
- // Old Firefox needs these\r
- allowedGlobals.getInterface =\r
- allowedGlobals.loadFirebugConsole =\r
- allowedGlobals._createFirebugConsole =\r
- allowedGlobals.netscape = \r
- allowedGlobals.XPCSafeJSObjectWrapper =\r
- allowedGlobals.XPCNativeWrapper =\r
- allowedGlobals.Components =\r
- allowedGlobals._firebug =\r
- // IE10 F12 dev tools adds this property when opened.\r
- allowedGlobals.__IE_DEVTOOLBAR_CONSOLE_COMMAND_LINE =\r
- // we're going to add the addGlobal function to the window object, so specs can call it\r
- allowedGlobals.addGlobal = true;\r
- allowedGlobals.id = true; // In Ext JS 4 Ext.get(window) adds an id property\r
-\r
- window.addGlobal = function() {\r
- me.addGlobal.apply(me, arguments);\r
- };\r
- },\r
-\r
- /**\r
- * Add an allowed global variable.\r
- * @param {String/Array} property The variable name, or array of names\r
- */\r
- addGlobal: function(property) {\r
- var len;\r
-\r
- if (property.charAt) { // string\r
- this.allowedGlobals[property] = true;\r
- } else { // array\r
- for (len = property.length; len--;) {\r
- this.allowedGlobals[property[len]] = true;\r
- }\r
- }\r
- },\r
-\r
- checkGlobals: function(spec) {\r
- var allowedGlobals = this.allowedGlobals,\r
- property, value;\r
- \r
- for (property in window) {\r
- value = window[property];\r
- if (value !== undefined && !allowedGlobals[property] &&\r
- (!value || // make sure we don't try to do a property lookup on a null value\r
- // old browsers (IE6 and opera 11) add element IDs as enumerable properties\r
- // of the window object, so make sure the global var is not a HTMLElement\r
- value.nodeType !== 1 &&\r
- // make sure it isn't a reference to a window object. This happens in\r
- // some browsers (e.g. IE6) when the document contains iframes. The\r
- // frames' window objects are referenced by id in the parent window object.\r
- !(value.location && value.document))) {\r
- spec.fail('Bad global variable: ' + property + ' = ' + value);\r
- allowedGlobals[property] = true;\r
- }\r
- } \r
- },\r
- \r
- results : [],\r
- \r
- Reporter : function() { \r
- var me = this;\r
- // some browsers add an empty text node in the document.body. This ensures\r
- // we start with an emtpy body\r
- document.body.innerHTML = '';\r
- me.suites = {};\r
- me.results = {\r
- startTime: null,\r
- endTime: null,\r
- failures: 0,\r
- suitesCount: 0,\r
- specsCount: 0,\r
- suites: []\r
- };\r
- SenchaTestRunner.reporter = this;\r
- }\r
-};\r
-\r
-\r
-SenchaTestRunner.Reporter.prototype = {\r
- initContextMapping: function() {\r
-// var xhr = new jasmine.XmlHttpRequest();\r
-// window.alert(SenchaTestRunner.testArtifactServerURL + "context-directory-mapping");\r
-// xhr.open("GET", SenchaTestRunner.testArtifactServerURL + "context-directory-mapping", false);\r
-// xhr.send(null);\r
-// if (xhr.status === 200) {\r
-// jasmine.contextMapping = JSON.parse(xhr.responseText);\r
-// } else {\r
-// jasmine.contextMapping = null;\r
-// }\r
- },\r
- \r
- reportRunnerStarting: function() {\r
- this.initContextMapping();\r
- this.isRunning = true;\r
- },\r
- \r
- reportRunnerResults: function() {\r
- this.isRunning = false;\r
- Ext.cmd.api.adapter.onTestsDone();\r
- },\r
- \r
- extractRe: /((http:\/\/|file:\/\/\/).*\.js)[^:]*:(\d*)/,\r
-\r
- extractFileAndLine: function(line) {\r
- var result = line.match(this.extractRe);\r
-\r
- if (!result) {\r
- return null;\r
- }\r
-\r
- return {\r
- fileName : result[1],\r
- lineNumber : parseInt(result[3], 10)\r
- };\r
- },\r
- \r
- extractStackTrace: function(error) {\r
- var stack = error.stack || error.stackTrace,\r
- results = [],\r
- lines, line, length, i, extract, fileName, lineNumber;\r
-\r
- if (stack) {\r
- lines = stack.split("\n");\r
- length = lines.length;\r
- for (i = 0; i < length; i++) {\r
- line = lines[i];\r
- if (line.search(jasmine.util.getOrigin() + "/jasmine.js") === -1) {\r
- extract = this.extractFileAndLine(line);\r
- if (extract) {\r
- results.push(extract);\r
- }\r
- }\r
- }\r
- } else {\r
- fileName = error.sourceURL || error.fileName;\r
- lineNumber = error.line || error.lineNumber;\r
-\r
- if (fileName && lineNumber) {\r
- results.push({\r
- fileName : fileName,\r
- lineNumber : lineNumber\r
- });\r
- }\r
- }\r
- return results;\r
- },\r
- \r
- filterRe: /\n|\t|\r|\v|'|"|="|=/g,\r
- \r
- filterChars: function(string) {\r
- return jasmine.util.htmlEscape(string).replace(this.filterRe, ' ');\r
- },\r
-\r
- reportSpecStarting: function(spec) {\r
- var me = this,\r
- testResult = {\r
- startTime: (new Date).getTime()\r
- };\r
-\r
- spec.startTime = (new Date).getTime();\r
- spec._testResult = testResult;\r
- },\r
-\r
- reportSpecResults: function(spec) {\r
- var blocksArray = [],\r
- blocks = spec.queue.blocks,\r
- block,\r
- results, \r
- result, \r
- length, \r
- i, \r
- expectation,\r
- testResult = spec._testResult,\r
- suiteTestResult = spec.suite && spec.suite._testResult;\r
-\r
- this.checkForCleanup(spec);\r
-\r
- testResult.description = this.filterChars(spec.description);\r
- testResult.hash = '' + spec.id;\r
- testResult.fileName = spec.fileName;\r
- testResult.expectations = [];\r
- testResult.duration = (new Date).getTime() - testResult.startTime;\r
- testResult.passed = spec.results().passed();\r
-\r
- if (!testResult.passed) {\r
- if(suiteTestResult) {\r
- suiteTestResult.failures++;\r
- suiteTestResult.passed = false;\r
- }\r
- }\r
-\r
- results = spec.results().getItems();\r
-\r
- length = results.length;\r
- for (i = 0; i < length; i++) {\r
- result = results[i];\r
-\r
- if (result.type === 'expect') {\r
-\r
- expectation = {\r
- description: result.message\r
- };\r
-\r
- if (!result.passed() && result.error) {\r
- expectation.stackTrace = this.extractStackTrace(result.error);\r
- } \r
-\r
- if (result.passed()) {\r
- expectation.passed = true;\r
- } else {\r
- expectation.passed = false;\r
- }\r
-\r
- testResult.expectations.push(expectation);\r
- }\r
- }\r
-\r
- length = blocks.length;\r
- i = 0;\r
- for (; i < length; i++) {\r
- block = blocks[i];\r
- if (block.func && block.func.typeName) {\r
- blocksArray.push({\r
- idx: i,\r
- fn: block.func.toString(),\r
- typeName: block.func.typeName\r
- });\r
- }\r
- }\r
-\r
- testResult.blocks = blocksArray;\r
- Ext.cmd.api.adapter.onTestResult(testResult);\r
- delete spec._testResult;\r
- },\r
- \r
- reportSuiteStarting: function(suite) {\r
- var testResult = {\r
- startTime: (new Date).getTime(),\r
- failures: 0,\r
- passed: true\r
- };\r
- \r
- suite._testResult = testResult;\r
- },\r
- \r
- reportSuiteResults: function(suite) {\r
- var testResult = suite._testResult,\r
- parentTestResult = suite.parentSuite && suite.parentSuite._testResult;\r
-\r
- testResult.description = this.filterChars(suite.description);\r
- testResult.hash = '' + suite.id;\r
- testResult.duration = (new Date).getTime() - testResult.startTime;\r
- \r
- if (parentTestResult) {\r
- parentTestResult.failures += testResult.failures;\r
- if (!testResult.passed) {\r
- parentTestResult.passed = false;\r
- }\r
- }\r
-\r
- Ext.cmd.api.adapter.onTestResult(testResult);\r
- delete suite._testResult;\r
- },\r
-\r
- checkDom: function(spec) {\r
- var body = document.body,\r
- children = body && body.childNodes || [],\r
- len = children.length,\r
- badNodes = [],\r
- i = 0;\r
-\r
- for (; i < len; i++) {\r
- if (children[i].nodeType === 3 || !children[i].getAttribute('data-sticky')) {\r
- badNodes.push(children[i]);\r
- }\r
- }\r
-\r
- for (i = 0, len = badNodes.length; i < len; i++) {\r
- document.body.removeChild(badNodes[i]);\r
- }\r
-\r
- if (badNodes.length) {\r
- spec.fail('document.body contains childNodes after spec execution');\r
- }\r
- },\r
-\r
- checkForCleanup: function(spec) {\r
- this.checkDom(spec);\r
- SenchaTestRunner.checkGlobals(spec);\r
- }\r
-};\r
-\r
-// The initGlobals() method adds all currently enumerable window properties to a list of\r
-// allowed globals. It needs to be called after Ext and jasmine are loaded, but before any\r
-// of the spec files are executed. This ensures that bad globals defined in the spec\r
-// files do not get added to the list of allowed globals.\r
-\r
-\r
-\r
-SenchaTestRunner.initGlobals();\r
+var isCommonJS = typeof window == "undefined" && typeof exports == "object";
+
+/**
+ * Top level namespace for Jasmine, a lightweight JavaScript BDD/spec/testing framework.
+ *
+ * @namespace
+ */
+var jasmine = {};
+if (isCommonJS) exports.jasmine = jasmine;
+/**
+ * @private
+ */
+jasmine.unimplementedMethod_ = function() {
+ throw new Error("unimplemented method");
+};
+
+/**
+ * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just
+ * a plain old variable and may be redefined by somebody else.
+ *
+ * @private
+ */
+jasmine.undefined = jasmine.___undefined___;
+
+/**
+ * Show diagnostic messages in the console if set to true
+ *
+ */
+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;
+
+/**
+ * Maximum levels of nesting that will be included when an object is pretty-printed
+ */
+jasmine.MAX_PRETTY_PRINT_DEPTH = 40;
+
+/**
+ * Default timeout interval in milliseconds for waitsFor() blocks.
+ */
+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.getGlobal = function() {
+ function getGlobal() {
+ return this;
+ }
+
+ return getGlobal();
+};
+
+/**
+ * Allows for bound functions to be compared. Internal use only.
+ *
+ * @ignore
+ * @private
+ * @param base {Object} bound 'this' for the function
+ * @param name {Function} function to find
+ */
+jasmine.bindOriginal_ = function(base, name) {
+ var original = base[name];
+ if (original.apply) {
+ return function() {
+ return original.apply(base, arguments);
+ };
+ } else {
+ // IE support
+ 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.MessageResult = function(values) {
+ this.type = 'log';
+ this.values = values;
+ this.trace = new Error(); // todo: test better
+};
+
+jasmine.MessageResult.prototype.toString = function() {
+ var text = "";
+ for (var i = 0; i < this.values.length; i++) {
+ if (i > 0) text += " ";
+ if (jasmine.isString_(this.values[i])) {
+ text += this.values[i];
+ } else {
+ text += jasmine.pp(this.values[i]);
+ }
+ }
+ 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;
+
+ var trace = (params.trace || new Error(this.message));
+ this.trace = this.passed_ ? '' : trace;
+};
+
+jasmine.ExpectationResult.prototype.toString = function () {
+ return this.message;
+};
+
+jasmine.ExpectationResult.prototype.passed = function () {
+ 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;
+};
+
+/**
+ * @ignore
+ * @private
+ * @param value
+ * @returns {Boolean}
+ */
+jasmine.isArray_ = function(value) {
+ return jasmine.isA_("Array", value);
+};
+
+/**
+ * @ignore
+ * @private
+ * @param value
+ * @returns {Boolean}
+ */
+jasmine.isString_ = function(value) {
+ return jasmine.isA_("String", value);
+};
+
+/**
+ * @ignore
+ * @private
+ * @param value
+ * @returns {Boolean}
+ */
+jasmine.isNumber_ = function(value) {
+ return jasmine.isA_("Number", value);
+};
+
+/**
+ * @ignore
+ * @private
+ * @param {String} typeName
+ * @param value
+ * @returns {Boolean}
+ */
+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.
+ *
+ * @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;
+};
+
+/**
+ * Returns true if the object is a DOM Node.
+ *
+ * @param {Object} obj object to check
+ * @returns {Boolean}
+ */
+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.
+ *
+ * @example
+ * // don't care about which function is passed in, as long as it's a function
+ * expect(mySpy).toHaveBeenCalledWith(jasmine.any(Function));
+ *
+ * @param {Class} clazz
+ * @returns matchable object of the type 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
+ * attributes on the object.
+ *
+ * @example
+ * // don't care about any other attributes than foo.
+ * expect(mySpy).toHaveBeenCalledWith(jasmine.objectContaining({foo: "bar"});
+ *
+ * @param sample {Object} sample
+ * @returns matchable object for the sample
+ */
+jasmine.objectContaining = function (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.
+ *
+ * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine
+ * expectation syntax. Spies can be checked if they were called or not and what the calling params were.
+ *
+ * A Spy has the following fields: wasCalled, callCount, mostRecentCall, and argsForCall (see docs).
+ *
+ * Spies are torn down at the end of every spec.
+ *
+ * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj.
+ *
+ * @example
+ * // a stub
+ * var myStub = jasmine.createSpy('myStub'); // can be used anywhere
+ *
+ * // spy example
+ * var foo = {
+ * not: function(bool) { return !bool; }
+ * }
+ *
+ * // actual foo.not will not be called, execution stops
+ * spyOn(foo, 'not');
+
+ // foo.not spied upon, execution will continue to implementation
+ * spyOn(foo, 'not').andCallThrough();
+ *
+ * // fake example
+ * var foo = {
+ * not: function(bool) { return !bool; }
+ * }
+ *
+ * // foo.not(val) will return val
+ * spyOn(foo, 'not').andCallFake(function(value) {return value;});
+ *
+ * // mock example
+ * foo.not(7 == 7);
+ * expect(foo.not).toHaveBeenCalled();
+ * expect(foo.not).toHaveBeenCalledWith(true);
+ *
+ * @constructor
+ * @see spyOn, jasmine.createSpy, jasmine.createSpyObj
+ * @param {String} name
+ */
+jasmine.Spy = function(name) {
+ /**
+ * The name of the spy, if provided.
+ */
+ this.identity = name || 'unknown';
+ /**
+ * Is this Object a spy?
+ */
+ this.isSpy = true;
+ /**
+ * The actual function this spy stubs.
+ */
+ this.plan = function() {
+ };
+ /**
+ * Tracking of the most recent call to the spy.
+ * @example
+ * var mySpy = jasmine.createSpy('foo');
+ * mySpy(1, 2);
+ * mySpy.mostRecentCall.args = [1, 2];
+ */
+ this.mostRecentCall = {};
+
+ /**
+ * Holds arguments for each call to the spy, indexed by call count
+ * @example
+ * var mySpy = jasmine.createSpy('foo');
+ * mySpy(1, 2);
+ * mySpy(7, 8);
+ * mySpy.mostRecentCall.args = [7, 8];
+ * mySpy.argsForCall[0] = [1, 2];
+ * mySpy.argsForCall[1] = [7, 8];
+ */
+ this.argsForCall = [];
+ this.calls = [];
+};
+
+/**
+ * Tells a spy to call through to the actual implemenatation.
+ *
+ * @example
+ * var foo = {
+ * bar: function() { // do some stuff }
+ * }
+ *
+ * // defining a spy on an existing property: foo.bar
+ * spyOn(foo, 'bar').andCallThrough();
+ */
+jasmine.Spy.prototype.andCallThrough = function() {
+ this.plan = this.originalValue;
+ return this;
+};
+
+/**
+ * For setting the return value of a spy.
+ *
+ * @example
+ * // defining a spy from scratch: foo() returns 'baz'
+ * var foo = jasmine.createSpy('spy on foo').andReturn('baz');
+ *
+ * // defining a spy on an existing property: foo.bar() returns 'baz'
+ * spyOn(foo, 'bar').andReturn('baz');
+ *
+ * @param {Object} value
+ */
+jasmine.Spy.prototype.andReturn = function(value) {
+ this.plan = function() {
+ return value;
+ };
+ return this;
+};
+
+/**
+ * For throwing an exception when a spy is called.
+ *
+ * @example
+ * // defining a spy from scratch: foo() throws an exception w/ message 'ouch'
+ * var foo = jasmine.createSpy('spy on foo').andThrow('baz');
+ *
+ * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch'
+ * spyOn(foo, 'bar').andThrow('baz');
+ *
+ * @param {String} exceptionMsg
+ */
+jasmine.Spy.prototype.andThrow = function(exceptionMsg) {
+ this.plan = function() {
+ throw exceptionMsg;
+ };
+ return this;
+};
+
+/**
+ * Calls an alternate implementation when a spy is called.
+ *
+ * @example
+ * var baz = function() {
+ * // do some stuff, return something
+ * }
+ * // defining a spy from scratch: foo() calls the function baz
+ * var foo = jasmine.createSpy('spy on foo').andCall(baz);
+ *
+ * // defining a spy on an existing property: foo.bar() calls an anonymnous function
+ * spyOn(foo, 'bar').andCall(function() { return 'baz';} );
+ *
+ * @param {Function} fakeFunc
+ */
+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.
+ *
+ * @example
+ * spyOn(foo, 'bar');
+ *
+ * foo.bar();
+ *
+ * expect(foo.bar.callCount).toEqual(1);
+ *
+ * foo.bar.reset();
+ *
+ * expect(foo.bar.callCount).toEqual(0);
+ */
+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);
+ };
+
+ var spy = new jasmine.Spy(name);
+
+ for (var prop in spy) {
+ spyObj[prop] = spy[prop];
+ }
+
+ spyObj.reset();
+
+ return spyObj;
+};
+
+/**
+ * Determines whether an object is a spy.
+ *
+ * @param {jasmine.Spy|Object} putativeSpy
+ * @returns {Boolean}
+ */
+jasmine.isSpy = function(putativeSpy) {
+ return putativeSpy && putativeSpy.isSpy;
+};
+
+/**
+ * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something
+ * large in one call.
+ *
+ * @param {String} baseName name of spy class
+ * @param {Array} methodNames array of names of methods to make spies
+ */
+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');
+ }
+ var obj = {};
+ for (var i = 0; i < methodNames.length; i++) {
+ obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]);
+ }
+ 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 <code>jasmine.log</code> in production code.
+ */
+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.
+ *
+ * @example
+ * // spy example
+ * var foo = {
+ * not: function(bool) { return !bool; }
+ * }
+ * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops
+ *
+ * @see jasmine.createSpy
+ * @param obj
+ * @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;
+
+/**
+ * Creates a Jasmine spec that will be added to the current suite.
+ *
+ * // TODO: pending tests
+ *
+ * @example
+ * it('should be true', function() {
+ * expect(true).toEqual(true);
+ * });
+ *
+ * @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;
+
+/**
+ * Creates a <em>disabled</em> Jasmine spec.
+ *
+ * A convenience method that allows existing specs to be disabled temporarily during development.
+ *
+ * @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;
+
+/**
+ * Starts a chain for a Jasmine expectation.
+ *
+ * It is passed an Object that is the actual value and should chain to one of the many
+ * jasmine.Matchers functions.
+ *
+ * @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;
+
+/**
+ * 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;
+
+/**
+ * Waits a fixed time period before moving to the next block.
+ *
+ * @deprecated Use waitsFor() instead
+ * @param {Number} timeout milliseconds to wait
+ */
+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.
+ *
+ * @param {Function} latchFunction
+ * @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;
+
+/**
+ * A function that is called before each spec in a suite.
+ *
+ * Used for spec setup, including validating assumptions.
+ *
+ * @param {Function} beforeEachFunction
+ */
+var beforeEach = function(beforeEachFunction) {
+ jasmine.getEnv().beforeEach(beforeEachFunction);
+};
+if (isCommonJS) exports.beforeEach = beforeEach;
+
+/**
+ * A function that is called after each spec in a suite.
+ *
+ * Used for restoring any state that is hijacked during spec execution.
+ *
+ * @param {Function} afterEachFunction
+ */
+var afterEach = function(afterEachFunction) {
+ jasmine.getEnv().afterEach(afterEachFunction);
+};
+if (isCommonJS) exports.afterEach = afterEach;
+
+/**
+ * Defines a suite of specifications.
+ *
+ * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared
+ * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization
+ * of setup in some tests.
+ *
+ * @example
+ * // TODO: a simple suite
+ *
+ * // TODO: a simple suite with a nested describe block
+ *
+ * @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;
+
+/**
+ * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development.
+ *
+ * @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;
+
+
+// Provide the XMLHttpRequest class for IE 5.x-6.x:
+jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() {
+ function tryIt(f) {
+ try {
+ return f();
+ } catch(e) {
+ }
+ return null;
+ }
+
+ 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");
+ }) ||
+ tryIt(function() {
+ return new ActiveXObject("Microsoft.XMLHTTP");
+ });
+
+ if (!xhr) throw new Error("This browser does not support XMLHttpRequest.");
+
+ return xhr;
+} : XMLHttpRequest;
+jasmine.MAX_PRETTY_PRINT_DEPTH = 1;
+
+jasmine.hashes = {};
+
+jasmine.hashString = function (s, hash) {
+ hash = hash || 0;
+
+ // see http://www.cse.yorku.ca/~oz/hash.html
+ for (var c, i = 0, n = s.length; i < n; ++i) {
+ c = s.charCodeAt(i);
+ hash = c + (hash << 6) + (hash << 16) - hash;
+ }
+
+ if (jasmine.hashes[hash]) {
+ console.log("Identical hash detected: " + s);
+ }
+
+ jasmine.hashes[hash] = true;
+ return hash;
+};
+
+jasmine.toMap = function (items) {
+ var map = {},
+ k;
+
+ for (k = items.length; k--; ) {
+ map[items[k]] = true;
+ }
+
+ return map;
+};
+
+
+jasmine.setCurrentScript = function(file){
+ if(typeof Ext !== "undefined" && Ext.cmd && Ext.cmd.api && Ext.cmd.api.adapter) {
+ Ext.cmd.api.adapter.setCurrentScript(file);
+ }
+};
+
+jasmine.getCurrentScript = function() {
+ if(typeof Ext !== "undefined" && Ext.cmd && Ext.cmd.api && Ext.cmd.api.adapter) {
+ return Ext.cmd.api.adapter.getCurrentScript();
+ }
+ return null;
+};
+
+jasmine.setOptions = function(jsonString) {
+ jasmine._options = JSON.parse(jsonString);
+};
+
+jasmine.getOptions = function() {
+ return jasmine._options || {};
+};
+
+jasmine.initDebug = function() {
+ var spec = jasmine.getOptions().spec;
+ if (spec) {
+ var specId = parseInt(spec);
+ this.getEnv().specFilter = function(spec) {
+ if (spec.id === specId) {
+ spec.debugBlocks = true;
+ return true;
+ } else {
+ return false;
+ }
+ }
+ }
+};
+
+jasmine.generateDebuggableBlock = function(fn) {
+ return function() {
+ debugger;
+ /* Step into the function below */
+ fn.apply(this, arguments);
+ };
+};
+
+jasmine.showDebugPrompt = function(callback) {
+ if (navigator.userAgent.toLowerCase().match(/chrome|safari|msie/)) {
+ var div = document.createElement("div");
+
+ div.setAttribute("style",[
+ "background:#E5E4E2;",
+ "z-index:99999;",
+ "position:absolute;",
+ "left:25%;",
+ "right:25%;",
+ "top:100px;",
+ "border-radius: 5px;",
+ "border:1px solid #777;",
+ "text-align:center;",
+ "box-shadow: 5px 5px 5px #888;"
+ ].join(""));
+
+ div.innerHTML = [
+ '<p>Open the developer tools to debug and press ok.</p>',
+ '<button id="sencha-debug-button">OK</button>',
+ '<p></p>'
+ ].join("");
+
+ document.body.appendChild(div);
+
+ var button = document.getElementById("sencha-debug-button");
+
+ var onClick = function() {
+ if (button.removeEventListener) {
+ button.removeEventListener("click", onClick, false);
+ } else {
+ button.detachEvent("onmousedown", onClick);
+ }
+ document.body.removeChild(div);
+ div = null;
+ callback();
+ };
+
+ if (button.addEventListener) {
+ button.addEventListener("click", onClick, false);
+ } else {
+ button.attachEvent("onmousedown", onClick);
+ }
+ } else {
+ callback();
+ }
+};
+
+
+addGlobal = function() {};
+
+jasmine.getByIds = function (items, ids) {
+ var result = [],
+ length = items.length,
+ i, id, item;
+
+ for (i = 0; i < length; ++i) {
+ item = items[i];
+ id = item.id;
+ if (ids[id]) {
+ result.push(item);
+ }
+ }
+
+ return result;
+};
+
+var specFor = function(object, specForFn) {
+ jasmine.getEnv().specFor(object, specForFn);
+};
+
+var xspecFor = function(object, specForFn) {
+ jasmine.getEnv().xspecFor(object, specForFn);
+};
+
+var xdescribe = function(description, specDefinitions, coverageFile) {
+ return jasmine.getEnv().describe(description, specDefinitions, coverageFile).disable();
+};
+
+var xit = function(desc, func) {
+ return jasmine.getEnv().it(desc, func).disable();
+};
+/**
+ * @namespace
+ */
+jasmine.util = {};
+
+/**
+ * Declare that a child class inherit it's prototype from the parent class.
+ *
+ * @private
+ * @param {Function} childClass
+ * @param {Function} parentClass
+ */
+jasmine.util.inherit = function(childClass, parentClass) {
+ /**
+ * @private
+ */
+ var subclass = function() {
+ };
+ subclass.prototype = parentClass.prototype;
+ childClass.prototype = new subclass();
+};
+
+jasmine.util.formatException = function(e) {
+ var lineNumber;
+ if (e.line) {
+ lineNumber = e.line;
+ }
+ else if (e.lineNumber) {
+ lineNumber = e.lineNumber;
+ }
+
+ var file;
+
+ if (e.sourceURL) {
+ file = e.sourceURL;
+ }
+ else if (e.fileName) {
+ file = e.fileName;
+ }
+
+ var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
+
+ if (file && lineNumber) {
+ message += ' in ' + file + ' (line ' + lineNumber + ')';
+ }
+
+ return message;
+};
+
+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.extend = function(destination, source) {
+ for (var property in source) destination[property] = source[property];
+ return destination;
+};
+
+jasmine.util.getOrigin = function() {
+ var port = window.location.port;
+ var origin;
+
+ origin = window.location.protocol + "//" + window.location.hostname;
+
+ if (port) {
+ origin += ":" + port;
+ }
+
+ return origin;
+};
+
+jasmine.util.getFileFromContextMapping = function(file) {
+ var contextMapping = jasmine.contextMapping;
+ if (file && contextMapping) {
+ var origin = jasmine.util.getOrigin();
+ for (var context in contextMapping) {
+ file = file.replace(origin + context, contextMapping[context]);
+ }
+ }
+ return file;
+};
+
+jasmine.util.formatException = function(e) {
+ var lineNumber;
+ if (e.line) {
+ lineNumber = e.line;
+ }
+ else if (e.lineNumber) {
+ lineNumber = e.lineNumber;
+ }
+
+ var file;
+
+ if (e.sourceURL) {
+ file = e.sourceURL;
+ }
+ else if (e.fileName) {
+ file = e.fileName;
+ }
+
+ file = jasmine.util.getFileFromContextMapping(file);
+
+ var message = (e.name && e.message) ? (e.name + ': ' + e.message) : e.toString();
+
+ if (file && lineNumber) {
+ message += ' in ' + file + ' (line ' + lineNumber + ')';
+ }
+
+ return message;
+};/**
+ * Environment for Jasmine
+ *
+ * @constructor
+ */
+jasmine.Env = function() {
+ this.currentSpec = null;
+ this.currentSuite = null;
+ this.currentRunner_ = new jasmine.Runner(this);
+
+ 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.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);
+};
+
+
+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_;
+ } else {
+ throw new Error('Version not set');
+ }
+};
+
+/**
+ * @returns string containing jasmine version build info, if set.
+ */
+jasmine.Env.prototype.versionString = function() {
+ if (!jasmine.version_) {
+ return "version unknown";
+ }
+
+ var version = this.version();
+ var versionString = version.major + "." + version.minor + "." + version.build;
+ if (version.release_candidate) {
+ versionString += ".rc" + version.release_candidate;
+ }
+ versionString += " revision " + version.revision;
+ return versionString;
+};
+
+/**
+ * @returns a sequential integer starting at 0
+ */
+jasmine.Env.prototype.nextSpecId = function () {
+ return this.nextSpecId_++;
+};
+
+/**
+ * @returns a sequential integer starting at 0
+ */
+jasmine.Env.prototype.nextSuiteId = function () {
+ 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.execute = function() {
+ this.currentRunner_.execute();
+};
+
+jasmine.Env.prototype.describe = function(description, specDefinitions) {
+ var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite);
+
+ var parentSuite = this.currentSuite;
+ if (parentSuite) {
+ parentSuite.add(suite);
+ } else {
+ this.currentRunner_.add(suite);
+ }
+
+ this.currentSuite = suite;
+
+ var declarationError = null;
+ try {
+ specDefinitions.call(suite);
+ } catch(e) {
+ declarationError = e;
+ }
+
+ if (declarationError) {
+ this.it("encountered a declaration exception", function() {
+ throw declarationError;
+ });
+ }
+
+ this.currentSuite = parentSuite;
+
+ return suite;
+};
+
+jasmine.Env.prototype.beforeEach = function(beforeEachFunction) {
+ if (this.currentSuite) {
+ this.currentSuite.beforeEach(beforeEachFunction);
+ } else {
+ this.currentRunner_.beforeEach(beforeEachFunction);
+ }
+};
+
+jasmine.Env.prototype.currentRunner = function () {
+ return this.currentRunner_;
+};
+
+jasmine.Env.prototype.afterEach = function(afterEachFunction) {
+ if (this.currentSuite) {
+ this.currentSuite.afterEach(afterEachFunction);
+ } else {
+ this.currentRunner_.afterEach(afterEachFunction);
+ }
+
+};
+
+jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) {
+ return {
+ 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;
+
+ if (func) {
+ spec.runs(func);
+ }
+
+ return spec;
+};
+
+jasmine.Env.prototype.xit = function(desc, func) {
+ return {
+ id: this.nextSpecId(),
+ 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 + "/");
+
+ 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.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");
+
+ return (mismatchValues.length === 0);
+};
+
+jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) {
+ if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) {
+ return true;
+ }
+
+ a.__Jasmine_been_here_before__ = b;
+ b.__Jasmine_been_here_before__ = a;
+
+ 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.");
+ }
+ }
+ for (property in a) {
+ if (!hasKey(b, property) && hasKey(a, property)) {
+ mismatchKeys.push("expected missing key '" + property + "', but present in actual.");
+ }
+ }
+ for (property in b) {
+ 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.");
+ }
+ }
+
+ if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.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);
+};
+
+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;
+ }
+
+ if (a === b) return true;
+
+ if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) {
+ return (a == jasmine.undefined && b == jasmine.undefined);
+ }
+
+ if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) {
+ return a === b;
+ }
+
+ if (a instanceof Date && b instanceof Date) {
+ return a.getTime() == b.getTime();
+ }
+
+ if (a.jasmineMatches) {
+ return a.jasmineMatches(b);
+ }
+
+ if (b.jasmineMatches) {
+ return b.jasmineMatches(a);
+ }
+
+ if (a instanceof jasmine.Matchers.ObjectContaining) {
+ return a.matches(b);
+ }
+
+ if (b instanceof jasmine.Matchers.ObjectContaining) {
+ return b.matches(a);
+ }
+
+ if (jasmine.isString_(a) && jasmine.isString_(b)) {
+ return (a == b);
+ }
+
+ if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) {
+ return (a == b);
+ }
+
+ if (a instanceof RegExp && b instanceof RegExp) {
+ return this.compareRegExps_(a, b, mismatchKeys, mismatchValues);
+ }
+
+ if (typeof a === "object" && typeof b === "object") {
+ return this.compareObjects_(a, b, mismatchKeys, mismatchValues);
+ }
+
+ //Straight check
+ return (a === b);
+};
+
+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;
+ }
+ return false;
+ }
+ return haystack.indexOf(needle) >= 0;
+};
+
+jasmine.Env.prototype.addEqualityTester = function(equalityTester) {
+ this.equalityTesters_.push(equalityTester);
+};
+/**
+ * Basic browsers detection.
+ */
+jasmine.browser = {};
+jasmine.browser.isIE = !!window.ActiveXObject;
+jasmine.browser.isIE6 = jasmine.browser.isIE && !window.XMLHttpRequest;
+jasmine.browser.isIE7 = jasmine.browser.isIE && !!window.XMLHttpRequest && !document.documentMode;
+jasmine.browser.isIE8 = jasmine.browser.isIE && !!window.XMLHttpRequest && !!document.documentMode && !window.performance;
+jasmine.browser.isIE9 = jasmine.browser.isIE && !!window.performance;
+jasmine.browser.isSafari3 = /safari/.test(navigator.userAgent.toLowerCase()) && /version\/3/.test(navigator.userAgent.toLowerCase());
+jasmine.browser.isOpera = !!window.opera;
+jasmine.browser.isOpera11 = jasmine.browser.isOpera && parseInt(window.opera.version(), 10) > 10;
+
+jasmine.array = {};
+
+ /**
+ * Checks whether or not the specified item exists in the array.
+ * Array.prototype.indexOf is missing in Internet Explorer, unfortunately.
+ * We always have to use this static method instead for consistency
+ * @param {Array} array The array to check
+ * @param {Mixed} item The item to look for
+ * @param {Number} from (Optional) The index at which to begin the search
+ * @return {Number} The index of item in the array (or -1 if it is not found)
+ */
+jasmine.array.indexOf = function(array, item, from){
+ if (array.indexOf) {
+ return array.indexOf(item, from);
+ }
+
+ var i, length = array.length;
+
+ for (i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){
+ if (array[i] === item) {
+ return i;
+ }
+ }
+
+ return -1;
+};
+
+ /**
+ * Removes the specified item from the array. If the item is not found nothing happens.
+ * @param {Array} array The array
+ * @param {Mixed} item The item to remove
+ * @return {Array} The passed array itself
+ */
+jasmine.array.remove = function(array, item) {
+ var index = this.indexOf(array, item);
+
+ if (index !== -1) {
+ array.splice(index, 1);
+ }
+
+ return array;
+};
+
+jasmine.Env.prototype.it = function(description, func, timeout) {
+ var spec = new jasmine.Spec(this, this.currentSuite, description);
+ this.currentSuite.add(spec);
+ this.currentSpec = spec;
+
+ // override
+ if (func) {
+ func.typeName = 'it';
+ var block = new jasmine.Block(spec.env, func, spec);
+ block.timeout = parseInt(timeout);
+ spec.addToQueue(block);
+ }
+ // end of override
+
+ return spec;
+};
+
+jasmine.Env.prototype.specFor = function(object, specForFn) {
+ var index = 0,
+ property;
+
+ for (property in object) {
+ if (!object.hasOwnProperty(property)) {
+ continue;
+ }
+ specForFn.call(this, property, object[property], index, object);
+ index = index + 1;
+ }
+};
+
+jasmine.Env.prototype.xspecFor = function(object, specForFn) {};/** No-op base class for Jasmine reporters.
+ *
+ * @constructor
+ */
+jasmine.Reporter = function() {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportRunnerStarting = function(runner) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportRunnerResults = function(runner) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSuiteResults = function(suite) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSpecStarting = function(spec) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.reportSpecResults = function(spec) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.Reporter.prototype.log = function(str) {
+};
+
+/**
+ * Blocks are functions with executable code that make up a spec.
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ * @param {Function} func
+ * @param {jasmine.Spec} spec
+ */
+jasmine.Block = function(env, func, spec) {
+ this.env = env;
+ this.func = func;
+ this.spec = spec;
+};
+
+jasmine.Block.prototype.execute = function(onComplete) {
+ if (!jasmine.CATCH_EXCEPTIONS) {
+ this.func.apply(this.spec);
+ }
+ else {
+ try {
+ this.func.apply(this.spec);
+ } catch (e) {
+ this.spec.fail(e);
+ }
+ }
+ onComplete();
+};
+jasmine.Block.prototype.execute = function(onComplete) {
+ if (this.func.length === 1) {
+
+ var timeOutId = setTimeout(function(){
+ onComplete();
+ }, this.timeout || jasmine.DEFAULT_TIMEOUT_INTERVAL);
+
+ if (!jasmine.CATCH_EXCEPTIONS) {
+ this.func.call(this.spec, function() {
+ clearTimeout(timeOutId);
+ onComplete();
+ });
+ } else {
+ try {
+ this.func.call(this.spec, function() {
+ clearTimeout(timeOutId);
+ onComplete();
+ });
+ } catch (e) {
+ this.spec.fail(e);
+ onComplete();
+ }
+ }
+ } else {
+ if (!jasmine.CATCH_EXCEPTIONS) {
+ this.func.apply(this.spec);
+ } else {
+ try {
+ this.func.apply(this.spec);
+ } catch (e) {
+ this.spec.fail(e);
+ }
+ }
+ onComplete();
+ }
+};/** JavaScript API reporter.
+ *
+ * @constructor
+ */
+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();
+ for (var i = 0; i < suites.length; i++) {
+ var suite = suites[i];
+ this.suites_.push(this.summarize_(suite));
+ }
+};
+
+jasmine.JsApiReporter.prototype.suites = function() {
+ return this.suites_;
+};
+
+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();
+ for (var i = 0; i < children.length; i++) {
+ summary.children.push(this.summarize_(children[i]));
+ }
+ }
+ return summary;
+};
+
+jasmine.JsApiReporter.prototype.results = function() {
+ return this.results_;
+};
+
+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.reportSuiteResults = function(suite) {
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) {
+ this.results_[spec.id] = {
+ messages: spec.results().getItems(),
+ result: spec.results().failedCount > 0 ? "failed" : "passed"
+ };
+};
+
+//noinspection JSUnusedLocalSymbols
+jasmine.JsApiReporter.prototype.log = function(str) {
+};
+
+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]);
+ }
+ return results;
+};
+
+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];
+ summaryMessages.push({
+ text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined,
+ passed: resultMessage.passed ? resultMessage.passed() : true,
+ type: resultMessage.type,
+ message: resultMessage.message,
+ trace: {
+ stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined
+ }
+ });
+ }
+
+ return {
+ result : result.result,
+ messages : summaryMessages
+ };
+};
+
+/**
+ * @constructor
+ * @param {jasmine.Env} env
+ * @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;
+};
+
+// 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!");
+};
+
+// 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.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);
+ }
+};
+
+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;
+ }
+
+ if (this.reportWasCalled_) return result;
+
+ var message;
+ if (!result) {
+ if (this.message) {
+ message = this.message.apply(this, arguments);
+ if (jasmine.isArray_(message)) {
+ 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;
+ if (matcherArgs.length > 0) {
+ for (var i = 0; i < matcherArgs.length; i++) {
+ if (i > 0) message += ",";
+ message += " " + jasmine.pp(matcherArgs[i]);
+ }
+ }
+ message += ".";
+ }
+ }
+ var expectationResult = new jasmine.ExpectationResult({
+ matcherName: matcherName,
+ passed: result,
+ expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0],
+ actual: this.actual,
+ message: message
+ });
+ 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;
+};
+
+/**
+ * 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;
+};
+
+/**
+ * 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);
+};
+
+/**
+ * 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);
+};
+
+/**
+ * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes
+ * a pattern or a String.
+ *
+ * @param expected
+ */
+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));
+};
+
+/**
+ * Matcher that compares the actual to 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);
+};
+
+/**
+ * Matcher that compares the actual to 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." ];
+ };
+
+ return (this.actual !== this.actual);
+};
+
+/**
+ * Matcher that boolean not-nots the actual.
+ */
+jasmine.Matchers.prototype.toBeTruthy = function() {
+ return !!this.actual;
+};
+
+
+/**
+ * Matcher that boolean nots the 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() {
+ if (arguments.length > 0) {
+ 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) + '.');
+ }
+
+ this.message = function() {
+ return [
+ "Expected spy " + this.actual.identity + " to have been called.",
+ "Expected spy " + this.actual.identity + " not to have been called."
+ ];
+ };
+
+ return this.actual.wasCalled;
+};
+
+/** @deprecated Use expect(xxx).toHaveBeenCalled() instead */
+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() {
+ if (arguments.length > 0) {
+ 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) + '.');
+ }
+
+ this.message = function() {
+ return [
+ "Expected spy " + this.actual.identity + " to not have been called.",
+ "Expected spy " + this.actual.identity + " to have been called."
+ ];
+ };
+
+ return !this.actual.wasCalled;
+};
+
+/**
+ * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters.
+ *
+ * @example
+ *
+ */
+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) + '.');
+ }
+ 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.";
+ } 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, '')
+ }
+ return [positiveMessage, invertedMessage];
+ };
+
+ return this.env.contains_(this.actual.argsForCall, expectedArgs);
+};
+
+/** @deprecated Use expect(xxx).toHaveBeenCalledWith() instead */
+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);
+ if (!jasmine.isSpy(this.actual)) {
+ throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.');
+ }
+
+ 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"
+ ];
+ };
+
+ 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);
+};
+
+/**
+ * Matcher that checks that the expected item is NOT an element in the actual Array.
+ *
+ * @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.toBeLessThan = 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
+ * up to a given level of decimal precision (default 2).
+ *
+ * @param {Number} expected
+ * @param {Number} precision, as number of decimal places
+ */
+jasmine.Matchers.prototype.toBeCloseTo = function(expected, precision) {
+ if (!(precision === 0)) {
+ precision = 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');
+ }
+ try {
+ this.actual();
+ } catch (e) {
+ exception = e;
+ }
+ if (exception) {
+ result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected));
+ }
+
+ var not = this.isNot ? "not " : "";
+
+ 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(' ');
+ } else {
+ return "Expected function to throw an exception.";
+ }
+ };
+
+ return result;
+};
+
+jasmine.Matchers.Any = function(expectedClass) {
+ this.expectedClass = expectedClass;
+};
+
+jasmine.Matchers.Any.prototype.jasmineMatches = function(other) {
+ if (this.expectedClass == String) {
+ return typeof other == 'string' || other instanceof String;
+ }
+
+ if (this.expectedClass == Number) {
+ return typeof other == 'number' || other instanceof Number;
+ }
+
+ if (this.expectedClass == Function) {
+ return typeof other == 'function' || other instanceof Function;
+ }
+
+ if (this.expectedClass == Object) {
+ return typeof other == 'object';
+ }
+
+ return other instanceof this.expectedClass;
+};
+
+jasmine.Matchers.Any.prototype.jasmineToString = function() {
+ return '<jasmine.any(' + this.expectedClass + ')>';
+};
+
+jasmine.Matchers.ObjectContaining = function (sample) {
+ this.sample = sample;
+};
+
+jasmine.Matchers.ObjectContaining.prototype.jasmineMatches = function(other, mismatchKeys, mismatchValues) {
+ mismatchKeys = mismatchKeys || [];
+ mismatchValues = mismatchValues || [];
+
+ var env = jasmine.getEnv();
+
+ var hasKey = function(obj, keyName) {
+ return obj != null && obj[keyName] !== jasmine.undefined;
+ };
+
+ for (var property in this.sample) {
+ if (!hasKey(other, property) && hasKey(this.sample, property)) {
+ mismatchKeys.push("expected has key '" + property + "', but missing from actual.");
+ }
+ else if (!env.equals_(this.sample[property], other[property], mismatchKeys, mismatchValues)) {
+ mismatchValues.push("'" + property + "' was '" + (other[property] ? jasmine.util.htmlEscape(other[property].toString()) : other[property]) + "' in expected, but was '" + (this.sample[property] ? jasmine.util.htmlEscape(this.sample[property].toString()) : this.sample[property]) + "' in actual.");
+ }
+ }
+
+ return (mismatchKeys.length === 0 && mismatchValues.length === 0);
+};
+
+jasmine.Matchers.ObjectContaining.prototype.jasmineToString = function () {
+ return "<jasmine.objectContaining(" + jasmine.pp(this.sample) + ")>";
+};
+/**
+ * Override of toThrow special opera 10 !!!
+ */
+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();
+ } catch (e) {
+ exception = e;
+ }
+ if (exception) {
+ result = (expected === jasmine.undefined || this.env.contains_(exception.message || exception, expected.message || expected));
+ }
+
+ var not = this.isNot ? "not " : "";
+
+ this.message = function() {
+ if (exception && (expected === jasmine.undefined || !this.env.contains_(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(' ');
+ } else {
+ return "Expected function to throw an exception.";
+ }
+ };
+
+ return result;
+};
+
+jasmine.Matchers.prototype.toRaiseExtError = function(expected) {
+ var result = false,
+ global = Ext.global,
+ extError;
+ if (typeof this.actual != 'function') {
+ throw new Error('Actual is not a function');
+ }
+
+ // mock the console to avoid logging to the real console during the tests
+ Ext.global = {
+ console: {
+ dir: function(s) {
+ return s;
+ },
+ log: function(s) {
+ return s;
+ },
+ error: function(s) {
+ return s;
+ },
+ warn: function(s) {
+ return s;
+ }
+ }
+ };
+
+ try {
+ this.actual();
+ } catch (e) {
+ extError = e;
+ }
+
+
+ Ext.global = global;
+
+ if (extError && extError instanceof Error) {
+ result = (expected === jasmine.undefined || this.env.contains_(extError.toString(), expected.message || expected));
+ }
+
+
+ var not = this.isNot ? "not " : "";
+
+ this.message = function() {
+ if (!extError instanceof Error) {
+ return "Exception thrown is not an instance of Ext.Error";
+ } else if (extError && (expected === jasmine.undefined || !this.env.contains_(extError.toString(), expected.message || expected))) {
+ return ["Expected function " + not + "to throw", expected ? expected.message || expected : " an exception", ", but it threw", extError.toString()].join(' ');
+ } else {
+ return "Expected function to throw an exception.";
+ }
+ };
+
+ return result;
+};
+
+jasmine.Matchers.prototype.hasHTML = function(expected) {
+ var me = this;
+
+ if (!me.actual || !me.actual.tagName) {
+ throw new Error('Actual is not a dom element');
+ }
+ if (jasmine.browser.isSafari3) {
+ expected = expected.replace(/>/g, '>');
+ }
+ // this normalize innerHTML which could vary a lot
+ var normalizedHTML = me.actual.innerHTML.replace(/<[^>]*>/g, function(match1) {
+ return match1.toLowerCase().replace(/=\w+/g, function(match2) {
+ return '="' + match2.split('=')[1] + '"';
+ });
+ });
+
+ me.message = function() {
+ return [
+ "Expected dom element innerHTML to be " + expected + " but was " + normalizedHTML,
+ "Expected dom element innerHTML to not be " + expected + "."
+ ];
+ };
+
+ return normalizedHTML === expected;
+};
+
+jasmine.Matchers.prototype.toHaveCls = function(cls) {
+ return Ext.fly(this.actual).hasCls(cls);
+};
+
+jasmine.Matchers.prototype.toEqualTime = function(hour, minute, second, ms) {
+ var actual = this.actual;
+ return actual instanceof Date &&
+ actual.getHours() === hour &&
+ actual.getMinutes() === (minute || 0) &&
+ actual.getSeconds() === (second || 0) &&
+ actual.getMilliseconds() === (ms || 0);
+
+};
+
+jasmine.Matchers.prototype.toBePositionedAt = function(x, y) {
+ var xy = this.actual.getXY();
+ this.message = function() {
+ return "Expected Ext.Element to be positioned at (" + x + "," + y + ") but was positioned at (" + xy[0] + "," + xy[1] + ")";
+ };
+ return xy[0] === x && xy[1] === y;
+};
+
+(function () {
+ var elementPropGetters = {
+ x: function (el, root) {
+ var x = el.getX(),
+ x0 = root ? root.el.getX() : el.getX();
+ return x - x0;
+ },
+ y: function (el, root) {
+ var y = el.getY(),
+ y0 = root ? root.el.getY() : el.getY();
+ return y - y0;
+ },
+ w: function (el) {
+ return el.getWidth();
+ },
+ h: function (el) {
+ return el.getHeight();
+ },
+ xywh: function(el, root) {
+ var x= el.getX(),
+ x0 = root ? root.el.getX() : el.getX(),
+ y = el.getY(),
+ y0 = root ? root.el.getY() : el.getY(),
+ w = el.getWidth(),
+ h = el.getHeight(),
+ dims = [];
+ dims.push(x - x0, y - y0, w, h);
+ return dims.join(' ');
+ },
+ cls: function (el) {
+ return el.dom.className;
+ }
+ },
+ browsers = [
+ "IE6", "IE7", "IE8", "IE9", "IE",
+ "Gecko3", "Gecko4", "Gecko5", "Gecko10", "Gecko",
+ "FF3_6", "FF4", "FF5",
+ "Chrome",
+ "Safari2", "Safari3", "Safari4", "Safari5", "Safari"
+ ],
+ blen = browsers.length,
+ b, browser,
+ browserCheck = function(expected){
+ if(Ext.isNumeric(expected) || Ext.isArray(expected)) {
+ return expected;
+ }
+ for (b = 0; b < blen; b++) {
+ browser = browsers[b];
+ if (expected.hasOwnProperty(browser) && Ext["is" + browser]){
+ return expected[browser];
+ }
+ }
+ return expected['*'] || expected;
+ };
+
+
+ function checkLayout (comp, layout, root, path) {
+ Ext.Object.each(layout, function (name, value) {
+ if (name == 'items' || name == 'dockedItems') {
+ Ext.Object.each(value, function (id, sub) {
+ var isNum = String(parseInt(id,10)) == id,
+ child = isNum ? comp[name].items[parseInt(id,10)]
+ : (comp.getComponent(id) || comp.child(id));
+
+ if (isNum) {
+ id = '.' + name + '[' + id + ']';
+ } else if (id.charAt(0) != ':') {
+ id = '_' + id;
+ }
+
+ if (child) {
+ checkLayout(child, sub, comp, path + id);
+ } else {
+ expect(id).toBe('found!');
+ }
+ });
+ } else {
+ // the name is an element name like 'body'
+ var el = comp[name];
+
+ if (!el) {
+ // no child el matched, assume the key is a CSS selector
+ el = comp.el.selectNode(name, false);
+ }
+
+ if (el.isComponent) {
+ checkLayout(el, value, el.ownerCt, path + '_' + name);
+ } else if (el.dom) {
+ value = browserCheck(value);
+ if (value.xywh) {
+ var dims = value.xywh.split(' ');
+ value.x = eval('(' + dims[0] + ')');
+ value.y = eval('(' + dims[1] + ')');
+ value.w = eval('(' + dims[2] + ')');
+ value.h = eval('(' + dims[3] + ')');
+ delete value.xywh;
+ }
+ Ext.Object.each(value, function (prop, expected) {
+ var actual = elementPropGetters[prop](el, root || comp.el),
+ pfx = path + '.' + name + '.' + prop + '=';
+
+ if (Ext.isArray(expected)) {
+ if (actual < expected[0] || actual > expected[1]) {
+ expect(pfx + '=' + actual).
+ toBe('in [' + expected[0] + ',' + expected[1] + ']');
+ }
+ } else if (actual != expected) {
+ expect(pfx + actual).toEqual(expected);
+ }
+ });
+ }
+ }
+ });
+ }
+
+ jasmine.Matchers.prototype.toHaveLayout = function(expected) {
+ var comp = this.actual;
+ checkLayout(comp, expected, comp.ownerCt, comp.getXType());
+ return true;
+ };
+
+ jasmine.Matchers.prototype.toBeLessThanOrEqual = function(expected) {
+ return this.actual <= expected;
+ };
+
+ jasmine.Matchers.prototype.toBeGreaterThanOrEqual = function(expected) {
+ return this.actual >= expected;
+ };
+
+})();
+
+
+ jasmine.Matchers.prototype.toHaveFiredEvents = function() {
+ var calls = this.actual.fireEvent.calls,
+ i = 0,
+ ret = true,
+ expectedEvents = Array.prototype.slice.call(arguments, 0),
+ length = expectedEvents.length,
+ actualEvents = [],
+ actualEvent,
+ expectedEvent;
+
+
+
+ for (;i < length; i++) {
+ expectedEvent = expectedEvents[i];
+ try {
+ actualEvent = calls[i].args[0];
+ } catch (e) {
+ actualEvent = null;
+ }
+ if (actualEvent) {
+ actualEvents.push(actualEvent);
+ }
+
+ if (actualEvent != expectedEvent) {
+ ret = false;
+ }
+ }
+
+ this.message = function() {
+ return "Expected events flow to be (" + expectedEvents.length + " events): \n" + expectedEvents.join('\n') + "\nBut it was (" + actualEvents.length + " events): \n"+ actualEvents.join('\n');
+ };
+ return ret;
+ };/**
+ * @constructor
+ */
+jasmine.MultiReporter = function() {
+ this.subReporters_ = [];
+};
+jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter);
+
+jasmine.MultiReporter.prototype.addReporter = function(reporter) {
+ this.subReporters_.push(reporter);
+};
+
+(function() {
+ var functionNames = [
+ "reportRunnerStarting",
+ "reportRunnerResults",
+ "reportSuiteStarting",
+ "reportSuiteResults",
+ "reportSpecStarting",
+ "reportSpecResults",
+ "log"
+ ];
+ for (var i = 0; i < functionNames.length; i++) {
+ var functionName = functionNames[i];
+ jasmine.MultiReporter.prototype[functionName] = (function(functionName) {
+ return function() {
+ for (var j = 0; j < this.subReporters_.length; j++) {
+ var subReporter = this.subReporters_[j];
+ if (subReporter[functionName]) {
+ subReporter[functionName].apply(subReporter, arguments);
+ }
+ }
+ };
+ })(functionName);
+ }
+})();/**
+ * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults
+ *
+ * @constructor
+ */
+jasmine.NestedResults = function() {
+ /**
+ * The total count of results
+ */
+ this.totalCount = 0;
+ /**
+ * Number of passed results
+ */
+ this.passedCount = 0;
+ /**
+ * Number of failed results
+ */
+ this.failedCount = 0;
+ /**
+ * Was this suite/spec skipped?
+ */
+ this.skipped = false;
+ /**
+ * @ignore
+ */
+ this.items_ = [];
+};
+
+/**
+ * Roll up the result counts.
+ *
+ * @param result
+ */
+jasmine.NestedResults.prototype.rollupCounts = function(result) {
+ this.totalCount += result.totalCount;
+ this.passedCount += result.passedCount;
+ this.failedCount += result.failedCount;
+};
+
+/**
+ * Adds a log message.
+ * @param values Array of message parts which will be concatenated later.
+ */
+jasmine.NestedResults.prototype.log = function(values) {
+ this.items_.push(new jasmine.MessageResult(values));
+};
+
+/**
+ * Getter for the results: message & results.
+ */
+jasmine.NestedResults.prototype.getItems = function() {
+ return this.items_;
+};
+
+/**
+ * Adds a result, tracking counts (total, passed, & failed)
+ * @param {jasmine.ExpectationResult|jasmine.NestedResults} result
+ */
+jasmine.NestedResults.prototype.addResult = function(result) {
+ if (result.type != 'log') {
+ if (result.items_) {
+ this.rollupCounts(result);
+ } else {
+ this.totalCount++;
+ if (result.passed()) {
+ this.passedCount++;
+ } else {
+ this.failedCount++;
+ }
+ }
+ }
+ this.items_.push(result);
+};
+
+/**
+ * @returns {Boolean} True if <b>everything</b> below passed
+ */
+jasmine.NestedResults.prototype.passed = function() {
+ return this.passedCount === this.totalCount;
+};
+/**
+ * Base class for pretty printing for expectation results.
+ */
+jasmine.PrettyPrinter = function() {
+ this.ppNestLevel_ = 0;
+};
+
+/**
+ * Formats a value in a nice, human-readable string.
+ *
+ * @param value
+ */
+jasmine.PrettyPrinter.prototype.format = function(value) {
+ this.ppNestLevel_++;
+ try {
+ if (value === jasmine.undefined) {
+ this.emitScalar('undefined');
+ } else if (value === null) {
+ this.emitScalar('null');
+ } else if (value === jasmine.getGlobal()) {
+ this.emitScalar('<global>');
+ } else if (value.jasmineToString) {
+ this.emitScalar(value.jasmineToString());
+ } else if (typeof value === 'string') {
+ this.emitString(value);
+ } else if (jasmine.isSpy(value)) {
+ this.emitScalar("spy on " + value.identity);
+ } else if (value instanceof RegExp) {
+ this.emitScalar(value.toString());
+ } else if (typeof value === 'function') {
+ this.emitScalar('Function');
+ } else if (typeof value.nodeType === 'number') {
+ this.emitScalar('HTMLNode');
+ } else if (value instanceof Date) {
+ this.emitScalar('Date(' + value + ')');
+ } else if (value.__Jasmine_been_here_before__) {
+ this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>');
+ } else if (jasmine.isArray_(value) || typeof value == 'object') {
+ value.__Jasmine_been_here_before__ = true;
+ if (jasmine.isArray_(value)) {
+ this.emitArray(value);
+ } else {
+ this.emitObject(value);
+ }
+ delete value.__Jasmine_been_here_before__;
+ } else {
+ this.emitScalar(value.toString());
+ }
+ } finally {
+ this.ppNestLevel_--;
+ }
+};
+
+jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
+ for (var property in obj) {
+ if (!obj.hasOwnProperty(property)) continue;
+ if (property == '__Jasmine_been_here_before__') continue;
+ fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
+ obj.__lookupGetter__(property) !== null) : false);
+ }
+};
+
+jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_;
+jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_;
+jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_;
+jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_;
+
+jasmine.StringPrettyPrinter = function() {
+ jasmine.PrettyPrinter.call(this);
+
+ this.string = '';
+};
+jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter);
+
+jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) {
+ this.append(value);
+};
+
+jasmine.StringPrettyPrinter.prototype.emitString = function(value) {
+ this.append("'" + value + "'");
+};
+
+jasmine.StringPrettyPrinter.prototype.emitArray = function(array) {
+ if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
+ this.append("Array");
+ return;
+ }
+
+ this.append('[ ');
+ for (var i = 0; i < array.length; i++) {
+ if (i > 0) {
+ this.append(', ');
+ }
+ this.format(array[i]);
+ }
+ this.append(' ]');
+};
+
+jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) {
+ if (this.ppNestLevel_ > jasmine.MAX_PRETTY_PRINT_DEPTH) {
+ this.append("Object");
+ return;
+ }
+
+ var self = this;
+ this.append('{ ');
+ var first = true;
+
+ this.iterateObject(obj, function(property, isGetter) {
+ if (first) {
+ first = false;
+ } else {
+ self.append(', ');
+ }
+
+ self.append(property);
+ self.append(' : ');
+ if (isGetter) {
+ self.append('<getter>');
+ } else {
+ self.format(obj[property]);
+ }
+ });
+
+ this.append(' }');
+};
+
+jasmine.StringPrettyPrinter.prototype.append = function(value) {
+ this.string += value;
+};
+(function() {
+ var prototype = jasmine.PrettyPrinter.prototype,
+ superFormat = prototype.format;
+
+ prototype.format = function(value) {
+ if (value && value.$className) {
+ // support for pretty printing instances of Ext classes
+ this.emitScalar(value.$className + '#' + value.id);
+ } else {
+ superFormat.call(this, value);
+ }
+ };
+})();jasmine.Queue = function(env) {
+ this.env = env;
+
+ // parallel to blocks. each true value in this array means the block will
+ // get executed even if we abort
+ this.ensured = [];
+ this.blocks = [];
+ this.running = false;
+ this.index = 0;
+ this.offset = 0;
+ this.abort = false;
+};
+
+jasmine.Queue.prototype.addBefore = function(block, ensure) {
+ if (ensure === jasmine.undefined) {
+ ensure = false;
+ }
+
+ this.blocks.unshift(block);
+ this.ensured.unshift(ensure);
+};
+
+jasmine.Queue.prototype.add = function(block, ensure) {
+ if (ensure === jasmine.undefined) {
+ ensure = false;
+ }
+
+ this.blocks.push(block);
+ this.ensured.push(ensure);
+};
+
+jasmine.Queue.prototype.insertNext = function(block, ensure) {
+ if (ensure === jasmine.undefined) {
+ ensure = false;
+ }
+
+ this.ensured.splice((this.index + this.offset + 1), 0, ensure);
+ this.blocks.splice((this.index + this.offset + 1), 0, block);
+ this.offset++;
+};
+
+jasmine.Queue.prototype.start = function(onComplete) {
+ this.running = true;
+ this.onComplete = onComplete;
+ this.next_();
+};
+
+jasmine.Queue.prototype.isRunning = function() {
+ return this.running;
+};
+
+jasmine.Queue.LOOP_DONT_RECURSE = true;
+
+jasmine.Queue.prototype.next_ = function() {
+ var self = this;
+ var goAgain = true;
+
+ while (goAgain) {
+ goAgain = false;
+
+ if (self.index < self.blocks.length && !(this.abort && !this.ensured[self.index])) {
+ var calledSynchronously = true;
+ var completedSynchronously = false;
+
+ var onComplete = function () {
+ if (jasmine.Queue.LOOP_DONT_RECURSE && calledSynchronously) {
+ completedSynchronously = true;
+ return;
+ }
+
+ if (self.blocks[self.index].abort) {
+ self.abort = true;
+ }
+
+ self.offset = 0;
+ self.index++;
+
+ var now = new Date().getTime();
+ if (self.env.updateInterval && now - self.env.lastUpdate > self.env.updateInterval) {
+ self.env.lastUpdate = now;
+ self.env.setTimeout(function() {
+ self.next_();
+ }, 0);
+ } else {
+ if (jasmine.Queue.LOOP_DONT_RECURSE && completedSynchronously) {
+ goAgain = true;
+ } else {
+ self.next_();
+ }
+ }
+ };
+ self.blocks[self.index].execute(onComplete);
+
+ calledSynchronously = false;
+ if (completedSynchronously) {
+ onComplete();
+ }
+
+ } else {
+ self.running = false;
+ if (self.onComplete) {
+ self.onComplete();
+ }
+ }
+ }
+};
+
+jasmine.Queue.prototype.results = function() {
+ var results = new jasmine.NestedResults();
+ for (var i = 0; i < this.blocks.length; i++) {
+ if (this.blocks[i].results) {
+ results.addResult(this.blocks[i].results());
+ }
+ }
+ return results;
+};
+
+
+/**
+ * Runner
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ */
+jasmine.Runner = function(env) {
+ var self = this;
+ self.env = env;
+ self.queue = new jasmine.Queue(env);
+ self.before_ = [];
+ self.after_ = [];
+ self.suites_ = [];
+};
+
+jasmine.Runner.prototype.execute = function() {
+ var self = this;
+ if (self.env.reporter.reportRunnerStarting) {
+ self.env.reporter.reportRunnerStarting(this);
+ }
+ self.queue.start(function () {
+ self.finishCallback();
+ });
+};
+
+jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) {
+ beforeEachFunction.typeName = 'beforeEach';
+ this.before_.splice(0,0,beforeEachFunction);
+};
+
+jasmine.Runner.prototype.afterEach = function(afterEachFunction) {
+ afterEachFunction.typeName = 'afterEach';
+ this.after_.splice(0,0,afterEachFunction);
+};
+
+
+jasmine.Runner.prototype.finishCallback = function() {
+ this.env.reporter.reportRunnerResults(this);
+};
+
+jasmine.Runner.prototype.addSuite = function(suite) {
+ this.suites_.push(suite);
+};
+
+jasmine.Runner.prototype.add = function(block) {
+ if (block instanceof jasmine.Suite) {
+ this.addSuite(block);
+ }
+ this.queue.add(block);
+};
+
+jasmine.Runner.prototype.specs = function () {
+ var suites = this.suites();
+ var specs = [];
+ for (var i = 0; i < suites.length; i++) {
+ specs = specs.concat(suites[i].specs());
+ }
+ return specs;
+};
+
+jasmine.Runner.prototype.suites = function() {
+ return this.suites_;
+};
+
+jasmine.Runner.prototype.topLevelSuites = function() {
+ var topLevelSuites = [];
+ for (var i = 0; i < this.suites_.length; i++) {
+ if (!this.suites_[i].parentSuite) {
+ topLevelSuites.push(this.suites_[i]);
+ }
+ }
+ return topLevelSuites;
+};
+
+jasmine.Runner.prototype.results = function() {
+ return this.queue.results();
+};
+jasmine.Runner.prototype.filter = function (suiteIds, specIds) {
+ // convert [1, 2] into { 1: true, 2: true }
+ //
+ if (typeof suiteIds.length == 'number') {
+ suiteIds = jasmine.toMap(suiteIds);
+ }
+ if (typeof specIds.length == 'number') {
+ specIds = jasmine.toMap(specIds);
+ }
+
+ var specs = jasmine.getByIds(this.specs(), specIds),
+ suites = jasmine.getByIds(this.suites(), suiteIds),
+ blocks = [],
+ i, length, suite;
+
+ length = specs.length;
+ for (i = 0; i < length; i++) {
+ suite = specs[i].getRootSuite();
+ if (jasmine.array.indexOf(blocks, suite) === -1) {
+ suite.filter(suiteIds, specIds);
+ blocks.push(suite);
+ }
+ }
+
+ length = suites.length;
+ for (i = 0; i < length; i++) {
+ suite = suites[i].getRootSuite();
+ if (jasmine.array.indexOf(blocks, suite) === -1) {
+ suite.filter(suiteIds, specIds);
+ blocks.push(suite);
+ }
+ }
+
+ if (blocks.length) {
+ this.queue.blocks = blocks;
+ }
+
+ return this;
+};
+/**
+ * Internal representation of a Jasmine specification, or test.
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ * @param {jasmine.Suite} suite
+ * @param {String} description
+ */
+jasmine.Spec = function(env, suite, description) {
+ if (!env) {
+ throw new Error('jasmine.Env() required');
+ }
+ if (!suite) {
+ throw new Error('jasmine.Suite() required');
+ }
+ var spec = this;
+ spec.id = env.nextSpecId ? env.nextSpecId() : null;
+ spec.env = env;
+ spec.suite = suite;
+ spec.description = description;
+ spec.queue = new jasmine.Queue(env);
+
+ spec.afterCallbacks = [];
+ spec.spies_ = [];
+
+ spec.results_ = new jasmine.NestedResults();
+ spec.results_.description = description;
+ spec.matchersClass = null;
+};
+
+jasmine.Spec.prototype.getFullName = function() {
+ return this.suite.getFullName() + ' ' + this.description + '.';
+};
+
+
+jasmine.Spec.prototype.results = function() {
+ return this.results_;
+};
+
+/**
+ * All parameters are pretty-printed and concatenated together, then written to the spec's output.
+ *
+ * Be careful not to leave calls to <code>jasmine.log</code> in production code.
+ */
+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;
+};
+
+jasmine.Spec.prototype.addToQueue = function (block) {
+ if (this.queue.isRunning()) {
+ this.queue.insertNext(block);
+ } else {
+ this.queue.add(block);
+ }
+};
+
+/**
+ * @param {jasmine.ExpectationResult} 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;
+};
+
+/**
+ * Waits a fixed time period before moving to the next block.
+ *
+ * @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;
+};
+
+/**
+ * Waits for the latchFunction to return true before proceeding to the next block.
+ *
+ * @param {Function} latchFunction
+ * @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;
+
+ for (var i = 0; i < arguments.length; i++) {
+ var arg = arguments[i];
+ switch (typeof arg) {
+ case 'function':
+ latchFunction_ = arg;
+ break;
+ case 'string':
+ optional_timeoutMessage_ = arg;
+ break;
+ case 'number':
+ optional_timeout_ = arg;
+ break;
+ }
+ }
+
+ 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();
+ if (onComplete) {
+ onComplete();
+ }
+};
+
+jasmine.Spec.prototype.after = function(doAfter) {
+ if (this.queue.isRunning()) {
+ this.queue.add(new jasmine.Block(this.env, doAfter, this), true);
+ } else {
+ this.afterCallbacks.unshift(doAfter);
+ }
+};
+
+jasmine.Spec.prototype.execute = function(onComplete) {
+ var spec = this;
+ if (!spec.env.specFilter(spec)) {
+ spec.results_.skipped = true;
+ spec.finish(onComplete);
+ return;
+ }
+
+ this.env.reporter.reportSpecStarting(this);
+
+ spec.env.currentSpec = spec;
+
+ spec.addBeforesAndAftersToQueue();
+
+ spec.queue.start(function () {
+ spec.finish(onComplete);
+ });
+};
+
+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));
+ }
+ }
+ for (i = 0; i < runner.before_.length; i++) {
+ 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);
+ }
+ 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);
+ }
+ }
+ for (i = 0; i < runner.after_.length; i++) {
+ 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.spyOn = function(obj, methodName, ignoreMethodDoesntExist) {
+ if (obj == jasmine.undefined) {
+ throw "spyOn could not find an object to spy upon for " + methodName + "()";
+ }
+
+ if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) {
+ throw methodName + '() method does not exist';
+ }
+
+ if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) {
+ throw new Error(methodName + ' has already been spied upon');
+ }
+
+ var spyObj = jasmine.createSpy(methodName);
+
+ this.spies_.push(spyObj);
+ spyObj.baseObj = obj;
+ spyObj.methodName = methodName;
+ spyObj.originalValue = obj[methodName];
+
+ obj[methodName] = spyObj;
+
+ return spyObj;
+};
+
+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;
+ }
+ this.spies_ = [];
+};
+
+(function () {
+ var _Spec = jasmine.Spec,
+ proto = _Spec.prototype;
+
+ jasmine.Spec = function () {
+ _Spec.apply(this, arguments);
+ this.fileName = jasmine.getCurrentScript();
+ this.id = jasmine.hashString(this.getFullName(), this.suite.id);
+ };
+
+ jasmine.Spec.prototype = proto;
+
+ // Override: adds the error to the result
+ proto.fail = function (e) {
+ var expectationResult = new jasmine.ExpectationResult({
+ passed: false,
+ message: e ? jasmine.util.formatException(e) : 'Exception'
+ });
+ // Modification start
+ if (e instanceof Error) {
+ expectationResult.error = e;
+ }
+ // Modification end
+ this.results_.addResult(expectationResult);
+ };
+
+ proto.execute = function(onComplete) {
+ var spec = this;
+ if (!spec.env.specFilter(spec)) {
+ spec.results_.skipped = true;
+ onComplete();
+ return;
+ }
+
+ this.env.reporter.reportSpecStarting(this);
+
+ if (spec.isDisabled()) {
+ spec.results_.skipped = true;
+ spec.finish(onComplete);
+ return;
+ }
+
+ spec.env.currentSpec = spec;
+
+ spec.addBeforesAndAftersToQueue();
+
+ if (spec.debugBlocks && jasmine.getOptions().debug === true) {
+ var blockIdx = jasmine.getOptions().block;
+ if (typeof blockIdx !== 'undefined') {
+ blockIdx = parseInt(blockIdx);
+ var blocks = this.queue.blocks,
+ length = blocks.length,
+ i = 0,
+ block;
+
+ for (; i < length; i++) {
+ block = blocks[i];
+ if (i === blockIdx) {
+ block.func = jasmine.generateDebuggableBlock(block.func);
+ }
+ }
+ }
+ jasmine.showDebugPrompt(function() {
+ spec.queue.start(function () {
+ spec.finish(onComplete);
+ });
+ });
+ } else {
+ spec.queue.start(function () {
+ spec.finish(onComplete);
+ });
+ }
+ };
+
+ proto.enabled = true;
+
+ proto.isEnabled = function() {
+ return this.enabled;
+ };
+
+ proto.isDisabled = function() {
+ return !this.enabled;
+ };
+
+ proto.disable = function() {
+ this.enabled = false;
+
+ return this;
+ };
+
+ proto.enable = function() {
+ this.enabled = true;
+
+ return this;
+ };
+
+ proto.getRootSuite = function() {
+ var suite = this.suite;
+
+ while (suite.parentSuite) {
+ suite = suite.parentSuite;
+ }
+
+ return suite;
+ };
+})();
+
+/**
+ * Works just like waits() and waitsFor(), except waits for the next animationFrame
+ */
+function waitsForAnimation() {
+ runs(function() {
+ var done = false;
+ Ext.Function.requestAnimationFrame(function() {
+ done = true;
+ });
+ waitsFor(function() {
+ return done;
+ });
+ });
+}
+/**
+ * Internal representation of a Jasmine suite.
+ *
+ * @constructor
+ * @param {jasmine.Env} env
+ * @param {String} description
+ * @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;
+ for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) {
+ fullName = parentSuite.description + ' ' + 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.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.results = function() {
+ return this.queue.results();
+};
+
+jasmine.Suite.prototype.add = function(suiteOrSpec) {
+ this.children_.push(suiteOrSpec);
+ if (suiteOrSpec instanceof jasmine.Suite) {
+ this.suites_.push(suiteOrSpec);
+ this.env.currentRunner().addSuite(suiteOrSpec);
+ } else {
+ this.specs_.push(suiteOrSpec);
+ }
+ this.queue.add(suiteOrSpec);
+};
+
+jasmine.Suite.prototype.specs = function() {
+ return this.specs_;
+};
+
+jasmine.Suite.prototype.suites = function() {
+ return this.suites_;
+};
+
+jasmine.Suite.prototype.children = function() {
+ return this.children_;
+};
+
+jasmine.Suite.prototype.execute = function(onComplete) {
+ var self = this;
+ this.queue.start(function () {
+ self.finish(onComplete);
+ });
+};
+(function () {
+ var _Suite = jasmine.Suite,
+ proto = _Suite.prototype;
+
+ jasmine.Suite = function () {
+ _Suite.apply(this, arguments);
+
+ var parentSuite = this.parentSuite;
+ this.fileName = jasmine.getCurrentScript();
+ this.id = jasmine.hashString(this.getFullName(), parentSuite ? parentSuite.id : 0);
+ };
+
+ jasmine.Suite.prototype = proto;
+
+ proto.execute = function(onComplete) {
+ var self = this;
+ self.env.reporter.reportSuiteStarting(self); // override
+
+ if (self.isDisabled()) {
+ self.results = self.forceSkippedResults;
+ self.disableChildren();
+ }
+
+ this.queue.start(function () {
+ self.finish(onComplete);
+ });
+ };
+
+ proto.enabled = true;
+
+ proto.isEnabled = function() {
+ return this.enabled;
+ };
+
+ proto.isDisabled = function() {
+ return !this.enabled;
+ };
+
+ proto.disable = function() {
+ this.enabled = false;
+ return this;
+ };
+
+ proto.enable = function() {
+ this.enabled = true;
+ return this;
+ };
+
+ proto.forceSkippedResults = function() {
+ var results = this.queue.results();
+ results.skipped = true;
+ return results;
+ };
+
+ proto.disableChildren = function() {
+ var children = this.children(),
+ length = children.length,
+ i = 0;
+
+ for (; i < length; i++) {
+ children[i].disable();
+ }
+
+ return this;
+ };
+
+ proto.filter = function (suiteIds, specIds) {
+
+ if (!suiteIds[this.id]) {
+ var specs = this.specs(),
+ suites = this.suites(),
+ spec, i, suite, length;
+
+ length = specs.length;
+
+ for (i = 0; i < length; i++) {
+ spec = specs[i];
+ if (!specIds[spec.id]) {
+ jasmine.array.remove(this.queue.blocks, spec);
+ }
+ }
+
+ length = suites.length;
+
+ for (i = 0; i < length; i++) {
+ suite = suites[i];
+ suite.filter(suiteIds, specIds);
+ if (suite.empty) {
+ jasmine.array.remove(this.queue.blocks, suite);
+ }
+ }
+
+ if (this.queue.blocks.length === 0) {
+ this.empty = true;
+ }
+ }
+
+ return this;
+ };
+
+ proto.getRootSuite = function() {
+ var suite = this;
+
+ while (suite.parentSuite) {
+ suite = suite.parentSuite;
+ }
+
+ return suite;
+ };
+
+})();
+jasmine.WaitsBlock = function(env, timeout, spec) {
+ this.timeout = timeout;
+ jasmine.Block.call(this, env, null, spec);
+};
+
+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.setTimeout(function () {
+ onComplete();
+ }, this.timeout);
+};
+/**
+ * A block which waits for some condition to become true, with timeout.
+ *
+ * @constructor
+ * @extends jasmine.Block
+ * @param {jasmine.Env} env The Jasmine environment.
+ * @param {Number} timeout The maximum time in milliseconds to wait for the condition to become true.
+ * @param {Function} latchFunction A function which returns true when the desired condition has been met.
+ * @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.TIMEOUT_INCREMENT = 10;
+
+jasmine.WaitsForBlock.prototype.execute = function(onComplete) {
+ if (jasmine.VERBOSE) {
+ this.env.reporter.log('>> Jasmine waiting for ' + (this.message || 'something to happen'));
+ }
+ var latchFunctionResult;
+ try {
+ latchFunctionResult = this.latchFunction.apply(this.spec);
+ } catch (e) {
+ this.spec.fail(e);
+ onComplete();
+ return;
+ }
+
+ if (latchFunctionResult) {
+ onComplete();
+ } else if (this.totalTimeSpentWaitingForLatch >= this.timeout) {
+ 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();
+ } else {
+ this.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT;
+ var self = this;
+ this.env.setTimeout(function() {
+ self.execute(onComplete);
+ }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT);
+ }
+};
+// Mock setTimeout, clearTimeout
+// Contributed by Pivotal Computer Systems, www.pivotalsf.com
+
+jasmine.FakeTimer = function() {
+ this.reset();
+
+ var self = this;
+ self.setTimeout = function(funcToCall, millis) {
+ self.timeoutsMade++;
+ self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
+ return self.timeoutsMade;
+ };
+
+ self.setInterval = function(funcToCall, millis) {
+ self.timeoutsMade++;
+ self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
+ return self.timeoutsMade;
+ };
+
+ self.clearTimeout = function(timeoutKey) {
+ self.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ };
+
+ self.clearInterval = function(timeoutKey) {
+ self.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ };
+
+};
+
+jasmine.FakeTimer.prototype.reset = function() {
+ this.timeoutsMade = 0;
+ this.scheduledFunctions = {};
+ this.nowMillis = 0;
+};
+
+jasmine.FakeTimer.prototype.tick = function(millis) {
+ var oldMillis = this.nowMillis;
+ var newMillis = oldMillis + millis;
+ this.runFunctionsWithinRange(oldMillis, newMillis);
+ this.nowMillis = newMillis;
+};
+
+jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
+ var scheduledFunc;
+ var funcsToRun = [];
+ for (var timeoutKey in this.scheduledFunctions) {
+ scheduledFunc = this.scheduledFunctions[timeoutKey];
+ if (scheduledFunc != jasmine.undefined &&
+ scheduledFunc.runAtMillis >= oldMillis &&
+ scheduledFunc.runAtMillis <= nowMillis) {
+ funcsToRun.push(scheduledFunc);
+ this.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ }
+ }
+
+ if (funcsToRun.length > 0) {
+ funcsToRun.sort(function(a, b) {
+ return a.runAtMillis - b.runAtMillis;
+ });
+ for (var i = 0; i < funcsToRun.length; ++i) {
+ try {
+ var funcToRun = funcsToRun[i];
+ this.nowMillis = funcToRun.runAtMillis;
+ funcToRun.funcToCall();
+ if (funcToRun.recurring) {
+ this.scheduleFunction(funcToRun.timeoutKey,
+ funcToRun.funcToCall,
+ funcToRun.millis,
+ true);
+ }
+ } catch(e) {
+ }
+ }
+ this.runFunctionsWithinRange(oldMillis, nowMillis);
+ }
+};
+
+jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
+ this.scheduledFunctions[timeoutKey] = {
+ runAtMillis: this.nowMillis + millis,
+ funcToCall: funcToCall,
+ recurring: recurring,
+ timeoutKey: timeoutKey,
+ millis: millis
+ };
+};
+
+/**
+ * @namespace
+ */
+jasmine.Clock = {
+ defaultFakeTimer: new jasmine.FakeTimer(),
+
+ reset: function() {
+ jasmine.Clock.assertInstalled();
+ jasmine.Clock.defaultFakeTimer.reset();
+ },
+
+ tick: function(millis) {
+ jasmine.Clock.assertInstalled();
+ jasmine.Clock.defaultFakeTimer.tick(millis);
+ },
+
+ runFunctionsWithinRange: function(oldMillis, nowMillis) {
+ jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
+ },
+
+ scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
+ jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
+ },
+
+ useMock: function() {
+ if (!jasmine.Clock.isInstalled()) {
+ var spec = jasmine.getEnv().currentSpec;
+ spec.after(jasmine.Clock.uninstallMock);
+
+ jasmine.Clock.installMock();
+ }
+ },
+
+ installMock: function() {
+ jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer;
+ },
+
+ uninstallMock: function() {
+ jasmine.Clock.assertInstalled();
+ jasmine.Clock.installed = jasmine.Clock.real;
+ },
+
+ real: {
+ setTimeout: jasmine.getGlobal().setTimeout,
+ clearTimeout: jasmine.getGlobal().clearTimeout,
+ setInterval: jasmine.getGlobal().setInterval,
+ clearInterval: jasmine.getGlobal().clearInterval
+ },
+
+ assertInstalled: function() {
+ if (!jasmine.Clock.isInstalled()) {
+ throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()");
+ }
+ },
+
+ isInstalled: function() {
+ return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer;
+ },
+
+ installed: null
+};
+jasmine.Clock.installed = jasmine.Clock.real;
+
+//else for IE support
+jasmine.getGlobal().setTimeout = function(funcToCall, millis) {
+ if (jasmine.Clock.installed.setTimeout.apply) {
+ return jasmine.Clock.installed.setTimeout.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.setTimeout(funcToCall, millis);
+ }
+};
+
+jasmine.getGlobal().setInterval = function(funcToCall, millis) {
+ if (jasmine.Clock.installed.setInterval.apply) {
+ return jasmine.Clock.installed.setInterval.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.setInterval(funcToCall, millis);
+ }
+};
+
+jasmine.getGlobal().clearTimeout = function(timeoutKey) {
+ if (jasmine.Clock.installed.clearTimeout.apply) {
+ return jasmine.Clock.installed.clearTimeout.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.clearTimeout(timeoutKey);
+ }
+};
+
+jasmine.getGlobal().clearInterval = function(timeoutKey) {
+ if (jasmine.Clock.installed.clearTimeout.apply) {
+ return jasmine.Clock.installed.clearInterval.apply(this, arguments);
+ } else {
+ return jasmine.Clock.installed.clearInterval(timeoutKey);
+ }
+};
+
+/**
+ * Utility function to fire a fake mouse event to a given target element
+ */
+jasmine.fireMouseEvent = function (target, type, x, y, button) {
+ var e,
+ doc,
+ docEl,
+ body,
+ ret;
+
+ target = Ext.getDom(target);
+ doc = target.ownerDocument || document;
+ x = x || 0;
+ y = y || 0;
+
+ if (doc.createEventObject){ // IE event model
+ e = doc.createEventObject();
+ docEl = doc.documentElement;
+ body = doc.body;
+ x = x + (docEl && docEl.clientLeft || 0) + (body && body.clientLeft || 0);
+ y = y + (docEl && docEl.clientTop || 0) + (body && body.clientLeft || 0);
+ Ext.apply(e, {
+ bubbles: true,
+ cancelable: true,
+ screenX: x,
+ screenY: y,
+ clientX: x,
+ clientY: y,
+ button: button || 1
+ });
+ ret = target.fireEvent('on' + type, e);
+ } else {
+ e = doc.createEvent("MouseEvents");
+ e.initMouseEvent(type, true, true, doc.defaultView || doc.parentWindow, 1, x, y, x, y, false, false, false, false, button || 0, null);
+ ret = target.dispatchEvent(e);
+ }
+
+ return (ret === false ? ret : e);
+};
+
+/**
+ * Fires a pointer event. Since PointerEvents cannot yet be directly constructed,
+ * we fake it by constructing a mouse event and setting its pointer id. This method
+ * should typically be used when (Ext.supports.PointerEvents || Ext.supports.MSPointerEvents).
+ * @param {String/Ext.Element/HTMLElement} target
+ * @param {String} type The name of the event to fire
+ * @param {Number} pointerId A unique id for the pointer, for more on pointerId see
+ * http://www.w3.org/TR/pointerevents/
+ * @param {Number} x The x coordinate
+ * @param {Number} y The y coordinate
+ * @param {Number} button
+ * @return {Boolean} true if the event was successfully dispatched
+ */
+jasmine.firePointerEvent = function(target, type, pointerId, x, y, button) {
+ var doc = document,
+ e = doc.createEvent("MouseEvents"),
+ target = Ext.getDom(target),
+ dispatched;
+
+ e.initMouseEvent(
+ type, // type
+ true, // canBubble
+ true, // cancelable
+ doc.defaultView || doc.parentWindow, // view
+ 1, // detail
+ x, // screenX
+ y, // screenY
+ x, // clientX
+ y, // clientY
+ false, // ctrlKey
+ false, // altKey
+ false, // shiftKey
+ false, // metaKey
+ button || 0, // button
+ null // relatedTarget
+ );
+ e.pointerId = pointerId || 1;
+ target.setPointerCapture = Ext.emptyFn;
+
+ dispatched = target.dispatchEvent(e);
+
+ delete target.setPointerCapture;
+
+ return dispatched;
+};
+
+jasmine.createTouchList = function(touchList, target) {
+ var doc = document,
+ i = 0,
+ ln = touchList.length,
+ touches = [],
+ touchCfg;
+
+ for (; i < ln; i++) {
+ touchCfg = touchList[i];
+ touches.push(doc.createTouch(
+ doc.defaultView || doc.parentWindow,
+ touchCfg.target || target,
+ // use 1 as the default ID, so that tests that are only concerned with a single
+ // touch event don't need to worry about providing an ID
+ touchCfg.identifier || 1,
+ touchCfg.pageX,
+ touchCfg.pageY,
+ touchCfg.screenX || touchCfg.pageX, // use pageX/Y as the default for screenXY
+ touchCfg.screenY || touchCfg.pageY
+ ));
+ }
+
+ return doc.createTouchList.apply(doc, touches);
+};
+
+/**
+ * Utility for emulating a touch event. This method should typically only be used when
+ * Ext.supports.TouchEvents. Recommended reading for understanding how touch events work:
+ * http://www.w3.org/TR/touch-events/
+ * @param {String/Ext.Element/HTMLElement} target
+ * @param {String} type The name of the event to fire
+ * @param {Object[]} touches An array of config objects for constructing the event object's
+ * "touches". The config objects conform to the following interface:
+ * http://www.w3.org/TR/touch-events/#idl-def-Touch The only required properties
+ * are pageX and pageY. this method provides defaults for the others.
+ * @param {Object[]} changedTouches An array of config objects for constructing the event
+ * object's "changedTouches" (defaults to the same value as the `touches` param)
+ * @param {Object[]} targetTouches An array of config objects for constructing the event
+ * object's "targetTouches" (defaults to the same value as the `touches` param)
+ * @param {Number} scale
+ * @param {Number} rotation
+ * @return {Boolean} true if the event was successfully dispatched
+ */
+jasmine.fireTouchEvent = function(target, type, touches, changedTouches, targetTouches) {
+ var doc = document,
+ // Couldn't figure out how to set touches, changedTouches targetTouches on a "real"
+ // TouchEvent, initTouchEvent seems to ignore the parameters documented here:
+ // https://developer.apple.com/library/safari/documentation/UserExperience/Reference/TouchEventClassReference/TouchEvent/TouchEvent.htmlTouchLists
+ // Apparently directly assigning to e.touches after creating a TouchEvent doesn't
+ // work either so the best we can do is just make a CustomEvent and fake it.
+ e = new CustomEvent(type, {
+ bubbles: true,
+ cancelable: true
+ }),
+ target = Ext.getDom(target);
+
+ Ext.apply(e, {
+ target: target,
+ touches: jasmine.createTouchList(touches, target),
+ changedTouches: jasmine.createTouchList(changedTouches ? changedTouches : touches, target),
+ targetTouches: jasmine.createTouchList(targetTouches ? targetTouches : touches, target)
+ });
+
+ return target.dispatchEvent(e);
+};
+
+/**
+ * Utility function to fire a fake key event to a given target element
+ */
+jasmine.fireKeyEvent = function(target, type, key) {
+ var e,
+ doc;
+ target = Ext.getDom(target);
+ doc = target.ownerDocument || document;
+ if (doc.createEventObject) { //IE event model
+ e = doc.createEventObject();
+ Ext.apply(e, {
+ bubbles: true,
+ cancelable: true,
+ keyCode: key
+ });
+ return target.fireEvent('on' + type, e);
+ } else {
+ e = doc.createEvent("Events");
+ e.initEvent(type, true, true);
+ e.keyCode = key;
+ return target.dispatchEvent(e);
+ }
+};
+
+/*
+This version is commented out because there is a bug in WebKit that prevents
+key events to be fired with both options and a valid keycode. When the bug gets fixed
+this method can be reintroduced. See https://bugs.webkit.org/show_bug.cgi?id=16735
+jasmine.fireKeyEvent = function(target, type, key, options) {
+ var e, ret, prop;
+
+ options = options || {};
+ target = Ext.getDom(target);
+ if (document.createEventObject) { //IE event model
+ e = document.createEventObject();
+ Ext.apply(e, {
+ bubbles: true,
+ cancelable: true,
+ keyCode: key
+ });
+ if (options) {
+ for (prop in options) {
+ if (options.hasOwnProperty(prop)) {
+ e[prop] = options[prop];
+ }
+ }
+ }
+ return target.fireEvent('on' + type, e);
+ }
+ else {
+ e = document.createEvent('KeyboardEvent');
+ if (typeof e.initKeyboardEvent != 'undefined') {
+ e.initKeyboardEvent(type, true, true, window,
+ false,
+ false,
+ false,
+ false, 97, 97);
+ } else {
+ e.initKeyEvent(type, true, true, window,
+ options.ctrlKey || false,
+ options.altKey || false,
+ options.shiftKey || false,
+ options.metaKey || false, key, key);
+ }
+ return target.dispatchEvent(e);
+ }
+};
+*/
+var fakeScope = {
+ id: "fakeScope",
+ fakeScope: true
+};
+/**
+ * Class to act as a bridge between the MockAjax class and Ext.data.Connection
+ */
+var MockAjaxManager = {
+
+ getXhrInstance: null,
+
+ /**
+ * Pushes methods onto the Connection prototype to make it easier to deal with
+ */
+ addMethods: function(){
+ var Connection = Ext.data.Connection,
+ proto = Connection.prototype;
+
+ Connection.requestId = 0;
+ MockAjaxManager.getXhrInstance = proto.getXhrInstance;
+
+ /**
+ * Template method to create the AJAX request
+ */
+ proto.getXhrInstance = function(){
+ return new MockAjax();
+ };
+
+ /**
+ * Method to simulate a request completing
+ * @param {Object} response The response
+ * @param {String} id (optional) The id of the completed request
+ */
+ proto.mockComplete = function(response, id){
+ this.mockGetRequestXHR(id).xhr.complete(response);
+ };
+
+ /**
+ * Get a particular request
+ * @param {String} id (optional) The id of the request
+ */
+ proto.mockGetRequestXHR = function(id){
+ var request;
+
+ if (id) {
+ request = this.requests[id];
+ } else {
+ // get the first one
+ request = this.mockGetAllRequests()[0];
+ }
+ return request ? request : null;
+ };
+
+ /**
+ * Gets all the requests from the Connection
+ */
+ proto.mockGetAllRequests = function(){
+ var requests = this.requests,
+ id,
+ request,
+ out = [];
+
+ for (id in requests) {
+ if (requests.hasOwnProperty(id)) {
+ out.push(requests[id]);
+ }
+ }
+ return out;
+ };
+
+ this.originalExtAjax = Ext.Ajax;
+ Ext.Ajax = new Connection({autoAbort : false});
+ },
+
+ /**
+ * Restore any changes made by addMethods
+ */
+ removeMethods: function(){
+ var proto = Ext.data.Connection.prototype;
+ delete proto.mockComplete;
+ delete proto.mockGetRequestXHR;
+ proto.getXhrInstance = MockAjaxManager.getXhrInstance;
+ Ext.Ajax = this.originalExtAjax;
+ }
+};
+
+/**
+ * Simple Mock class to represent an XMLHttpRequest
+ */
+var MockAjax = function(){
+ /**
+ * Contains all request headers
+ */
+ this.headers = {};
+
+ /**
+ * Contains any options specified during sending
+ */
+ this.ajaxOptions = {};
+
+ this.readyState = 0;
+
+ this.status = null;
+
+ this.responseText = this.responseXML = null;
+};
+
+/**
+ * Contains a default response for any synchronous request.
+ */
+MockAjax.prototype.syncDefaults = {
+ responseText: 'data',
+ status: 200,
+ statusText: '',
+ responseXML: null,
+ responseHeaders: {"Content-type": "application/json" }
+};
+
+MockAjax.prototype.readyChange = function() {
+ if (this.onreadystatechange) {
+ this.onreadystatechange();
+ }
+};
+
+/**
+ * Simulate the XHR open method
+ * @param {Object} method
+ * @param {Object} url
+ * @param {Object} async
+ * @param {Object} username
+ * @param {Object} password
+ */
+MockAjax.prototype.open = function(method, url, async, username, password){
+ var options = this.ajaxOptions;
+ options.method = method;
+ options.url = url;
+ options.async = async;
+ options.username = username;
+ options.password = password;
+ this.readyState = 1;
+ this.readyChange();
+};
+
+/**
+ * Simulate the XHR send method
+ * @param {Object} data
+ */
+MockAjax.prototype.send = function(data){
+ this.ajaxOptions.data = data;
+ this.readyState = 2;
+ // if it's a synchronous request, let's just assume it's already finished
+ if (!this.ajaxOptions.async) {
+ this.complete(this.syncDefaults);
+ } else {
+ this.readyChange();
+ }
+};
+
+/**
+ * Simulate the XHR abort method
+ */
+MockAjax.prototype.abort = function(){
+ this.readyState = 0;
+ this.readyChange();
+};
+
+/**
+ * Simulate the XHR setRequestHeader method
+ * @param {Object} header
+ * @param {Object} value
+ */
+MockAjax.prototype.setRequestHeader = function(header, value){
+ this.headers[header] = value;
+};
+
+/**
+ * Simulate the XHR getAllResponseHeaders method
+ */
+MockAjax.prototype.getAllResponseHeaders = function(){
+ return '';
+};
+
+/**
+ * Simulate the XHR getResponseHeader method
+ * @param {Object} name
+ */
+MockAjax.prototype.getResponseHeader = function(name){
+ return this.headers[header];
+};
+
+/**
+ * Simulate the XHR onreadystatechange method
+ */
+MockAjax.prototype.onreadystatechange = function(){
+};
+
+/**
+ * Method for triggering a response completion
+ */
+MockAjax.prototype.complete = function(response){
+ this.responseText = response.responseText || '';
+ this.status = response.status;
+ this.statusText = response.statusText;
+ this.responseXML = response.responseXML || this.xmlDOM(response.responseText);
+ this.responseHeaders = response.responseHeaders || {"Content-type": response.contentType || "application/json" };
+ this.readyState = 4;
+ this.readyChange();
+};
+
+/**
+ * Converts string to XML DOM
+ */
+MockAjax.prototype.xmlDOM = function(xml) {
+ // IE DOMParser support
+ if (!window.DOMParser && window.ActiveXObject) {
+ doc = new ActiveXObject('Microsoft.XMLDOM');
+ doc.async = 'false';
+ DOMParser = function() {};
+ DOMParser.prototype.parseFromString = function(xmlString) {
+ var doc = new ActiveXObject('Microsoft.XMLDOM');
+ doc.async = 'false';
+ doc.loadXML(xmlString);
+ return doc;
+ };
+ }
+
+ try {
+ return (new DOMParser()).parseFromString(xml, "text/xml");
+ } catch (e) {
+ return null;
+ }
+};
+SenchaTestRunner = {
+ allowedGlobals: {},
+
+ specTimeout: 10 * 1000, // 10 secs
+
+ isRunning: function() {
+ if (!this.reporter) {
+ return false;
+ }
+
+ var isRunning = this.reporter.isRunning,
+ currentSpec = jasmine.getEnv().currentSpec,
+ testResult = currentSpec._testResult;
+
+ if (!isRunning || !currentSpec) {
+ return isRunning;
+ }
+
+ if (jasmine.getOptions().debug !== true && testResult) {
+ var duration = (new Date).getTime() - parseInt(testResult.startTime);
+ if (duration > this.specTimeout) {
+ throw new Error ("The spec '" + currentSpec.getFullName() + "' is taking more than " + (this.specTimeout/1000) + " seconds to complete.");
+ }
+ }
+
+ this.currentSpec = currentSpec;
+
+ return isRunning;
+
+ },
+
+ /**
+ * initializes the allowed globals object with all the propeties in the current
+ * window. Should be called after frameworks are loaded but before specs are loaded.
+ */
+ initGlobals: function() {
+ var me = this,
+ allowedGlobals = me.allowedGlobals,
+ prop;
+
+ for (prop in window) {
+ allowedGlobals[prop] = true;
+ }
+
+ // Old Firefox needs these
+ allowedGlobals.getInterface =
+ allowedGlobals.loadFirebugConsole =
+ allowedGlobals._createFirebugConsole =
+ allowedGlobals.netscape =
+ allowedGlobals.XPCSafeJSObjectWrapper =
+ allowedGlobals.XPCNativeWrapper =
+ allowedGlobals.Components =
+ allowedGlobals._firebug =
+ // IE10 F12 dev tools adds this property when opened.
+ allowedGlobals.__IE_DEVTOOLBAR_CONSOLE_COMMAND_LINE =
+ // we're going to add the addGlobal function to the window object, so specs can call it
+ allowedGlobals.addGlobal = true;
+ allowedGlobals.id = true; // In Ext JS 4 Ext.get(window) adds an id property
+
+ window.addGlobal = function() {
+ me.addGlobal.apply(me, arguments);
+ };
+ },
+
+ /**
+ * Add an allowed global variable.
+ * @param {String/Array} property The variable name, or array of names
+ */
+ addGlobal: function(property) {
+ var len;
+
+ if (property.charAt) { // string
+ this.allowedGlobals[property] = true;
+ } else { // array
+ for (len = property.length; len--;) {
+ this.allowedGlobals[property[len]] = true;
+ }
+ }
+ },
+
+ checkGlobals: function(spec) {
+ var allowedGlobals = this.allowedGlobals,
+ property, value;
+
+ for (property in window) {
+ value = window[property];
+ if (value !== undefined && !allowedGlobals[property] &&
+ (!value || // make sure we don't try to do a property lookup on a null value
+ // old browsers (IE6 and opera 11) add element IDs as enumerable properties
+ // of the window object, so make sure the global var is not a HTMLElement
+ value.nodeType !== 1 &&
+ // make sure it isn't a reference to a window object. This happens in
+ // some browsers (e.g. IE6) when the document contains iframes. The
+ // frames' window objects are referenced by id in the parent window object.
+ !(value.location && value.document))) {
+ spec.fail('Bad global variable: ' + property + ' = ' + value);
+ allowedGlobals[property] = true;
+ }
+ }
+ },
+
+ results : [],
+
+ Reporter : function() {
+ var me = this;
+ // some browsers add an empty text node in the document.body. This ensures
+ // we start with an emtpy body
+ document.body.innerHTML = '';
+ me.suites = {};
+ me.results = {
+ startTime: null,
+ endTime: null,
+ failures: 0,
+ suitesCount: 0,
+ specsCount: 0,
+ suites: []
+ };
+ SenchaTestRunner.reporter = this;
+ }
+};
+
+
+SenchaTestRunner.Reporter.prototype = {
+ initContextMapping: function() {
+// var xhr = new jasmine.XmlHttpRequest();
+// window.alert(SenchaTestRunner.testArtifactServerURL + "context-directory-mapping");
+// xhr.open("GET", SenchaTestRunner.testArtifactServerURL + "context-directory-mapping", false);
+// xhr.send(null);
+// if (xhr.status === 200) {
+// jasmine.contextMapping = JSON.parse(xhr.responseText);
+// } else {
+// jasmine.contextMapping = null;
+// }
+ },
+
+ reportRunnerStarting: function() {
+ this.initContextMapping();
+ this.isRunning = true;
+ },
+
+ reportRunnerResults: function() {
+ this.isRunning = false;
+ Ext.cmd.api.adapter.onTestsDone();
+ },
+
+ extractRe: /((http:\/\/|file:\/\/\/).*\.js)[^:]*:(\d*)/,
+
+ extractFileAndLine: function(line) {
+ var result = line.match(this.extractRe);
+
+ if (!result) {
+ return null;
+ }
+
+ return {
+ fileName : result[1],
+ lineNumber : parseInt(result[3], 10)
+ };
+ },
+
+ extractStackTrace: function(error) {
+ var stack = error.stack || error.stackTrace,
+ results = [],
+ lines, line, length, i, extract, fileName, lineNumber;
+
+ if (stack) {
+ lines = stack.split("\n");
+ length = lines.length;
+ for (i = 0; i < length; i++) {
+ line = lines[i];
+ if (line.search(jasmine.util.getOrigin() + "/jasmine.js") === -1) {
+ extract = this.extractFileAndLine(line);
+ if (extract) {
+ results.push(extract);
+ }
+ }
+ }
+ } else {
+ fileName = error.sourceURL || error.fileName;
+ lineNumber = error.line || error.lineNumber;
+
+ if (fileName && lineNumber) {
+ results.push({
+ fileName : fileName,
+ lineNumber : lineNumber
+ });
+ }
+ }
+ return results;
+ },
+
+ filterRe: /\n|\t|\r|\v|'|"|="|=/g,
+
+ filterChars: function(string) {
+ return jasmine.util.htmlEscape(string).replace(this.filterRe, ' ');
+ },
+
+ reportSpecStarting: function(spec) {
+ var me = this,
+ testResult = {
+ startTime: (new Date).getTime()
+ };
+
+ spec.startTime = (new Date).getTime();
+ spec._testResult = testResult;
+ },
+
+ reportSpecResults: function(spec) {
+ var blocksArray = [],
+ blocks = spec.queue.blocks,
+ block,
+ results,
+ result,
+ length,
+ i,
+ expectation,
+ testResult = spec._testResult,
+ suiteTestResult = spec.suite && spec.suite._testResult;
+
+ this.checkForCleanup(spec);
+
+ testResult.description = this.filterChars(spec.description);
+ testResult.hash = '' + spec.id;
+ testResult.fileName = spec.fileName;
+ testResult.expectations = [];
+ testResult.duration = (new Date).getTime() - testResult.startTime;
+ testResult.passed = spec.results().passed();
+
+ if (!testResult.passed) {
+ if(suiteTestResult) {
+ suiteTestResult.failures++;
+ suiteTestResult.passed = false;
+ }
+ }
+
+ results = spec.results().getItems();
+
+ length = results.length;
+ for (i = 0; i < length; i++) {
+ result = results[i];
+
+ if (result.type === 'expect') {
+
+ expectation = {
+ description: result.message
+ };
+
+ if (!result.passed() && result.error) {
+ expectation.stackTrace = this.extractStackTrace(result.error);
+ }
+
+ if (result.passed()) {
+ expectation.passed = true;
+ } else {
+ expectation.passed = false;
+ }
+
+ testResult.expectations.push(expectation);
+ }
+ }
+
+ length = blocks.length;
+ i = 0;
+ for (; i < length; i++) {
+ block = blocks[i];
+ if (block.func && block.func.typeName) {
+ blocksArray.push({
+ idx: i,
+ fn: block.func.toString(),
+ typeName: block.func.typeName
+ });
+ }
+ }
+
+ testResult.blocks = blocksArray;
+ Ext.cmd.api.adapter.onTestResult(testResult);
+ delete spec._testResult;
+ },
+
+ reportSuiteStarting: function(suite) {
+ var testResult = {
+ startTime: (new Date).getTime(),
+ failures: 0,
+ passed: true
+ };
+
+ suite._testResult = testResult;
+ },
+
+ reportSuiteResults: function(suite) {
+ var testResult = suite._testResult,
+ parentTestResult = suite.parentSuite && suite.parentSuite._testResult;
+
+ testResult.description = this.filterChars(suite.description);
+ testResult.hash = '' + suite.id;
+ testResult.duration = (new Date).getTime() - testResult.startTime;
+
+ if (parentTestResult) {
+ parentTestResult.failures += testResult.failures;
+ if (!testResult.passed) {
+ parentTestResult.passed = false;
+ }
+ }
+
+ Ext.cmd.api.adapter.onTestResult(testResult);
+ delete suite._testResult;
+ },
+
+ checkDom: function(spec) {
+ var body = document.body,
+ children = body && body.childNodes || [],
+ len = children.length,
+ badNodes = [],
+ i = 0;
+
+ for (; i < len; i++) {
+ if (children[i].nodeType === 3 || !children[i].getAttribute('data-sticky')) {
+ badNodes.push(children[i]);
+ }
+ }
+
+ for (i = 0, len = badNodes.length; i < len; i++) {
+ document.body.removeChild(badNodes[i]);
+ }
+
+ if (badNodes.length) {
+ spec.fail('document.body contains childNodes after spec execution');
+ }
+ },
+
+ checkForCleanup: function(spec) {
+ this.checkDom(spec);
+ SenchaTestRunner.checkGlobals(spec);
+ }
+};
+
+// The initGlobals() method adds all currently enumerable window properties to a list of
+// allowed globals. It needs to be called after Ext and jasmine are loaded, but before any
+// of the spec files are executed. This ensures that bad globals defined in the spec
+// files do not get added to the list of allowed globals.
+
+
+
+SenchaTestRunner.initGlobals();