diff --git a/doc/files.html b/doc/files.html index 31891cbd..7bb4757a 100644 --- a/doc/files.html +++ b/doc/files.html @@ -442,7 +442,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:45 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 195b8765..bfa48e69 100644 --- a/doc/index.html +++ b/doc/index.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:45 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 6882366b..e060d473 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -1116,7 +1116,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:43 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index 4a0e4b6d..6aac00ae 100644 --- a/doc/symbols/jasmine.Block.html +++ b/doc/symbols/jasmine.Block.html @@ -411,7 +411,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:43 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Clock.html b/doc/symbols/jasmine.Clock.html index 3d6eb2a9..19cccafa 100644 --- a/doc/symbols/jasmine.Clock.html +++ b/doc/symbols/jasmine.Clock.html @@ -301,6 +301,15 @@ ul.inheritsList + + <static>   + +
jasmine.Clock.isInstalled() +
+
+ + + <static>   @@ -451,6 +460,31 @@ ul.inheritsList +
+ + +
<static> + + + jasmine.Clock.isInstalled() + +
+
+ + + +
+ + + + + + + + + + +
@@ -672,7 +706,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:43 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index 0fd97fcb..ed1f9147 100644 --- a/doc/symbols/jasmine.Env.html +++ b/doc/symbols/jasmine.Env.html @@ -1204,7 +1204,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:43 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index 37d6361c..4faebf4a 100644 --- a/doc/symbols/jasmine.JsApiReporter.html +++ b/doc/symbols/jasmine.JsApiReporter.html @@ -816,7 +816,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:43 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Matchers.html b/doc/symbols/jasmine.Matchers.html index abf9c783..a8adefd7 100644 --- a/doc/symbols/jasmine.Matchers.html +++ b/doc/symbols/jasmine.Matchers.html @@ -1461,7 +1461,7 @@ a pattern or a String.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:44 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index 48392fd4..6a7fa1c1 100644 --- a/doc/symbols/jasmine.MultiReporter.html +++ b/doc/symbols/jasmine.MultiReporter.html @@ -388,7 +388,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:44 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index cfe41519..6a5e5435 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -704,7 +704,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:44 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index 3f1f70b0..7bb601b9 100644 --- a/doc/symbols/jasmine.Reporter.html +++ b/doc/symbols/jasmine.Reporter.html @@ -568,7 +568,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:44 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index fe0a20d0..01c3fa5b 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -738,7 +738,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:44 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index 75b4fadc..f4c5f439 100644 --- a/doc/symbols/jasmine.Spec.html +++ b/doc/symbols/jasmine.Spec.html @@ -405,7 +405,7 @@ ul.inheritsList
log()
-
+
All parameters are pretty-printed and concatenated together, then written to the spec's output.
@@ -955,7 +955,9 @@ ul.inheritsList
- + All parameters are pretty-printed and concatenated together, then written to the spec's output. + +Be careful not to leave calls to jasmine.log in production code.
@@ -1202,7 +1204,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:44 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 8d9b2952..e377cbef 100644 --- a/doc/symbols/jasmine.Spy.html +++ b/doc/symbols/jasmine.Spy.html @@ -849,7 +849,7 @@ expect(foo.bar.callCount).toEqual(0);
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:44 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index 326f2794..958809be 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -767,7 +767,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:45 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 060c415a..b711d5ae 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -397,7 +397,7 @@ ul.inheritsList
jasmine.log()
-
+
All parameters are pretty-printed and concatenated together, then written to the current spec's output.
@@ -883,7 +883,9 @@ large in one call.
- + All parameters are pretty-printed and concatenated together, then written to the current spec's output. + +Be careful not to leave calls to jasmine.log in production code.
@@ -1239,7 +1241,7 @@ large in one call.
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:43 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index 018ee913..38ea3a8c 100644 --- a/doc/symbols/jasmine.util.html +++ b/doc/symbols/jasmine.util.html @@ -529,7 +529,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Wed Jun 23 2010 11:30:45 GMT-0700 (PDT)
diff --git a/doc/symbols/src/src_Spec.js.html b/doc/symbols/src/src_Spec.js.html index 83a6f963..72f3a5cf 100644 --- a/doc/symbols/src/src_Spec.js.html +++ b/doc/symbols/src/src_Spec.js.html @@ -44,169 +44,174 @@ 37 return this.results_; 38 }; 39 - 40 jasmine.Spec.prototype.log = function() { - 41 return this.results_.log(arguments); - 42 }; - 43 - 44 jasmine.Spec.prototype.runs = function (func) { - 45 var block = new jasmine.Block(this.env, func, this); - 46 this.addToQueue(block); - 47 return this; - 48 }; - 49 - 50 jasmine.Spec.prototype.addToQueue = function (block) { - 51 if (this.queue.isRunning()) { - 52 this.queue.insertNext(block); - 53 } else { - 54 this.queue.add(block); - 55 } - 56 }; - 57 - 58 /** - 59 * @param {jasmine.ExpectationResult} result - 60 */ - 61 jasmine.Spec.prototype.addMatcherResult = function(result) { - 62 this.results_.addResult(result); - 63 }; - 64 - 65 jasmine.Spec.prototype.expect = function(actual) { - 66 var positive = new (this.getMatchersClass_())(this.env, actual, this); - 67 positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); - 68 return positive; - 69 }; - 70 - 71 jasmine.Spec.prototype.waits = function(timeout) { - 72 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); - 73 this.addToQueue(waitsFunc); - 74 return this; - 75 }; - 76 - 77 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { - 78 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); - 79 this.addToQueue(waitsForFunc); - 80 return this; - 81 }; - 82 - 83 jasmine.Spec.prototype.fail = function (e) { - 84 var expectationResult = new jasmine.ExpectationResult({ - 85 passed: false, - 86 message: e ? jasmine.util.formatException(e) : 'Exception' - 87 }); - 88 this.results_.addResult(expectationResult); - 89 }; - 90 - 91 jasmine.Spec.prototype.getMatchersClass_ = function() { - 92 return this.matchersClass || this.env.matchersClass; - 93 }; - 94 - 95 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { - 96 var parent = this.getMatchersClass_(); - 97 var newMatchersClass = function() { - 98 parent.apply(this, arguments); - 99 }; -100 jasmine.util.inherit(newMatchersClass, parent); -101 jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); -102 this.matchersClass = newMatchersClass; -103 }; -104 -105 jasmine.Spec.prototype.finishCallback = function() { -106 this.env.reporter.reportSpecResults(this); -107 }; -108 -109 jasmine.Spec.prototype.finish = function(onComplete) { -110 this.removeAllSpies(); -111 this.finishCallback(); -112 if (onComplete) { -113 onComplete(); -114 } -115 }; -116 -117 jasmine.Spec.prototype.after = function(doAfter) { -118 if (this.queue.isRunning()) { -119 this.queue.add(new jasmine.Block(this.env, doAfter, this)); -120 } else { -121 this.afterCallbacks.unshift(doAfter); -122 } -123 }; -124 -125 jasmine.Spec.prototype.execute = function(onComplete) { -126 var spec = this; -127 if (!spec.env.specFilter(spec)) { -128 spec.results_.skipped = true; -129 spec.finish(onComplete); -130 return; -131 } -132 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); -133 -134 spec.env.currentSpec = spec; -135 -136 spec.addBeforesAndAftersToQueue(); -137 -138 spec.queue.start(function () { -139 spec.finish(onComplete); -140 }); -141 }; + 40 /** + 41 * All parameters are pretty-printed and concatenated together, then written to the spec's output. + 42 * + 43 * Be careful not to leave calls to <code>jasmine.log</code> in production code. + 44 */ + 45 jasmine.Spec.prototype.log = function() { + 46 return this.results_.log(arguments); + 47 }; + 48 + 49 jasmine.Spec.prototype.runs = function (func) { + 50 var block = new jasmine.Block(this.env, func, this); + 51 this.addToQueue(block); + 52 return this; + 53 }; + 54 + 55 jasmine.Spec.prototype.addToQueue = function (block) { + 56 if (this.queue.isRunning()) { + 57 this.queue.insertNext(block); + 58 } else { + 59 this.queue.add(block); + 60 } + 61 }; + 62 + 63 /** + 64 * @param {jasmine.ExpectationResult} result + 65 */ + 66 jasmine.Spec.prototype.addMatcherResult = function(result) { + 67 this.results_.addResult(result); + 68 }; + 69 + 70 jasmine.Spec.prototype.expect = function(actual) { + 71 var positive = new (this.getMatchersClass_())(this.env, actual, this); + 72 positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); + 73 return positive; + 74 }; + 75 + 76 jasmine.Spec.prototype.waits = function(timeout) { + 77 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); + 78 this.addToQueue(waitsFunc); + 79 return this; + 80 }; + 81 + 82 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { + 83 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); + 84 this.addToQueue(waitsForFunc); + 85 return this; + 86 }; + 87 + 88 jasmine.Spec.prototype.fail = function (e) { + 89 var expectationResult = new jasmine.ExpectationResult({ + 90 passed: false, + 91 message: e ? jasmine.util.formatException(e) : 'Exception' + 92 }); + 93 this.results_.addResult(expectationResult); + 94 }; + 95 + 96 jasmine.Spec.prototype.getMatchersClass_ = function() { + 97 return this.matchersClass || this.env.matchersClass; + 98 }; + 99 +100 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { +101 var parent = this.getMatchersClass_(); +102 var newMatchersClass = function() { +103 parent.apply(this, arguments); +104 }; +105 jasmine.util.inherit(newMatchersClass, parent); +106 jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); +107 this.matchersClass = newMatchersClass; +108 }; +109 +110 jasmine.Spec.prototype.finishCallback = function() { +111 this.env.reporter.reportSpecResults(this); +112 }; +113 +114 jasmine.Spec.prototype.finish = function(onComplete) { +115 this.removeAllSpies(); +116 this.finishCallback(); +117 if (onComplete) { +118 onComplete(); +119 } +120 }; +121 +122 jasmine.Spec.prototype.after = function(doAfter) { +123 if (this.queue.isRunning()) { +124 this.queue.add(new jasmine.Block(this.env, doAfter, this)); +125 } else { +126 this.afterCallbacks.unshift(doAfter); +127 } +128 }; +129 +130 jasmine.Spec.prototype.execute = function(onComplete) { +131 var spec = this; +132 if (!spec.env.specFilter(spec)) { +133 spec.results_.skipped = true; +134 spec.finish(onComplete); +135 return; +136 } +137 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); +138 +139 spec.env.currentSpec = spec; +140 +141 spec.addBeforesAndAftersToQueue(); 142 -143 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { -144 var runner = this.env.currentRunner(); -145 var i; -146 -147 for (var suite = this.suite; suite; suite = suite.parentSuite) { -148 for (i = 0; i < suite.before_.length; i++) { -149 this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); -150 } -151 } -152 for (i = 0; i < runner.before_.length; i++) { -153 this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); -154 } -155 for (i = 0; i < this.afterCallbacks.length; i++) { -156 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); -157 } -158 for (suite = this.suite; suite; suite = suite.parentSuite) { -159 for (i = 0; i < suite.after_.length; i++) { -160 this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); -161 } +143 spec.queue.start(function () { +144 spec.finish(onComplete); +145 }); +146 }; +147 +148 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { +149 var runner = this.env.currentRunner(); +150 var i; +151 +152 for (var suite = this.suite; suite; suite = suite.parentSuite) { +153 for (i = 0; i < suite.before_.length; i++) { +154 this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); +155 } +156 } +157 for (i = 0; i < runner.before_.length; i++) { +158 this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); +159 } +160 for (i = 0; i < this.afterCallbacks.length; i++) { +161 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); 162 } -163 for (i = 0; i < runner.after_.length; i++) { -164 this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); -165 } -166 }; -167 -168 jasmine.Spec.prototype.explodes = function() { -169 throw 'explodes function should not have been called'; -170 }; -171 -172 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { -173 if (obj == jasmine.undefined) { -174 throw "spyOn could not find an object to spy upon for " + methodName + "()"; -175 } +163 for (suite = this.suite; suite; suite = suite.parentSuite) { +164 for (i = 0; i < suite.after_.length; i++) { +165 this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); +166 } +167 } +168 for (i = 0; i < runner.after_.length; i++) { +169 this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); +170 } +171 }; +172 +173 jasmine.Spec.prototype.explodes = function() { +174 throw 'explodes function should not have been called'; +175 }; 176 -177 if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { -178 throw methodName + '() method does not exist'; -179 } -180 -181 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { -182 throw new Error(methodName + ' has already been spied upon'); -183 } -184 -185 var spyObj = jasmine.createSpy(methodName); -186 -187 this.spies_.push(spyObj); -188 spyObj.baseObj = obj; -189 spyObj.methodName = methodName; -190 spyObj.originalValue = obj[methodName]; +177 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { +178 if (obj == jasmine.undefined) { +179 throw "spyOn could not find an object to spy upon for " + methodName + "()"; +180 } +181 +182 if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { +183 throw methodName + '() method does not exist'; +184 } +185 +186 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { +187 throw new Error(methodName + ' has already been spied upon'); +188 } +189 +190 var spyObj = jasmine.createSpy(methodName); 191 -192 obj[methodName] = spyObj; -193 -194 return spyObj; -195 }; +192 this.spies_.push(spyObj); +193 spyObj.baseObj = obj; +194 spyObj.methodName = methodName; +195 spyObj.originalValue = obj[methodName]; 196 -197 jasmine.Spec.prototype.removeAllSpies = function() { -198 for (var i = 0; i < this.spies_.length; i++) { -199 var spy = this.spies_[i]; -200 spy.baseObj[spy.methodName] = spy.originalValue; -201 } -202 this.spies_ = []; -203 }; -204 -205 \ No newline at end of file +197 obj[methodName] = spyObj; +198 +199 return spyObj; +200 }; +201 +202 jasmine.Spec.prototype.removeAllSpies = function() { +203 for (var i = 0; i < this.spies_.length; i++) { +204 var spy = this.spies_[i]; +205 spy.baseObj[spy.methodName] = spy.originalValue; +206 } +207 this.spies_ = []; +208 }; +209 +210 \ No newline at end of file diff --git a/doc/symbols/src/src_base.js.html b/doc/symbols/src/src_base.js.html index bfddf9c6..75ddeb59 100644 --- a/doc/symbols/src/src_base.js.html +++ b/doc/symbols/src/src_base.js.html @@ -57,7 +57,7 @@ 50 }; 51 } else { 52 // IE support - 53 return window[name]; + 53 return jasmine.getGlobal()[name]; 54 } 55 }; 56 @@ -416,169 +416,174 @@ 409 return obj; 410 }; 411 -412 jasmine.log = function() { -413 var spec = jasmine.getEnv().currentSpec; -414 spec.log.apply(spec, arguments); -415 }; -416 -417 /** -418 * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. -419 * -420 * @example -421 * // spy example -422 * var foo = { -423 * not: function(bool) { return !bool; } -424 * } -425 * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops -426 * -427 * @see jasmine.createSpy -428 * @param obj -429 * @param methodName -430 * @returns a Jasmine spy that can be chained with all spy methods -431 */ -432 var spyOn = function(obj, methodName) { -433 return jasmine.getEnv().currentSpec.spyOn(obj, methodName); -434 }; -435 -436 /** -437 * Creates a Jasmine spec that will be added to the current suite. -438 * -439 * // TODO: pending tests -440 * -441 * @example -442 * it('should be true', function() { -443 * expect(true).toEqual(true); -444 * }); +412 /** +413 * All parameters are pretty-printed and concatenated together, then written to the current spec's output. +414 * +415 * Be careful not to leave calls to <code>jasmine.log</code> in production code. +416 */ +417 jasmine.log = function() { +418 var spec = jasmine.getEnv().currentSpec; +419 spec.log.apply(spec, arguments); +420 }; +421 +422 /** +423 * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. +424 * +425 * @example +426 * // spy example +427 * var foo = { +428 * not: function(bool) { return !bool; } +429 * } +430 * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops +431 * +432 * @see jasmine.createSpy +433 * @param obj +434 * @param methodName +435 * @returns a Jasmine spy that can be chained with all spy methods +436 */ +437 var spyOn = function(obj, methodName) { +438 return jasmine.getEnv().currentSpec.spyOn(obj, methodName); +439 }; +440 +441 /** +442 * Creates a Jasmine spec that will be added to the current suite. +443 * +444 * // TODO: pending tests 445 * -446 * @param {String} desc description of this specification -447 * @param {Function} func defines the preconditions and expectations of the spec -448 */ -449 var it = function(desc, func) { -450 return jasmine.getEnv().it(desc, func); -451 }; -452 -453 /** -454 * Creates a <em>disabled</em> Jasmine spec. -455 * -456 * A convenience method that allows existing specs to be disabled temporarily during development. -457 * -458 * @param {String} desc description of this specification -459 * @param {Function} func defines the preconditions and expectations of the spec -460 */ -461 var xit = function(desc, func) { -462 return jasmine.getEnv().xit(desc, func); -463 }; -464 -465 /** -466 * Starts a chain for a Jasmine expectation. -467 * -468 * It is passed an Object that is the actual value and should chain to one of the many -469 * jasmine.Matchers functions. -470 * -471 * @param {Object} actual Actual value to test against and expected value -472 */ -473 var expect = function(actual) { -474 return jasmine.getEnv().currentSpec.expect(actual); -475 }; -476 -477 /** -478 * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. -479 * -480 * @param {Function} func Function that defines part of a jasmine spec. -481 */ -482 var runs = function(func) { -483 jasmine.getEnv().currentSpec.runs(func); -484 }; -485 -486 /** -487 * Waits for a timeout before moving to the next runs()-defined block. -488 * @param {Number} timeout -489 */ -490 var waits = function(timeout) { -491 jasmine.getEnv().currentSpec.waits(timeout); -492 }; -493 -494 /** -495 * Waits for the latchFunction to return true before proceeding to the next runs()-defined block. -496 * -497 * @param {Number} timeout -498 * @param {Function} latchFunction -499 * @param {String} message -500 */ -501 var waitsFor = function(timeout, latchFunction, message) { -502 jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message); -503 }; -504 -505 /** -506 * A function that is called before each spec in a suite. -507 * -508 * Used for spec setup, including validating assumptions. -509 * -510 * @param {Function} beforeEachFunction -511 */ -512 var beforeEach = function(beforeEachFunction) { -513 jasmine.getEnv().beforeEach(beforeEachFunction); -514 }; -515 -516 /** -517 * A function that is called after each spec in a suite. -518 * -519 * Used for restoring any state that is hijacked during spec execution. -520 * -521 * @param {Function} afterEachFunction -522 */ -523 var afterEach = function(afterEachFunction) { -524 jasmine.getEnv().afterEach(afterEachFunction); -525 }; -526 -527 /** -528 * Defines a suite of specifications. -529 * -530 * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared -531 * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization -532 * of setup in some tests. -533 * -534 * @example -535 * // TODO: a simple suite -536 * -537 * // TODO: a simple suite with a nested describe block +446 * @example +447 * it('should be true', function() { +448 * expect(true).toEqual(true); +449 * }); +450 * +451 * @param {String} desc description of this specification +452 * @param {Function} func defines the preconditions and expectations of the spec +453 */ +454 var it = function(desc, func) { +455 return jasmine.getEnv().it(desc, func); +456 }; +457 +458 /** +459 * Creates a <em>disabled</em> Jasmine spec. +460 * +461 * A convenience method that allows existing specs to be disabled temporarily during development. +462 * +463 * @param {String} desc description of this specification +464 * @param {Function} func defines the preconditions and expectations of the spec +465 */ +466 var xit = function(desc, func) { +467 return jasmine.getEnv().xit(desc, func); +468 }; +469 +470 /** +471 * Starts a chain for a Jasmine expectation. +472 * +473 * It is passed an Object that is the actual value and should chain to one of the many +474 * jasmine.Matchers functions. +475 * +476 * @param {Object} actual Actual value to test against and expected value +477 */ +478 var expect = function(actual) { +479 return jasmine.getEnv().currentSpec.expect(actual); +480 }; +481 +482 /** +483 * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. +484 * +485 * @param {Function} func Function that defines part of a jasmine spec. +486 */ +487 var runs = function(func) { +488 jasmine.getEnv().currentSpec.runs(func); +489 }; +490 +491 /** +492 * Waits for a timeout before moving to the next runs()-defined block. +493 * @param {Number} timeout +494 */ +495 var waits = function(timeout) { +496 jasmine.getEnv().currentSpec.waits(timeout); +497 }; +498 +499 /** +500 * Waits for the latchFunction to return true before proceeding to the next runs()-defined block. +501 * +502 * @param {Number} timeout +503 * @param {Function} latchFunction +504 * @param {String} message +505 */ +506 var waitsFor = function(timeout, latchFunction, message) { +507 jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message); +508 }; +509 +510 /** +511 * A function that is called before each spec in a suite. +512 * +513 * Used for spec setup, including validating assumptions. +514 * +515 * @param {Function} beforeEachFunction +516 */ +517 var beforeEach = function(beforeEachFunction) { +518 jasmine.getEnv().beforeEach(beforeEachFunction); +519 }; +520 +521 /** +522 * A function that is called after each spec in a suite. +523 * +524 * Used for restoring any state that is hijacked during spec execution. +525 * +526 * @param {Function} afterEachFunction +527 */ +528 var afterEach = function(afterEachFunction) { +529 jasmine.getEnv().afterEach(afterEachFunction); +530 }; +531 +532 /** +533 * Defines a suite of specifications. +534 * +535 * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared +536 * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization +537 * of setup in some tests. 538 * -539 * @param {String} description A string, usually the class under test. -540 * @param {Function} specDefinitions function that defines several specs. -541 */ -542 var describe = function(description, specDefinitions) { -543 return jasmine.getEnv().describe(description, specDefinitions); -544 }; -545 -546 /** -547 * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. -548 * -549 * @param {String} description A string, usually the class under test. -550 * @param {Function} specDefinitions function that defines several specs. -551 */ -552 var xdescribe = function(description, specDefinitions) { -553 return jasmine.getEnv().xdescribe(description, specDefinitions); -554 }; -555 -556 -557 // Provide the XMLHttpRequest class for IE 5.x-6.x: -558 jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { -559 try { -560 return new ActiveXObject("Msxml2.XMLHTTP.6.0"); -561 } catch(e) { -562 } -563 try { -564 return new ActiveXObject("Msxml2.XMLHTTP.3.0"); -565 } catch(e) { -566 } -567 try { -568 return new ActiveXObject("Msxml2.XMLHTTP"); -569 } catch(e) { -570 } -571 try { -572 return new ActiveXObject("Microsoft.XMLHTTP"); -573 } catch(e) { -574 } -575 throw new Error("This browser does not support XMLHttpRequest."); -576 } : XMLHttpRequest; -577 \ No newline at end of file +539 * @example +540 * // TODO: a simple suite +541 * +542 * // TODO: a simple suite with a nested describe block +543 * +544 * @param {String} description A string, usually the class under test. +545 * @param {Function} specDefinitions function that defines several specs. +546 */ +547 var describe = function(description, specDefinitions) { +548 return jasmine.getEnv().describe(description, specDefinitions); +549 }; +550 +551 /** +552 * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. +553 * +554 * @param {String} description A string, usually the class under test. +555 * @param {Function} specDefinitions function that defines several specs. +556 */ +557 var xdescribe = function(description, specDefinitions) { +558 return jasmine.getEnv().xdescribe(description, specDefinitions); +559 }; +560 +561 +562 // Provide the XMLHttpRequest class for IE 5.x-6.x: +563 jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { +564 try { +565 return new ActiveXObject("Msxml2.XMLHTTP.6.0"); +566 } catch(e) { +567 } +568 try { +569 return new ActiveXObject("Msxml2.XMLHTTP.3.0"); +570 } catch(e) { +571 } +572 try { +573 return new ActiveXObject("Msxml2.XMLHTTP"); +574 } catch(e) { +575 } +576 try { +577 return new ActiveXObject("Microsoft.XMLHTTP"); +578 } catch(e) { +579 } +580 throw new Error("This browser does not support XMLHttpRequest."); +581 } : XMLHttpRequest; +582 \ No newline at end of file diff --git a/doc/symbols/src/src_mock-timeout.js.html b/doc/symbols/src/src_mock-timeout.js.html index 9e4e6f60..fa655cbf 100644 --- a/doc/symbols/src/src_mock-timeout.js.html +++ b/doc/symbols/src/src_mock-timeout.js.html @@ -71,9 +71,9 @@ 64 funcToRun.funcToCall(); 65 if (funcToRun.recurring) { 66 this.scheduleFunction(funcToRun.timeoutKey, - 67 funcToRun.funcToCall, - 68 funcToRun.millis, - 69 true); + 67 funcToRun.funcToCall, + 68 funcToRun.millis, + 69 true); 70 } 71 } catch(e) { 72 } @@ -117,69 +117,76 @@ 110 }, 111 112 useMock: function() { -113 var spec = jasmine.getEnv().currentSpec; -114 spec.after(jasmine.Clock.uninstallMock); -115 -116 jasmine.Clock.installMock(); -117 }, -118 -119 installMock: function() { -120 jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; -121 }, -122 -123 uninstallMock: function() { -124 jasmine.Clock.assertInstalled(); -125 jasmine.Clock.installed = jasmine.Clock.real; -126 }, -127 -128 real: { -129 setTimeout: jasmine.getGlobal().setTimeout, -130 clearTimeout: jasmine.getGlobal().clearTimeout, -131 setInterval: jasmine.getGlobal().setInterval, -132 clearInterval: jasmine.getGlobal().clearInterval -133 }, -134 -135 assertInstalled: function() { -136 if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) { -137 throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); -138 } -139 }, -140 -141 installed: null -142 }; -143 jasmine.Clock.installed = jasmine.Clock.real; -144 -145 //else for IE support -146 jasmine.getGlobal().setTimeout = function(funcToCall, millis) { -147 if (jasmine.Clock.installed.setTimeout.apply) { -148 return jasmine.Clock.installed.setTimeout.apply(this, arguments); -149 } else { -150 return jasmine.Clock.installed.setTimeout(funcToCall, millis); -151 } -152 }; -153 -154 jasmine.getGlobal().setInterval = function(funcToCall, millis) { -155 if (jasmine.Clock.installed.setInterval.apply) { -156 return jasmine.Clock.installed.setInterval.apply(this, arguments); -157 } else { -158 return jasmine.Clock.installed.setInterval(funcToCall, millis); -159 } -160 }; -161 -162 jasmine.getGlobal().clearTimeout = function(timeoutKey) { -163 if (jasmine.Clock.installed.clearTimeout.apply) { -164 return jasmine.Clock.installed.clearTimeout.apply(this, arguments); -165 } else { -166 return jasmine.Clock.installed.clearTimeout(timeoutKey); -167 } -168 }; -169 -170 jasmine.getGlobal().clearInterval = function(timeoutKey) { -171 if (jasmine.Clock.installed.clearTimeout.apply) { -172 return jasmine.Clock.installed.clearInterval.apply(this, arguments); -173 } else { -174 return jasmine.Clock.installed.clearInterval(timeoutKey); -175 } -176 }; -177 -178 \ No newline at end of file +113 if (!jasmine.Clock.isInstalled()) { +114 var spec = jasmine.getEnv().currentSpec; +115 spec.after(jasmine.Clock.uninstallMock); +116 +117 jasmine.Clock.installMock(); +118 } +119 }, +120 +121 installMock: function() { +122 jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; +123 }, +124 +125 uninstallMock: function() { +126 jasmine.log("uninstall") +127 jasmine.Clock.assertInstalled(); +128 jasmine.Clock.installed = jasmine.Clock.real; +129 }, +130 +131 real: { +132 setTimeout: jasmine.getGlobal().setTimeout, +133 clearTimeout: jasmine.getGlobal().clearTimeout, +134 setInterval: jasmine.getGlobal().setInterval, +135 clearInterval: jasmine.getGlobal().clearInterval +136 }, +137 +138 assertInstalled: function() { +139 if (!jasmine.Clock.isInstalled()) { +140 throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); +141 } +142 }, +143 +144 isInstalled: function() { +145 return jasmine.Clock.installed == jasmine.Clock.defaultFakeTimer; +146 }, +147 +148 installed: null +149 }; +150 jasmine.Clock.installed = jasmine.Clock.real; +151 +152 //else for IE support +153 jasmine.getGlobal().setTimeout = function(funcToCall, millis) { +154 if (jasmine.Clock.installed.setTimeout.apply) { +155 return jasmine.Clock.installed.setTimeout.apply(this, arguments); +156 } else { +157 return jasmine.Clock.installed.setTimeout(funcToCall, millis); +158 } +159 }; +160 +161 jasmine.getGlobal().setInterval = function(funcToCall, millis) { +162 if (jasmine.Clock.installed.setInterval.apply) { +163 return jasmine.Clock.installed.setInterval.apply(this, arguments); +164 } else { +165 return jasmine.Clock.installed.setInterval(funcToCall, millis); +166 } +167 }; +168 +169 jasmine.getGlobal().clearTimeout = function(timeoutKey) { +170 if (jasmine.Clock.installed.clearTimeout.apply) { +171 return jasmine.Clock.installed.clearTimeout.apply(this, arguments); +172 } else { +173 return jasmine.Clock.installed.clearTimeout(timeoutKey); +174 } +175 }; +176 +177 jasmine.getGlobal().clearInterval = function(timeoutKey) { +178 if (jasmine.Clock.installed.clearTimeout.apply) { +179 return jasmine.Clock.installed.clearInterval.apply(this, arguments); +180 } else { +181 return jasmine.Clock.installed.clearInterval(timeoutKey); +182 } +183 }; +184 +185 \ No newline at end of file