From 82e04c327a639c8d4368461dbe1c70cdd326b833 Mon Sep 17 00:00:00 2001 From: Lee Byrd & Christian Williams Date: Tue, 22 Jun 2010 17:52:25 -0700 Subject: [PATCH] Bumped version to 0.11.0. Regenerated docs and lib. --- doc/files.html | 14 +- doc/index.html | 2 +- doc/symbols/_global_.html | 206 +++- doc/symbols/jasmine.Block.html | 2 +- doc/symbols/jasmine.Clock.html | 2 +- doc/symbols/jasmine.Env.html | 43 +- doc/symbols/jasmine.JsApiReporter.html | 2 +- doc/symbols/jasmine.Matchers.html | 9 +- doc/symbols/jasmine.MultiReporter.html | 2 +- doc/symbols/jasmine.NestedResults.html | 14 +- doc/symbols/jasmine.Reporter.html | 2 +- doc/symbols/jasmine.Runner.html | 36 +- doc/symbols/jasmine.Spec.html | 53 +- doc/symbols/jasmine.Spy.html | 2 +- doc/symbols/jasmine.Suite.html | 76 +- doc/symbols/jasmine.html | 122 +- doc/symbols/jasmine.util.html | 2 +- doc/symbols/src/lib_TrivialReporter.js.html | 253 +++-- doc/symbols/src/src_Env.js.html | 393 ++++--- doc/symbols/src/src_JsApiReporter.js.html | 145 ++- doc/symbols/src/src_Matchers.js.html | 602 +++++----- doc/symbols/src/src_NestedResults.js.html | 10 +- doc/symbols/src/src_PrettyPrinter.js.html | 4 +- doc/symbols/src/src_Runner.js.html | 29 +- doc/symbols/src/src_Spec.js.html | 322 +++--- doc/symbols/src/src_Suite.js.html | 112 +- doc/symbols/src/src_WaitsForBlock.js.html | 11 +- doc/symbols/src/src_base.js.html | 1057 +++++++++--------- doc/symbols/src/src_mock-timeout.js.html | 354 +++--- lib/{jasmine-0.10.4.js => jasmine-0.11.0.js} | 6 +- src/version.json | 4 +- 31 files changed, 2079 insertions(+), 1812 deletions(-) rename lib/{jasmine-0.10.4.js => jasmine-0.11.0.js} (99%) diff --git a/doc/files.html b/doc/files.html index 1284c83..31891cb 100644 --- a/doc/files.html +++ b/doc/files.html @@ -362,18 +362,6 @@ ul.inheritsList - - -
- -
-

src/Reporters.js

- -
- - - -

@@ -454,7 +442,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index 582b23c..195b876 100644 --- a/doc/index.html +++ b/doc/index.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 1f30daf..6882366 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -278,6 +278,24 @@ ul.inheritsList + +   + +
clearInterval(timeoutKey) +
+
+ + + + +   + +
clearTimeout(timeoutKey) +
+
+ + +   @@ -314,6 +332,24 @@ ul.inheritsList + +   + +
setInterval(funcToCall, millis) +
+
+ + + + +   + +
setTimeout(funcToCall, millis) +
+
+ + +   @@ -460,6 +496,84 @@ Used for spec setup, including validating assumptions. +
+ + +
+ + + clearInterval(timeoutKey) + +
+
+ + +
+ Defined in: mock-timeout.js. + + +
+ + + + +
+
Parameters:
+ +
+ timeoutKey + +
+
+ +
+ + + + + + + + +
+ + +
+ + + clearTimeout(timeoutKey) + +
+
+ + +
+ Defined in: mock-timeout.js. + + +
+ + + + +
+
Parameters:
+ +
+ timeoutKey + +
+
+ +
+ + + + + + + +
@@ -649,6 +763,96 @@ jasmine.Matchers functions. +
+ + +
+ + + setInterval(funcToCall, millis) + +
+
+ + +
+ Defined in: mock-timeout.js. + + +
+ + + + +
+
Parameters:
+ +
+ funcToCall + +
+
+ +
+ millis + +
+
+ +
+ + + + + + + + +
+ + +
+ + + setTimeout(funcToCall, millis) + +
+
+ + +
+ Defined in: mock-timeout.js. + + +
+ + + + +
+
Parameters:
+ +
+ funcToCall + +
+
+ +
+ millis + +
+
+ +
+ + + + + + + +
@@ -912,7 +1116,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:00 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index 1e39095..4a0e4b6 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 Thu Mar 18 2010 20:35:00 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Clock.html b/doc/symbols/jasmine.Clock.html index 35f552e..3d6eb2a 100644 --- a/doc/symbols/jasmine.Clock.html +++ b/doc/symbols/jasmine.Clock.html @@ -672,7 +672,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:00 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index de4e958..0fd97fc 100644 --- a/doc/symbols/jasmine.Env.html +++ b/doc/symbols/jasmine.Env.html @@ -427,6 +427,15 @@ ul.inheritsList + +   + +
versionString() +
+
+ + +   @@ -1065,6 +1074,38 @@ ul.inheritsList +
+ + +
+ + + versionString() + +
+
+ + + +
+ + + + + + + + +
+
Returns:
+ +
string containing jasmine version build info, if set.
+ +
+ + + +
@@ -1163,7 +1204,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index b0d0ba5..37d6361 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 Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Matchers.html b/doc/symbols/jasmine.Matchers.html index 8a598ee..abf9c78 100644 --- a/doc/symbols/jasmine.Matchers.html +++ b/doc/symbols/jasmine.Matchers.html @@ -773,13 +773,6 @@ ul.inheritsList -
-
Deprecated:
-
- Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. -
-
- @@ -1468,7 +1461,7 @@ a pattern or a String.
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index 9a45068..48392fd 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 Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 5836f68..cfe4151 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -362,9 +362,9 @@ ul.inheritsList   -
log(message) +
log(values)
-
Tracks a result's message.
+
Adds a log message.
@@ -592,11 +592,11 @@ ul.inheritsList
- log(message) + log(values)
- Tracks a result's message. + Adds a log message.
@@ -608,10 +608,10 @@ ul.inheritsList
Parameters:
- message + values
-
+
Array of message parts which will be concatenated later.
@@ -704,7 +704,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index 9e52925..3f1f70b 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 Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index 2ea1691..fe0a20d 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -364,6 +364,15 @@ ul.inheritsList + +   + + +
+ + + @@ -690,6 +699,31 @@ ul.inheritsList +
+ + +
+ + + topLevelSuites() + +
+
+ + + +
+ + + + + + + + + + + @@ -704,7 +738,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index bfbfde1..75b4fad 100644 --- a/doc/symbols/jasmine.Spec.html +++ b/doc/symbols/jasmine.Spec.html @@ -403,16 +403,7 @@ ul.inheritsList   - -
- - - - -   - -
log(message) +
log()
@@ -588,7 +579,7 @@ ul.inheritsList
Parameters:
- result + {jasmine.ExpectationResult} result
@@ -954,38 +945,13 @@ ul.inheritsList -
- - -
- - - getResults() - -
-
- - - -
- - - - - - - - - - -
- log(message) + log()
@@ -997,17 +963,6 @@ ul.inheritsList -
-
Parameters:
- -
- message - -
-
- -
- @@ -1247,7 +1202,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 38c9024..8d9b295 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 Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index efb39e3..326f279 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -286,7 +286,7 @@ ul.inheritsList   -
add(block) +
add(suiteOrSpec)
@@ -310,6 +310,15 @@ ul.inheritsList + +   + + +
+ + +   @@ -355,6 +364,15 @@ ul.inheritsList + +   + +
suites() +
+
+ + + @@ -436,7 +454,7 @@ ul.inheritsList
- add(block) + add(suiteOrSpec)
@@ -452,7 +470,7 @@ ul.inheritsList
Parameters:
- block + suiteOrSpec
@@ -538,6 +556,31 @@ ul.inheritsList +
+ + +
+ + + children() + +
+
+ + + +
+ + + + + + + + + + +
@@ -685,6 +728,31 @@ ul.inheritsList +
+ + +
+ + + suites() + +
+
+ + + +
+ + + + + + + + + + + @@ -699,7 +767,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 569cafe..060c415 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -290,27 +290,6 @@ ul.inheritsList - - <static>   - -
- jasmine.details -
-
- - - - - <static>   - -
- jasmine.Reporters -
-
JasmineReporters.reporter - Base object that will get called whenever a Spec, Suite, or Runner is done.
- - - @@ -389,10 +368,9 @@ ul.inheritsList <static>   -
jasmine.include(url, opt_global) +
jasmine.getGlobal()
-
Adds suite files to an HTML document so that they are executed, thus adding them to the current -Jasmine environment.
+
@@ -417,7 +395,7 @@ Jasmine environment.
<static>   -
jasmine.log(message) +
jasmine.log()
@@ -426,7 +404,7 @@ Jasmine environment.
<static>   -
jasmine.MessageResult(text) +
jasmine.MessageResult(values)
@@ -560,55 +538,6 @@ Jasmine environment.
-
- - -
<static> - - - jasmine.details - -
-
- - - -
- - - - - - - - -
- - -
<static> - - - jasmine.Reporters - -
-
- JasmineReporters.reporter - Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to - descendants of this object to do something with the results (see json_reporter.js) - -
- Defined in: Reporters.js. - - -
- - - - - - - - @@ -835,16 +764,15 @@ large in one call.
- +
<static> - jasmine.include(url, opt_global) + jasmine.getGlobal()
- Adds suite files to an HTML document so that they are executed, thus adding them to the current -Jasmine environment. +
@@ -852,23 +780,6 @@ Jasmine environment. -
-
Parameters:
- -
- {String} url - -
-
path to the file to include
- -
- {Boolean} opt_global - -
-
- -
- @@ -968,7 +879,7 @@ Jasmine environment.
<static> - jasmine.log(message) + jasmine.log()
@@ -980,17 +891,6 @@ Jasmine environment. -
-
Parameters:
- -
- message - -
-
- -
- @@ -1004,7 +904,7 @@ Jasmine environment.
<static> - jasmine.MessageResult(text) + jasmine.MessageResult(values)
@@ -1020,7 +920,7 @@ Jasmine environment.
Parameters:
- text + values
@@ -1339,7 +1239,7 @@ Jasmine environment.
- Documentation generated by JsDoc Toolkit 2.1.0 on Thu Mar 18 2010 20:35:00 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:46 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index 41a1fb8..018ee91 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 Thu Mar 18 2010 20:35:01 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Tue Jun 22 2010 17:46:47 GMT-0700 (PDT)
diff --git a/doc/symbols/src/lib_TrivialReporter.js.html b/doc/symbols/src/lib_TrivialReporter.js.html index 9eac326..8afab28 100644 --- a/doc/symbols/src/lib_TrivialReporter.js.html +++ b/doc/symbols/src/lib_TrivialReporter.js.html @@ -24,101 +24,160 @@ 17 } 18 19 for (var attr in attrs) { - 20 el[attr] = attrs[attr]; - 21 } - 22 - 23 return el; - 24 }; - 25 - 26 jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { - 27 var suites = runner.suites(); - 28 - 29 this.runnerDiv = this.createDom('div', { className: 'runner running' }, - 30 this.createDom('a', { className: 'run_spec', href: '?' }, "run all"), - 31 this.runnerMessageSpan = this.createDom('span', {}, "Running...")); - 32 this.document.body.appendChild(this.runnerDiv); - 33 - 34 for (var i = 0; i < suites.length; i++) { - 35 var suite = suites[i]; - 36 var suiteDiv = this.createDom('div', { className: 'suite' }, - 37 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"), - 38 this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description)); - 39 this.suiteDivs[suite.getFullName()] = suiteDiv; - 40 var parentDiv = this.document.body; - 41 if (suite.parentSuite) { - 42 parentDiv = this.suiteDivs[suite.parentSuite.getFullName()]; - 43 } - 44 parentDiv.appendChild(suiteDiv); - 45 } + 20 if (attr == "className") { + 21 el[attr] = attrs[attr]; + 22 } else { + 23 el.setAttribute(attr, attrs[attr]); + 24 } + 25 } + 26 + 27 return el; + 28 }; + 29 + 30 jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) { + 31 var showPassed, showSkipped; + 32 + 33 this.outerDiv = this.createDom('div', { className: 'jasmine_reporter' }, + 34 this.createDom('div', { className: 'banner' }, + 35 this.createDom('div', { className: 'logo' }, + 36 "Jasmine", + 37 this.createDom('span', { className: 'version' }, runner.env.versionString())), + 38 this.createDom('div', { className: 'options' }, + 39 "Show ", + 40 showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }), + 41 this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "), + 42 showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }), + 43 this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped") + 44 ) + 45 ), 46 - 47 this.startedAt = new Date(); - 48 }; - 49 - 50 jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { - 51 var results = runner.results(); - 52 var className = (results.failedCount > 0) ? "runner failed" : "runner passed"; - 53 this.runnerDiv.setAttribute("class", className); - 54 //do it twice for IE - 55 this.runnerDiv.setAttribute("className", className); - 56 var specs = runner.specs(); - 57 var specCount = 0; - 58 for (var i = 0; i < specs.length; i++) { - 59 if (this.specFilter(specs[i])) { - 60 specCount++; - 61 } - 62 } - 63 var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); - 64 message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; - 65 this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild); - 66 }; - 67 - 68 jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { - 69 var results = suite.results(); - 70 var status = results.passed() ? 'passed' : 'failed'; - 71 if (results.totalCount == 0) { // todo: change this to check results.skipped - 72 status = 'skipped'; - 73 } - 74 this.suiteDivs[suite.getFullName()].className += " " + status; - 75 }; - 76 - 77 jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { - 78 var results = spec.results(); - 79 var status = results.passed() ? 'passed' : 'failed'; - 80 if (results.skipped) { - 81 status = 'skipped'; - 82 } - 83 var specDiv = this.createDom('div', { className: 'spec ' + status }, - 84 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"), - 85 this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, spec.getFullName())); - 86 - 87 - 88 var resultItems = results.getItems(); - 89 for (var i = 0; i < resultItems.length; i++) { - 90 var result = resultItems[i]; - 91 if (result.passed && !result.passed()) { - 92 specDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); - 93 specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); - 94 } - 95 } - 96 this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv); - 97 }; - 98 - 99 jasmine.TrivialReporter.prototype.log = function() { -100 console.log.apply(console, arguments); -101 }; -102 -103 jasmine.TrivialReporter.prototype.getLocation = function() { -104 return this.document.location; -105 }; -106 -107 jasmine.TrivialReporter.prototype.specFilter = function(spec) { -108 var paramMap = {}; -109 var params = this.getLocation().search.substring(1).split('&'); -110 for (var i = 0; i < params.length; i++) { -111 var p = params[i].split('='); -112 paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); -113 } -114 -115 if (!paramMap["spec"]) return true; -116 return spec.getFullName().indexOf(paramMap["spec"]) == 0; -117 }; \ No newline at end of file + 47 this.runnerDiv = this.createDom('div', { className: 'runner running' }, + 48 this.createDom('a', { className: 'run_spec', href: '?' }, "run all"), + 49 this.runnerMessageSpan = this.createDom('span', {}, "Running..."), + 50 this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, "")) + 51 ); + 52 + 53 this.document.body.appendChild(this.outerDiv); + 54 + 55 var suites = runner.suites(); + 56 for (var i = 0; i < suites.length; i++) { + 57 var suite = suites[i]; + 58 var suiteDiv = this.createDom('div', { className: 'suite' }, + 59 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"), + 60 this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description)); + 61 this.suiteDivs[suite.id] = suiteDiv; + 62 var parentDiv = this.outerDiv; + 63 if (suite.parentSuite) { + 64 parentDiv = this.suiteDivs[suite.parentSuite.id]; + 65 } + 66 parentDiv.appendChild(suiteDiv); + 67 } + 68 + 69 this.startedAt = new Date(); + 70 + 71 var self = this; + 72 showPassed.onchange = function(evt) { + 73 if (evt.target.checked) { + 74 self.outerDiv.className += ' show-passed'; + 75 } else { + 76 self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, ''); + 77 } + 78 }; + 79 + 80 showSkipped.onchange = function(evt) { + 81 if (evt.target.checked) { + 82 self.outerDiv.className += ' show-skipped'; + 83 } else { + 84 self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, ''); + 85 } + 86 }; + 87 }; + 88 + 89 jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) { + 90 var results = runner.results(); + 91 var className = (results.failedCount > 0) ? "runner failed" : "runner passed"; + 92 this.runnerDiv.setAttribute("class", className); + 93 //do it twice for IE + 94 this.runnerDiv.setAttribute("className", className); + 95 var specs = runner.specs(); + 96 var specCount = 0; + 97 for (var i = 0; i < specs.length; i++) { + 98 if (this.specFilter(specs[i])) { + 99 specCount++; +100 } +101 } +102 var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s"); +103 message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"; +104 this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild); +105 +106 this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString())); +107 }; +108 +109 jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) { +110 var results = suite.results(); +111 var status = results.passed() ? 'passed' : 'failed'; +112 if (results.totalCount == 0) { // todo: change this to check results.skipped +113 status = 'skipped'; +114 } +115 this.suiteDivs[suite.id].className += " " + status; +116 }; +117 +118 jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) { +119 var results = spec.results(); +120 var status = results.passed() ? 'passed' : 'failed'; +121 if (results.skipped) { +122 status = 'skipped'; +123 } +124 var specDiv = this.createDom('div', { className: 'spec ' + status }, +125 this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"), +126 this.createDom('a', { +127 className: 'description', +128 href: '?spec=' + encodeURIComponent(spec.getFullName()), +129 title: spec.getFullName() +130 }, spec.description)); +131 +132 +133 var resultItems = results.getItems(); +134 var messagesDiv = this.createDom('div', { className: 'messages' }); +135 for (var i = 0; i < resultItems.length; i++) { +136 var result = resultItems[i]; +137 +138 if (result.type == 'log') { +139 messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString())); +140 } else if (result.type == 'expect' && result.passed && !result.passed()) { +141 messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message)); +142 +143 if (result.trace.stack) { +144 messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack)); +145 } +146 } +147 } +148 +149 if (messagesDiv.childNodes.length > 0) { +150 specDiv.appendChild(messagesDiv); +151 } +152 +153 this.suiteDivs[spec.suite.id].appendChild(specDiv); +154 }; +155 +156 jasmine.TrivialReporter.prototype.log = function() { +157 var console = jasmine.getGlobal().console; +158 if (console && console.log) console.log.apply(console, arguments); +159 }; +160 +161 jasmine.TrivialReporter.prototype.getLocation = function() { +162 return this.document.location; +163 }; +164 +165 jasmine.TrivialReporter.prototype.specFilter = function(spec) { +166 var paramMap = {}; +167 var params = this.getLocation().search.substring(1).split('&'); +168 for (var i = 0; i < params.length; i++) { +169 var p = params[i].split('='); +170 paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]); +171 } +172 +173 if (!paramMap["spec"]) return true; +174 return spec.getFullName().indexOf(paramMap["spec"]) == 0; +175 }; +176 \ No newline at end of file diff --git a/doc/symbols/src/src_Env.js.html b/doc/symbols/src/src_Env.js.html index 04aa468..3d8863c 100644 --- a/doc/symbols/src/src_Env.js.html +++ b/doc/symbols/src/src_Env.js.html @@ -54,195 +54,218 @@ 47 }; 48 49 /** - 50 * @returns a sequential integer starting at 0 + 50 * @returns string containing jasmine version build info, if set. 51 */ - 52 jasmine.Env.prototype.nextSpecId = function () { - 53 return this.nextSpecId_++; - 54 }; - 55 - 56 /** - 57 * @returns a sequential integer starting at 0 - 58 */ - 59 jasmine.Env.prototype.nextSuiteId = function () { - 60 return this.nextSuiteId_++; - 61 }; - 62 - 63 /** - 64 * Register a reporter to receive status updates from Jasmine. - 65 * @param {jasmine.Reporter} reporter An object which will receive status updates. - 66 */ - 67 jasmine.Env.prototype.addReporter = function(reporter) { - 68 this.reporter.addReporter(reporter); - 69 }; - 70 - 71 jasmine.Env.prototype.execute = function() { - 72 this.currentRunner_.execute(); + 52 jasmine.Env.prototype.versionString = function() { + 53 if (jasmine.version_) { + 54 var version = this.version(); + 55 return version.major + "." + version.minor + "." + version.build + " revision " + version.revision; + 56 } else { + 57 return "version unknown"; + 58 } + 59 }; + 60 + 61 /** + 62 * @returns a sequential integer starting at 0 + 63 */ + 64 jasmine.Env.prototype.nextSpecId = function () { + 65 return this.nextSpecId_++; + 66 }; + 67 + 68 /** + 69 * @returns a sequential integer starting at 0 + 70 */ + 71 jasmine.Env.prototype.nextSuiteId = function () { + 72 return this.nextSuiteId_++; 73 }; 74 - 75 jasmine.Env.prototype.describe = function(description, specDefinitions) { - 76 var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); - 77 - 78 var parentSuite = this.currentSuite; - 79 if (parentSuite) { - 80 parentSuite.add(suite); - 81 } else { - 82 this.currentRunner_.add(suite); - 83 } - 84 - 85 this.currentSuite = suite; + 75 /** + 76 * Register a reporter to receive status updates from Jasmine. + 77 * @param {jasmine.Reporter} reporter An object which will receive status updates. + 78 */ + 79 jasmine.Env.prototype.addReporter = function(reporter) { + 80 this.reporter.addReporter(reporter); + 81 }; + 82 + 83 jasmine.Env.prototype.execute = function() { + 84 this.currentRunner_.execute(); + 85 }; 86 - 87 specDefinitions.call(suite); - 88 - 89 this.currentSuite = parentSuite; - 90 - 91 return suite; - 92 }; - 93 - 94 jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { - 95 if (this.currentSuite) { - 96 this.currentSuite.beforeEach(beforeEachFunction); - 97 } else { - 98 this.currentRunner_.beforeEach(beforeEachFunction); - 99 } -100 }; -101 -102 jasmine.Env.prototype.currentRunner = function () { -103 return this.currentRunner_; -104 }; + 87 jasmine.Env.prototype.describe = function(description, specDefinitions) { + 88 var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); + 89 + 90 var parentSuite = this.currentSuite; + 91 if (parentSuite) { + 92 parentSuite.add(suite); + 93 } else { + 94 this.currentRunner_.add(suite); + 95 } + 96 + 97 this.currentSuite = suite; + 98 + 99 var declarationError = null; +100 try { +101 specDefinitions.call(suite); +102 } catch(e) { +103 declarationError = e; +104 } 105 -106 jasmine.Env.prototype.afterEach = function(afterEachFunction) { -107 if (this.currentSuite) { -108 this.currentSuite.afterEach(afterEachFunction); -109 } else { -110 this.currentRunner_.afterEach(afterEachFunction); -111 } -112 -113 }; -114 -115 jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { -116 return { -117 execute: function() { -118 } -119 }; -120 }; -121 -122 jasmine.Env.prototype.it = function(description, func) { -123 var spec = new jasmine.Spec(this, this.currentSuite, description); -124 this.currentSuite.add(spec); -125 this.currentSpec = spec; -126 -127 if (func) { -128 spec.runs(func); -129 } -130 -131 return spec; -132 }; -133 -134 jasmine.Env.prototype.xit = function(desc, func) { -135 return { -136 id: this.nextSpecId(), -137 runs: function() { -138 } -139 }; -140 }; -141 -142 jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { -143 if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { -144 return true; -145 } -146 -147 a.__Jasmine_been_here_before__ = b; -148 b.__Jasmine_been_here_before__ = a; +106 this.currentSuite = parentSuite; +107 +108 if (declarationError) { +109 this.it("encountered a declaration exception", function() { +110 throw declarationError; +111 }); +112 } +113 +114 return suite; +115 }; +116 +117 jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { +118 if (this.currentSuite) { +119 this.currentSuite.beforeEach(beforeEachFunction); +120 } else { +121 this.currentRunner_.beforeEach(beforeEachFunction); +122 } +123 }; +124 +125 jasmine.Env.prototype.currentRunner = function () { +126 return this.currentRunner_; +127 }; +128 +129 jasmine.Env.prototype.afterEach = function(afterEachFunction) { +130 if (this.currentSuite) { +131 this.currentSuite.afterEach(afterEachFunction); +132 } else { +133 this.currentRunner_.afterEach(afterEachFunction); +134 } +135 +136 }; +137 +138 jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { +139 return { +140 execute: function() { +141 } +142 }; +143 }; +144 +145 jasmine.Env.prototype.it = function(description, func) { +146 var spec = new jasmine.Spec(this, this.currentSuite, description); +147 this.currentSuite.add(spec); +148 this.currentSpec = spec; 149 -150 var hasKey = function(obj, keyName) { -151 return obj != null && obj[keyName] !== jasmine.undefined; -152 }; +150 if (func) { +151 spec.runs(func); +152 } 153 -154 for (var property in b) { -155 if (!hasKey(a, property) && hasKey(b, property)) { -156 mismatchKeys.push("expected has key '" + property + "', but missing from actual."); -157 } -158 } -159 for (property in a) { -160 if (!hasKey(b, property) && hasKey(a, property)) { -161 mismatchKeys.push("expected missing key '" + property + "', but present in actual."); -162 } -163 } -164 for (property in b) { -165 if (property == '__Jasmine_been_here_before__') continue; -166 if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { -167 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."); -168 } -169 } -170 -171 if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { -172 mismatchValues.push("arrays were not the same length"); -173 } -174 -175 delete a.__Jasmine_been_here_before__; -176 delete b.__Jasmine_been_here_before__; -177 return (mismatchKeys.length == 0 && mismatchValues.length == 0); -178 }; -179 -180 jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { -181 mismatchKeys = mismatchKeys || []; -182 mismatchValues = mismatchValues || []; -183 -184 for (var i = 0; i < this.equalityTesters_.length; i++) { -185 var equalityTester = this.equalityTesters_[i]; -186 var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); -187 if (result !== jasmine.undefined) return result; -188 } -189 -190 if (a === b) return true; -191 -192 if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { -193 return (a == jasmine.undefined && b == jasmine.undefined); -194 } -195 -196 if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { -197 return a === b; -198 } -199 -200 if (a instanceof Date && b instanceof Date) { -201 return a.getTime() == b.getTime(); -202 } -203 -204 if (a instanceof jasmine.Matchers.Any) { -205 return a.matches(b); -206 } -207 -208 if (b instanceof jasmine.Matchers.Any) { -209 return b.matches(a); -210 } -211 -212 if (jasmine.isString_(a) && jasmine.isString_(b)) { -213 return (a == b); -214 } -215 -216 if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { -217 return (a == b); -218 } -219 -220 if (typeof a === "object" && typeof b === "object") { -221 return this.compareObjects_(a, b, mismatchKeys, mismatchValues); -222 } -223 -224 //Straight check -225 return (a === b); -226 }; -227 -228 jasmine.Env.prototype.contains_ = function(haystack, needle) { -229 if (jasmine.isArray_(haystack)) { -230 for (var i = 0; i < haystack.length; i++) { -231 if (this.equals_(haystack[i], needle)) return true; -232 } -233 return false; -234 } -235 return haystack.indexOf(needle) >= 0; -236 }; -237 -238 jasmine.Env.prototype.addEqualityTester = function(equalityTester) { -239 this.equalityTesters_.push(equalityTester); -240 }; -241 \ No newline at end of file +154 return spec; +155 }; +156 +157 jasmine.Env.prototype.xit = function(desc, func) { +158 return { +159 id: this.nextSpecId(), +160 runs: function() { +161 } +162 }; +163 }; +164 +165 jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { +166 if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { +167 return true; +168 } +169 +170 a.__Jasmine_been_here_before__ = b; +171 b.__Jasmine_been_here_before__ = a; +172 +173 var hasKey = function(obj, keyName) { +174 return obj != null && obj[keyName] !== jasmine.undefined; +175 }; +176 +177 for (var property in b) { +178 if (!hasKey(a, property) && hasKey(b, property)) { +179 mismatchKeys.push("expected has key '" + property + "', but missing from actual."); +180 } +181 } +182 for (property in a) { +183 if (!hasKey(b, property) && hasKey(a, property)) { +184 mismatchKeys.push("expected missing key '" + property + "', but present in actual."); +185 } +186 } +187 for (property in b) { +188 if (property == '__Jasmine_been_here_before__') continue; +189 if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { +190 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."); +191 } +192 } +193 +194 if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { +195 mismatchValues.push("arrays were not the same length"); +196 } +197 +198 delete a.__Jasmine_been_here_before__; +199 delete b.__Jasmine_been_here_before__; +200 return (mismatchKeys.length == 0 && mismatchValues.length == 0); +201 }; +202 +203 jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { +204 mismatchKeys = mismatchKeys || []; +205 mismatchValues = mismatchValues || []; +206 +207 for (var i = 0; i < this.equalityTesters_.length; i++) { +208 var equalityTester = this.equalityTesters_[i]; +209 var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); +210 if (result !== jasmine.undefined) return result; +211 } +212 +213 if (a === b) return true; +214 +215 if (a === jasmine.undefined || a === null || b === jasmine.undefined || b === null) { +216 return (a == jasmine.undefined && b == jasmine.undefined); +217 } +218 +219 if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { +220 return a === b; +221 } +222 +223 if (a instanceof Date && b instanceof Date) { +224 return a.getTime() == b.getTime(); +225 } +226 +227 if (a instanceof jasmine.Matchers.Any) { +228 return a.matches(b); +229 } +230 +231 if (b instanceof jasmine.Matchers.Any) { +232 return b.matches(a); +233 } +234 +235 if (jasmine.isString_(a) && jasmine.isString_(b)) { +236 return (a == b); +237 } +238 +239 if (jasmine.isNumber_(a) && jasmine.isNumber_(b)) { +240 return (a == b); +241 } +242 +243 if (typeof a === "object" && typeof b === "object") { +244 return this.compareObjects_(a, b, mismatchKeys, mismatchValues); +245 } +246 +247 //Straight check +248 return (a === b); +249 }; +250 +251 jasmine.Env.prototype.contains_ = function(haystack, needle) { +252 if (jasmine.isArray_(haystack)) { +253 for (var i = 0; i < haystack.length; i++) { +254 if (this.equals_(haystack[i], needle)) return true; +255 } +256 return false; +257 } +258 return haystack.indexOf(needle) >= 0; +259 }; +260 +261 jasmine.Env.prototype.addEqualityTester = function(equalityTester) { +262 this.equalityTesters_.push(equalityTester); +263 }; +264 \ No newline at end of file diff --git a/doc/symbols/src/src_JsApiReporter.js.html b/doc/symbols/src/src_JsApiReporter.js.html index 8097661..8ba33ff 100644 --- a/doc/symbols/src/src_JsApiReporter.js.html +++ b/doc/symbols/src/src_JsApiReporter.js.html @@ -18,7 +18,7 @@ 11 12 jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { 13 this.started = true; - 14 var suites = runner.suites(); + 14 var suites = runner.topLevelSuites(); 15 for (var i = 0; i < suites.length; i++) { 16 var suite = suites[i]; 17 this.suites_.push(this.summarize_(suite)); @@ -37,75 +37,74 @@ 30 type: isSuite ? 'suite' : 'spec', 31 children: [] 32 }; - 33 if (isSuite) { - 34 var specs = suiteOrSpec.specs(); - 35 for (var i = 0; i < specs.length; i++) { - 36 summary.children.push(this.summarize_(specs[i])); - 37 } - 38 } - 39 return summary; - 40 }; - 41 - 42 jasmine.JsApiReporter.prototype.results = function() { - 43 return this.results_; - 44 }; - 45 - 46 jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) { - 47 return this.results_[specId]; - 48 }; - 49 - 50 //noinspection JSUnusedLocalSymbols - 51 jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { - 52 this.finished = true; - 53 }; - 54 - 55 //noinspection JSUnusedLocalSymbols - 56 jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { - 57 }; - 58 - 59 //noinspection JSUnusedLocalSymbols - 60 jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { - 61 this.results_[spec.id] = { - 62 messages: spec.results().getItems(), - 63 result: spec.results().failedCount > 0 ? "failed" : "passed" - 64 }; - 65 }; - 66 - 67 //noinspection JSUnusedLocalSymbols - 68 jasmine.JsApiReporter.prototype.log = function(str) { - 69 }; - 70 - 71 jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){ - 72 var results = {}; - 73 for (var i = 0; i < specIds.length; i++) { - 74 var specId = specIds[i]; - 75 results[specId] = this.summarizeResult_(this.results_[specId]); - 76 } - 77 return results; - 78 }; - 79 - 80 jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ - 81 var summaryMessages = []; - 82 var messagesLength = result.messages.length - 83 for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { - 84 var resultMessage = result.messages[messageIndex]; - 85 summaryMessages.push({ - 86 text: resultMessage.text, - 87 passed: resultMessage.passed ? resultMessage.passed() : true, - 88 type: resultMessage.type, - 89 message: resultMessage.message, - 90 trace: { - 91 stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined - 92 } - 93 }); - 94 }; - 95 - 96 var summaryResult = { - 97 result : result.result, - 98 messages : summaryMessages - 99 }; -100 -101 return summaryResult; -102 }; -103 -104 \ No newline at end of file + 33 + 34 if (isSuite) { + 35 var children = suiteOrSpec.children(); + 36 for (var i = 0; i < children.length; i++) { + 37 summary.children.push(this.summarize_(children[i])); + 38 } + 39 } + 40 return summary; + 41 }; + 42 + 43 jasmine.JsApiReporter.prototype.results = function() { + 44 return this.results_; + 45 }; + 46 + 47 jasmine.JsApiReporter.prototype.resultsForSpec = function(specId) { + 48 return this.results_[specId]; + 49 }; + 50 + 51 //noinspection JSUnusedLocalSymbols + 52 jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { + 53 this.finished = true; + 54 }; + 55 + 56 //noinspection JSUnusedLocalSymbols + 57 jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { + 58 }; + 59 + 60 //noinspection JSUnusedLocalSymbols + 61 jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { + 62 this.results_[spec.id] = { + 63 messages: spec.results().getItems(), + 64 result: spec.results().failedCount > 0 ? "failed" : "passed" + 65 }; + 66 }; + 67 + 68 //noinspection JSUnusedLocalSymbols + 69 jasmine.JsApiReporter.prototype.log = function(str) { + 70 }; + 71 + 72 jasmine.JsApiReporter.prototype.resultsForSpecs = function(specIds){ + 73 var results = {}; + 74 for (var i = 0; i < specIds.length; i++) { + 75 var specId = specIds[i]; + 76 results[specId] = this.summarizeResult_(this.results_[specId]); + 77 } + 78 return results; + 79 }; + 80 + 81 jasmine.JsApiReporter.prototype.summarizeResult_ = function(result){ + 82 var summaryMessages = []; + 83 var messagesLength = result.messages.length; + 84 for (var messageIndex = 0; messageIndex < messagesLength; messageIndex++) { + 85 var resultMessage = result.messages[messageIndex]; + 86 summaryMessages.push({ + 87 text: resultMessage.type == 'log' ? resultMessage.toString() : jasmine.undefined, + 88 passed: resultMessage.passed ? resultMessage.passed() : true, + 89 type: resultMessage.type, + 90 message: resultMessage.message, + 91 trace: { + 92 stack: resultMessage.passed && !resultMessage.passed() ? resultMessage.trace.stack : jasmine.undefined + 93 } + 94 }); + 95 } + 96 + 97 return { + 98 result : result.result, + 99 messages : summaryMessages +100 }; +101 }; +102 +103 \ No newline at end of file diff --git a/doc/symbols/src/src_Matchers.js.html b/doc/symbols/src/src_Matchers.js.html index 8814321..9d5d958 100644 --- a/doc/symbols/src/src_Matchers.js.html +++ b/doc/symbols/src/src_Matchers.js.html @@ -22,323 +22,309 @@ 15 // todo: @deprecated as of Jasmine 0.11, remove soon [xw] 16 jasmine.Matchers.pp = function(str) { 17 throw new Error("jasmine.Matchers.pp() is no longer supported, please use jasmine.pp() instead!"); - 18 this.report(); - 19 }; - 20 - 21 /** @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. */ - 22 jasmine.Matchers.prototype.report = function(result, failing_message, details) { - 23 // todo: report a deprecation warning [xw] + 18 }; + 19 + 20 // todo: @deprecated Deprecated as of Jasmine 0.10. Rewrite your custom matchers to return true or false. [xw] + 21 jasmine.Matchers.prototype.report = function(result, failing_message, details) { + 22 throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); + 23 }; 24 - 25 if (this.isNot) { - 26 throw new Error("As of jasmine 0.11, custom matchers must be implemented differently -- please see jasmine docs"); - 27 } - 28 - 29 this.reportWasCalled_ = true; - 30 var expectationResult = new jasmine.ExpectationResult({ - 31 passed: result, - 32 message: failing_message, - 33 details: details - 34 }); - 35 this.spec.addMatcherResult(expectationResult); - 36 return result; - 37 }; - 38 - 39 jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { - 40 for (var methodName in prototype) { - 41 if (methodName == 'report') continue; - 42 var orig = prototype[methodName]; - 43 matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); - 44 } - 45 }; - 46 - 47 jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { - 48 return function() { - 49 var matcherArgs = jasmine.util.argsToArray(arguments); - 50 var result = matcherFunction.apply(this, arguments); - 51 - 52 if (this.isNot) { - 53 result = !result; - 54 } - 55 - 56 if (this.reportWasCalled_) return result; - 57 - 58 var message; - 59 if (!result) { - 60 if (this.message) { - 61 message = this.message.apply(this, arguments); - 62 if (jasmine.isArray_(message)) { - 63 message = message[this.isNot ? 1 : 0]; - 64 } - 65 } else { - 66 var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); - 67 message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; - 68 if (matcherArgs.length > 0) { - 69 for (var i = 0; i < matcherArgs.length; i++) { - 70 if (i > 0) message += ","; - 71 message += " " + jasmine.pp(matcherArgs[i]); - 72 } - 73 } - 74 message += "."; - 75 } - 76 } - 77 var expectationResult = new jasmine.ExpectationResult({ - 78 matcherName: matcherName, - 79 passed: result, - 80 expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], - 81 actual: this.actual, - 82 message: message - 83 }); - 84 this.spec.addMatcherResult(expectationResult); - 85 return result; - 86 }; - 87 }; - 88 - 89 - 90 - 91 - 92 /** - 93 * toBe: compares the actual to the expected using === - 94 * @param expected - 95 */ - 96 jasmine.Matchers.prototype.toBe = function(expected) { - 97 return this.actual === expected; - 98 }; - 99 -100 /** -101 * toNotBe: compares the actual to the expected using !== -102 * @param expected -103 */ -104 jasmine.Matchers.prototype.toNotBe = function(expected) { -105 return this.actual !== expected; -106 }; -107 -108 /** -109 * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. -110 * -111 * @param expected -112 */ -113 jasmine.Matchers.prototype.toEqual = function(expected) { -114 return this.env.equals_(this.actual, expected); -115 }; -116 -117 /** -118 * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual -119 * @param expected -120 */ -121 jasmine.Matchers.prototype.toNotEqual = function(expected) { -122 return !this.env.equals_(this.actual, expected); -123 }; -124 -125 /** -126 * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes -127 * a pattern or a String. -128 * -129 * @param expected -130 */ -131 jasmine.Matchers.prototype.toMatch = function(expected) { -132 return new RegExp(expected).test(this.actual); -133 }; -134 -135 /** -136 * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch -137 * @param expected + 25 jasmine.Matchers.wrapInto_ = function(prototype, matchersClass) { + 26 for (var methodName in prototype) { + 27 if (methodName == 'report') continue; + 28 var orig = prototype[methodName]; + 29 matchersClass.prototype[methodName] = jasmine.Matchers.matcherFn_(methodName, orig); + 30 } + 31 }; + 32 + 33 jasmine.Matchers.matcherFn_ = function(matcherName, matcherFunction) { + 34 return function() { + 35 var matcherArgs = jasmine.util.argsToArray(arguments); + 36 var result = matcherFunction.apply(this, arguments); + 37 + 38 if (this.isNot) { + 39 result = !result; + 40 } + 41 + 42 if (this.reportWasCalled_) return result; + 43 + 44 var message; + 45 if (!result) { + 46 if (this.message) { + 47 message = this.message.apply(this, arguments); + 48 if (jasmine.isArray_(message)) { + 49 message = message[this.isNot ? 1 : 0]; + 50 } + 51 } else { + 52 var englishyPredicate = matcherName.replace(/[A-Z]/g, function(s) { return ' ' + s.toLowerCase(); }); + 53 message = "Expected " + jasmine.pp(this.actual) + (this.isNot ? " not " : " ") + englishyPredicate; + 54 if (matcherArgs.length > 0) { + 55 for (var i = 0; i < matcherArgs.length; i++) { + 56 if (i > 0) message += ","; + 57 message += " " + jasmine.pp(matcherArgs[i]); + 58 } + 59 } + 60 message += "."; + 61 } + 62 } + 63 var expectationResult = new jasmine.ExpectationResult({ + 64 matcherName: matcherName, + 65 passed: result, + 66 expected: matcherArgs.length > 1 ? matcherArgs : matcherArgs[0], + 67 actual: this.actual, + 68 message: message + 69 }); + 70 this.spec.addMatcherResult(expectationResult); + 71 return result; + 72 }; + 73 }; + 74 + 75 + 76 + 77 + 78 /** + 79 * toBe: compares the actual to the expected using === + 80 * @param expected + 81 */ + 82 jasmine.Matchers.prototype.toBe = function(expected) { + 83 return this.actual === expected; + 84 }; + 85 + 86 /** + 87 * toNotBe: compares the actual to the expected using !== + 88 * @param expected + 89 */ + 90 jasmine.Matchers.prototype.toNotBe = function(expected) { + 91 return this.actual !== expected; + 92 }; + 93 + 94 /** + 95 * toEqual: compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. + 96 * + 97 * @param expected + 98 */ + 99 jasmine.Matchers.prototype.toEqual = function(expected) { +100 return this.env.equals_(this.actual, expected); +101 }; +102 +103 /** +104 * toNotEqual: compares the actual to the expected using the ! of jasmine.Matchers.toEqual +105 * @param expected +106 */ +107 jasmine.Matchers.prototype.toNotEqual = function(expected) { +108 return !this.env.equals_(this.actual, expected); +109 }; +110 +111 /** +112 * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes +113 * a pattern or a String. +114 * +115 * @param expected +116 */ +117 jasmine.Matchers.prototype.toMatch = function(expected) { +118 return new RegExp(expected).test(this.actual); +119 }; +120 +121 /** +122 * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch +123 * @param expected +124 */ +125 jasmine.Matchers.prototype.toNotMatch = function(expected) { +126 return !(new RegExp(expected).test(this.actual)); +127 }; +128 +129 /** +130 * Matcher that compares the actual to jasmine.undefined. +131 */ +132 jasmine.Matchers.prototype.toBeDefined = function() { +133 return (this.actual !== jasmine.undefined); +134 }; +135 +136 /** +137 * Matcher that compares the actual to jasmine.undefined. 138 */ -139 jasmine.Matchers.prototype.toNotMatch = function(expected) { -140 return !(new RegExp(expected).test(this.actual)); +139 jasmine.Matchers.prototype.toBeUndefined = function() { +140 return (this.actual === jasmine.undefined); 141 }; 142 143 /** -144 * Matcher that compares the actual to jasmine.undefined. +144 * Matcher that compares the actual to null. 145 */ -146 jasmine.Matchers.prototype.toBeDefined = function() { -147 return (this.actual !== jasmine.undefined); +146 jasmine.Matchers.prototype.toBeNull = function() { +147 return (this.actual === null); 148 }; 149 150 /** -151 * Matcher that compares the actual to jasmine.undefined. +151 * Matcher that boolean not-nots the actual. 152 */ -153 jasmine.Matchers.prototype.toBeUndefined = function() { -154 return (this.actual === jasmine.undefined); +153 jasmine.Matchers.prototype.toBeTruthy = function() { +154 return !!this.actual; 155 }; 156 -157 /** -158 * Matcher that compares the actual to null. -159 */ -160 jasmine.Matchers.prototype.toBeNull = function() { -161 return (this.actual === null); -162 }; -163 -164 /** -165 * Matcher that boolean not-nots the actual. -166 */ -167 jasmine.Matchers.prototype.toBeTruthy = function() { -168 return !!this.actual; -169 }; -170 -171 -172 /** -173 * Matcher that boolean nots the actual. -174 */ -175 jasmine.Matchers.prototype.toBeFalsy = function() { -176 return !this.actual; -177 }; -178 -179 /** -180 * Matcher that checks to see if the actual, a Jasmine spy, was called. -181 */ -182 jasmine.Matchers.prototype.wasCalled = function() { -183 if (arguments.length > 0) { -184 throw new Error('wasCalled does not take arguments, use wasCalledWith'); -185 } -186 -187 if (!jasmine.isSpy(this.actual)) { -188 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); -189 } -190 -191 this.message = function() { -192 return "Expected spy " + this.actual.identity + " to have been called."; -193 }; -194 -195 return this.actual.wasCalled; -196 }; -197 -198 /** -199 * Matcher that checks to see if the actual, a Jasmine spy, was not called. -200 */ -201 jasmine.Matchers.prototype.wasNotCalled = function() { -202 if (arguments.length > 0) { -203 throw new Error('wasNotCalled does not take arguments'); -204 } -205 -206 if (!jasmine.isSpy(this.actual)) { -207 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); -208 } -209 -210 this.message = function() { -211 return "Expected spy " + this.actual.identity + " to not have been called."; -212 }; -213 -214 return !this.actual.wasCalled; -215 }; -216 -217 /** -218 * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. -219 * -220 * @example -221 * -222 */ -223 jasmine.Matchers.prototype.wasCalledWith = function() { -224 var expectedArgs = jasmine.util.argsToArray(arguments); -225 if (!jasmine.isSpy(this.actual)) { -226 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); -227 } -228 this.message = function() { -229 if (this.actual.callCount == 0) { -230 return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called."; -231 } else { -232 return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall); -233 } -234 }; -235 -236 return this.env.contains_(this.actual.argsForCall, expectedArgs); -237 }; -238 -239 jasmine.Matchers.prototype.wasNotCalledWith = function() { -240 var expectedArgs = jasmine.util.argsToArray(arguments); -241 if (!jasmine.isSpy(this.actual)) { -242 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); -243 } -244 -245 this.message = function() { -246 return "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was"; -247 }; -248 -249 return !this.env.contains_(this.actual.argsForCall, expectedArgs); -250 }; -251 -252 /** -253 * Matcher that checks that the expected item is an element in the actual Array. -254 * -255 * @param {Object} expected -256 */ -257 jasmine.Matchers.prototype.toContain = function(expected) { -258 return this.env.contains_(this.actual, expected); -259 }; -260 -261 /** -262 * Matcher that checks that the expected item is NOT an element in the actual Array. -263 * -264 * @param {Object} expected -265 */ -266 jasmine.Matchers.prototype.toNotContain = function(expected) { -267 return !this.env.contains_(this.actual, expected); -268 }; -269 -270 jasmine.Matchers.prototype.toBeLessThan = function(expected) { -271 return this.actual < expected; -272 }; -273 -274 jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { -275 return this.actual > expected; -276 }; -277 -278 /** -279 * Matcher that checks that the expected exception was thrown by the actual. -280 * -281 * @param {String} expected -282 */ -283 jasmine.Matchers.prototype.toThrow = function(expected) { -284 var result = false; -285 var exception; -286 if (typeof this.actual != 'function') { -287 throw new Error('Actual is not a function'); -288 } -289 try { -290 this.actual(); -291 } catch (e) { -292 exception = e; -293 } -294 if (exception) { -295 result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); -296 } -297 -298 this.message = function() { -299 if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { -300 return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception].join(' '); -301 } else { -302 return "Expected function to throw an exception."; -303 } -304 }; -305 -306 return result; -307 }; -308 -309 jasmine.Matchers.Any = function(expectedClass) { -310 this.expectedClass = expectedClass; -311 }; -312 -313 jasmine.Matchers.Any.prototype.matches = function(other) { -314 if (this.expectedClass == String) { -315 return typeof other == 'string' || other instanceof String; -316 } -317 -318 if (this.expectedClass == Number) { -319 return typeof other == 'number' || other instanceof Number; -320 } -321 -322 if (this.expectedClass == Function) { -323 return typeof other == 'function' || other instanceof Function; -324 } -325 -326 if (this.expectedClass == Object) { -327 return typeof other == 'object'; -328 } -329 -330 return other instanceof this.expectedClass; -331 }; -332 -333 jasmine.Matchers.Any.prototype.toString = function() { -334 return '<jasmine.any(' + this.expectedClass + ')>'; -335 }; -336 -337 \ No newline at end of file +157 +158 /** +159 * Matcher that boolean nots the actual. +160 */ +161 jasmine.Matchers.prototype.toBeFalsy = function() { +162 return !this.actual; +163 }; +164 +165 /** +166 * Matcher that checks to see if the actual, a Jasmine spy, was called. +167 */ +168 jasmine.Matchers.prototype.wasCalled = function() { +169 if (arguments.length > 0) { +170 throw new Error('wasCalled does not take arguments, use wasCalledWith'); +171 } +172 +173 if (!jasmine.isSpy(this.actual)) { +174 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); +175 } +176 +177 this.message = function() { +178 return "Expected spy " + this.actual.identity + " to have been called."; +179 }; +180 +181 return this.actual.wasCalled; +182 }; +183 +184 /** +185 * Matcher that checks to see if the actual, a Jasmine spy, was not called. +186 */ +187 jasmine.Matchers.prototype.wasNotCalled = function() { +188 if (arguments.length > 0) { +189 throw new Error('wasNotCalled does not take arguments'); +190 } +191 +192 if (!jasmine.isSpy(this.actual)) { +193 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); +194 } +195 +196 this.message = function() { +197 return "Expected spy " + this.actual.identity + " to not have been called."; +198 }; +199 +200 return !this.actual.wasCalled; +201 }; +202 +203 /** +204 * Matcher that checks to see if the actual, a Jasmine spy, was called with a set of parameters. +205 * +206 * @example +207 * +208 */ +209 jasmine.Matchers.prototype.wasCalledWith = function() { +210 var expectedArgs = jasmine.util.argsToArray(arguments); +211 if (!jasmine.isSpy(this.actual)) { +212 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); +213 } +214 this.message = function() { +215 if (this.actual.callCount == 0) { +216 return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but it was never called."; +217 } else { +218 return "Expected spy to have been called with " + jasmine.pp(expectedArgs) + " but was called with " + jasmine.pp(this.actual.argsForCall); +219 } +220 }; +221 +222 return this.env.contains_(this.actual.argsForCall, expectedArgs); +223 }; +224 +225 jasmine.Matchers.prototype.wasNotCalledWith = function() { +226 var expectedArgs = jasmine.util.argsToArray(arguments); +227 if (!jasmine.isSpy(this.actual)) { +228 throw new Error('Expected a spy, but got ' + jasmine.pp(this.actual) + '.'); +229 } +230 +231 this.message = function() { +232 return "Expected spy not to have been called with " + jasmine.pp(expectedArgs) + " but it was"; +233 }; +234 +235 return !this.env.contains_(this.actual.argsForCall, expectedArgs); +236 }; +237 +238 /** +239 * Matcher that checks that the expected item is an element in the actual Array. +240 * +241 * @param {Object} expected +242 */ +243 jasmine.Matchers.prototype.toContain = function(expected) { +244 return this.env.contains_(this.actual, expected); +245 }; +246 +247 /** +248 * Matcher that checks that the expected item is NOT an element in the actual Array. +249 * +250 * @param {Object} expected +251 */ +252 jasmine.Matchers.prototype.toNotContain = function(expected) { +253 return !this.env.contains_(this.actual, expected); +254 }; +255 +256 jasmine.Matchers.prototype.toBeLessThan = function(expected) { +257 return this.actual < expected; +258 }; +259 +260 jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { +261 return this.actual > expected; +262 }; +263 +264 /** +265 * Matcher that checks that the expected exception was thrown by the actual. +266 * +267 * @param {String} expected +268 */ +269 jasmine.Matchers.prototype.toThrow = function(expected) { +270 var result = false; +271 var exception; +272 if (typeof this.actual != 'function') { +273 throw new Error('Actual is not a function'); +274 } +275 try { +276 this.actual(); +277 } catch (e) { +278 exception = e; +279 } +280 if (exception) { +281 result = (expected === jasmine.undefined || this.env.equals_(exception.message || exception, expected.message || expected)); +282 } +283 +284 this.message = function() { +285 if (exception && (expected === jasmine.undefined || !this.env.equals_(exception.message || exception, expected.message || expected))) { +286 return ["Expected function to throw", expected.message || expected, ", but it threw", exception.message || exception].join(' '); +287 } else { +288 return "Expected function to throw an exception."; +289 } +290 }; +291 +292 return result; +293 }; +294 +295 jasmine.Matchers.Any = function(expectedClass) { +296 this.expectedClass = expectedClass; +297 }; +298 +299 jasmine.Matchers.Any.prototype.matches = function(other) { +300 if (this.expectedClass == String) { +301 return typeof other == 'string' || other instanceof String; +302 } +303 +304 if (this.expectedClass == Number) { +305 return typeof other == 'number' || other instanceof Number; +306 } +307 +308 if (this.expectedClass == Function) { +309 return typeof other == 'function' || other instanceof Function; +310 } +311 +312 if (this.expectedClass == Object) { +313 return typeof other == 'object'; +314 } +315 +316 return other instanceof this.expectedClass; +317 }; +318 +319 jasmine.Matchers.Any.prototype.toString = function() { +320 return '<jasmine.any(' + this.expectedClass + ')>'; +321 }; +322 +323 \ No newline at end of file diff --git a/doc/symbols/src/src_NestedResults.js.html b/doc/symbols/src/src_NestedResults.js.html index 8f8c392..7a9e82a 100644 --- a/doc/symbols/src/src_NestedResults.js.html +++ b/doc/symbols/src/src_NestedResults.js.html @@ -45,11 +45,11 @@ 38 }; 39 40 /** - 41 * Tracks a result's message. - 42 * @param message + 41 * Adds a log message. + 42 * @param values Array of message parts which will be concatenated later. 43 */ - 44 jasmine.NestedResults.prototype.log = function(message) { - 45 this.items_.push(new jasmine.MessageResult(message)); + 44 jasmine.NestedResults.prototype.log = function(values) { + 45 this.items_.push(new jasmine.MessageResult(values)); 46 }; 47 48 /** @@ -64,7 +64,7 @@ 57 * @param {jasmine.ExpectationResult|jasmine.NestedResults} result 58 */ 59 jasmine.NestedResults.prototype.addResult = function(result) { - 60 if (result.type != 'MessageResult') { + 60 if (result.type != 'log') { 61 if (result.items_) { 62 this.rollupCounts(result); 63 } else { diff --git a/doc/symbols/src/src_PrettyPrinter.js.html b/doc/symbols/src/src_PrettyPrinter.js.html index 6b112d0..9e638b4 100644 --- a/doc/symbols/src/src_PrettyPrinter.js.html +++ b/doc/symbols/src/src_PrettyPrinter.js.html @@ -28,8 +28,8 @@ 21 this.emitScalar('undefined'); 22 } else if (value === null) { 23 this.emitScalar('null'); - 24 } else if (value.navigator && value.frames && value.setTimeout) { - 25 this.emitScalar('<window>'); + 24 } else if (value === jasmine.getGlobal()) { + 25 this.emitScalar('<global>'); 26 } else if (value instanceof jasmine.Matchers.Any) { 27 this.emitScalar(value.toString()); 28 } else if (typeof value === 'string') { diff --git a/doc/symbols/src/src_Runner.js.html b/doc/symbols/src/src_Runner.js.html index 7875142..1bb191d 100644 --- a/doc/symbols/src/src_Runner.js.html +++ b/doc/symbols/src/src_Runner.js.html @@ -32,12 +32,12 @@ 25 26 jasmine.Runner.prototype.beforeEach = function(beforeEachFunction) { 27 beforeEachFunction.typeName = 'beforeEach'; - 28 this.before_.push(beforeEachFunction); + 28 this.before_.splice(0,0,beforeEachFunction); 29 }; 30 31 jasmine.Runner.prototype.afterEach = function(afterEachFunction) { 32 afterEachFunction.typeName = 'afterEach'; - 33 this.after_.push(afterEachFunction); + 33 this.after_.splice(0,0,afterEachFunction); 34 }; 35 36 @@ -65,11 +65,20 @@ 58 return specs; 59 }; 60 - 61 - 62 jasmine.Runner.prototype.suites = function() { - 63 return this.suites_; - 64 }; - 65 - 66 jasmine.Runner.prototype.results = function() { - 67 return this.queue.results(); - 68 }; \ No newline at end of file + 61 jasmine.Runner.prototype.suites = function() { + 62 return this.suites_; + 63 }; + 64 + 65 jasmine.Runner.prototype.topLevelSuites = function() { + 66 var topLevelSuites = []; + 67 for (var i = 0; i < this.suites_.length; i++) { + 68 if (!this.suites_[i].parentSuite) { + 69 topLevelSuites.push(this.suites_[i]); + 70 } + 71 } + 72 return topLevelSuites; + 73 }; + 74 + 75 jasmine.Runner.prototype.results = function() { + 76 return this.queue.results(); + 77 }; \ No newline at end of file diff --git a/doc/symbols/src/src_Spec.js.html b/doc/symbols/src/src_Spec.js.html index 4743b11..83a6f96 100644 --- a/doc/symbols/src/src_Spec.js.html +++ b/doc/symbols/src/src_Spec.js.html @@ -44,171 +44,169 @@ 37 return this.results_; 38 }; 39 - 40 jasmine.Spec.prototype.log = function(message) { - 41 return this.results_.log(message); + 40 jasmine.Spec.prototype.log = function() { + 41 return this.results_.log(arguments); 42 }; 43 - 44 /** @deprecated */ - 45 jasmine.Spec.prototype.getResults = function() { - 46 return this.results_; - 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 jasmine.Spec.prototype.addMatcherResult = function(result) { - 64 this.results_.addResult(result); - 65 }; - 66 - 67 jasmine.Spec.prototype.expect = function(actual) { - 68 var positive = new (this.getMatchersClass_())(this.env, actual, this); - 69 positive.not = new (this.getMatchersClass_())(this.env, actual, this, true); - 70 return positive; - 71 }; - 72 - 73 jasmine.Spec.prototype.waits = function(timeout) { - 74 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); - 75 this.addToQueue(waitsFunc); - 76 return this; - 77 }; - 78 - 79 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { - 80 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); - 81 this.addToQueue(waitsForFunc); - 82 return this; - 83 }; - 84 - 85 jasmine.Spec.prototype.fail = function (e) { - 86 var expectationResult = new jasmine.ExpectationResult({ - 87 passed: false, - 88 message: e ? jasmine.util.formatException(e) : 'Exception' - 89 }); - 90 this.results_.addResult(expectationResult); - 91 }; - 92 - 93 jasmine.Spec.prototype.getMatchersClass_ = function() { - 94 return this.matchersClass || this.env.matchersClass; - 95 }; - 96 - 97 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { - 98 var parent = this.getMatchersClass_(); - 99 var newMatchersClass = function() { -100 parent.apply(this, arguments); -101 }; -102 jasmine.util.inherit(newMatchersClass, parent); -103 jasmine.Matchers.wrapInto_(matchersPrototype, newMatchersClass); -104 this.matchersClass = newMatchersClass; -105 }; -106 -107 jasmine.Spec.prototype.finishCallback = function() { -108 this.env.reporter.reportSpecResults(this); -109 }; -110 -111 jasmine.Spec.prototype.finish = function(onComplete) { -112 this.removeAllSpies(); -113 this.finishCallback(); -114 if (onComplete) { -115 onComplete(); -116 } -117 }; -118 -119 jasmine.Spec.prototype.after = function(doAfter) { -120 if (this.queue.isRunning()) { -121 this.queue.add(new jasmine.Block(this.env, doAfter, this)); -122 } else { -123 this.afterCallbacks.unshift(doAfter); -124 } -125 }; -126 -127 jasmine.Spec.prototype.execute = function(onComplete) { -128 var spec = this; -129 if (!spec.env.specFilter(spec)) { -130 spec.results_.skipped = true; -131 spec.finish(onComplete); -132 return; -133 } -134 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); + 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.env.currentSpec = spec; +136 spec.addBeforesAndAftersToQueue(); 137 -138 spec.addBeforesAndAftersToQueue(); -139 -140 spec.queue.start(function () { -141 spec.finish(onComplete); -142 }); -143 }; -144 -145 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { -146 var runner = this.env.currentRunner(); -147 var i; -148 -149 for (var suite = this.suite; suite; suite = suite.parentSuite) { -150 for (i = 0; i < suite.before_.length; i++) { -151 this.queue.addBefore(new jasmine.Block(this.env, suite.before_[i], this)); -152 } -153 } -154 for (i = 0; i < runner.before_.length; i++) { -155 this.queue.addBefore(new jasmine.Block(this.env, runner.before_[i], this)); -156 } -157 for (i = 0; i < this.afterCallbacks.length; i++) { -158 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); -159 } -160 for (suite = this.suite; suite; suite = suite.parentSuite) { -161 for (i = 0; i < suite.after_.length; i++) { -162 this.queue.add(new jasmine.Block(this.env, suite.after_[i], this)); -163 } -164 } -165 for (i = 0; i < runner.after_.length; i++) { -166 this.queue.add(new jasmine.Block(this.env, runner.after_[i], this)); -167 } -168 }; -169 -170 jasmine.Spec.prototype.explodes = function() { -171 throw 'explodes function should not have been called'; -172 }; -173 -174 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { -175 if (obj == jasmine.undefined) { -176 throw "spyOn could not find an object to spy upon for " + methodName + "()"; -177 } -178 -179 if (!ignoreMethodDoesntExist && obj[methodName] === jasmine.undefined) { -180 throw methodName + '() method does not exist'; -181 } -182 -183 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { -184 throw new Error(methodName + ' has already been spied upon'); -185 } +138 spec.queue.start(function () { +139 spec.finish(onComplete); +140 }); +141 }; +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 } +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 } +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 var spyObj = jasmine.createSpy(methodName); -188 -189 this.spies_.push(spyObj); -190 spyObj.baseObj = obj; -191 spyObj.methodName = methodName; -192 spyObj.originalValue = obj[methodName]; +187 this.spies_.push(spyObj); +188 spyObj.baseObj = obj; +189 spyObj.methodName = methodName; +190 spyObj.originalValue = obj[methodName]; +191 +192 obj[methodName] = spyObj; 193 -194 obj[methodName] = spyObj; -195 -196 return spyObj; -197 }; -198 -199 jasmine.Spec.prototype.removeAllSpies = function() { -200 for (var i = 0; i < this.spies_.length; i++) { -201 var spy = this.spies_[i]; -202 spy.baseObj[spy.methodName] = spy.originalValue; -203 } -204 this.spies_ = []; -205 }; -206 -207 \ No newline at end of file +194 return spyObj; +195 }; +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 diff --git a/doc/symbols/src/src_Suite.js.html b/doc/symbols/src/src_Suite.js.html index db39a6c..3ff28ae 100644 --- a/doc/symbols/src/src_Suite.js.html +++ b/doc/symbols/src/src_Suite.js.html @@ -23,55 +23,67 @@ 16 self.env = env; 17 self.before_ = []; 18 self.after_ = []; - 19 self.specs_ = []; - 20 }; - 21 - 22 jasmine.Suite.prototype.getFullName = function() { - 23 var fullName = this.description; - 24 for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { - 25 fullName = parentSuite.description + ' ' + fullName; - 26 } - 27 return fullName; - 28 }; - 29 - 30 jasmine.Suite.prototype.finish = function(onComplete) { - 31 this.env.reporter.reportSuiteResults(this); - 32 this.finished = true; - 33 if (typeof(onComplete) == 'function') { - 34 onComplete(); - 35 } - 36 }; - 37 - 38 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { - 39 beforeEachFunction.typeName = 'beforeEach'; - 40 this.before_.push(beforeEachFunction); - 41 }; - 42 - 43 jasmine.Suite.prototype.afterEach = function(afterEachFunction) { - 44 afterEachFunction.typeName = 'afterEach'; - 45 this.after_.push(afterEachFunction); - 46 }; - 47 - 48 jasmine.Suite.prototype.results = function() { - 49 return this.queue.results(); - 50 }; - 51 - 52 jasmine.Suite.prototype.add = function(block) { - 53 if (block instanceof jasmine.Suite) { - 54 this.env.currentRunner().addSuite(block); - 55 } else { - 56 this.specs_.push(block); - 57 } - 58 this.queue.add(block); - 59 }; - 60 - 61 jasmine.Suite.prototype.specs = function() { - 62 return this.specs_; + 19 self.children_ = []; + 20 self.suites_ = []; + 21 self.specs_ = []; + 22 }; + 23 + 24 jasmine.Suite.prototype.getFullName = function() { + 25 var fullName = this.description; + 26 for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { + 27 fullName = parentSuite.description + ' ' + fullName; + 28 } + 29 return fullName; + 30 }; + 31 + 32 jasmine.Suite.prototype.finish = function(onComplete) { + 33 this.env.reporter.reportSuiteResults(this); + 34 this.finished = true; + 35 if (typeof(onComplete) == 'function') { + 36 onComplete(); + 37 } + 38 }; + 39 + 40 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { + 41 beforeEachFunction.typeName = 'beforeEach'; + 42 this.before_.unshift(beforeEachFunction); + 43 }; + 44 + 45 jasmine.Suite.prototype.afterEach = function(afterEachFunction) { + 46 afterEachFunction.typeName = 'afterEach'; + 47 this.after_.unshift(afterEachFunction); + 48 }; + 49 + 50 jasmine.Suite.prototype.results = function() { + 51 return this.queue.results(); + 52 }; + 53 + 54 jasmine.Suite.prototype.add = function(suiteOrSpec) { + 55 this.children_.push(suiteOrSpec); + 56 if (suiteOrSpec instanceof jasmine.Suite) { + 57 this.suites_.push(suiteOrSpec); + 58 this.env.currentRunner().addSuite(suiteOrSpec); + 59 } else { + 60 this.specs_.push(suiteOrSpec); + 61 } + 62 this.queue.add(suiteOrSpec); 63 }; 64 - 65 jasmine.Suite.prototype.execute = function(onComplete) { - 66 var self = this; - 67 this.queue.start(function () { - 68 self.finish(onComplete); - 69 }); - 70 }; \ No newline at end of file + 65 jasmine.Suite.prototype.specs = function() { + 66 return this.specs_; + 67 }; + 68 + 69 jasmine.Suite.prototype.suites = function() { + 70 return this.suites_; + 71 }; + 72 + 73 jasmine.Suite.prototype.children = function() { + 74 return this.children_; + 75 }; + 76 + 77 jasmine.Suite.prototype.execute = function(onComplete) { + 78 var self = this; + 79 this.queue.start(function () { + 80 self.finish(onComplete); + 81 }); + 82 }; \ No newline at end of file diff --git a/doc/symbols/src/src_WaitsForBlock.js.html b/doc/symbols/src/src_WaitsForBlock.js.html index 60ce1ad..18c2bda 100644 --- a/doc/symbols/src/src_WaitsForBlock.js.html +++ b/doc/symbols/src/src_WaitsForBlock.js.html @@ -37,9 +37,8 @@ 30 name: 'timeout', 31 message: message 32 }); - 33 self.spec._next(); - 34 } else { - 35 self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; - 36 self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); - 37 } - 38 }; \ No newline at end of file + 33 } else { + 34 self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; + 35 self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); + 36 } + 37 }; \ 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 a917d73..bfddf9c 100644 --- a/doc/symbols/src/src_base.js.html +++ b/doc/symbols/src/src_base.js.html @@ -20,7 +20,7 @@ 13 }; 14 15 /** - 16 * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code is just + 16 * Use <code>jasmine.undefined</code> instead of <code>undefined</code>, since <code>undefined</code> is just 17 * a plain old variable and may be redefined by somebody else. 18 * 19 * @private @@ -33,553 +33,552 @@ 26 */ 27 jasmine.DEFAULT_UPDATE_INTERVAL = 250; 28 - 29 /** - 30 * Allows for bound functions to be compared. Internal use only. - 31 * - 32 * @ignore - 33 * @private - 34 * @param base {Object} bound 'this' for the function - 35 * @param name {Function} function to find - 36 */ - 37 jasmine.bindOriginal_ = function(base, name) { - 38 var original = base[name]; - 39 if (original.apply) { - 40 return function() { - 41 return original.apply(base, arguments); - 42 }; - 43 } else { - 44 // IE support - 45 return window[name]; - 46 } - 47 }; - 48 - 49 jasmine.setTimeout = jasmine.bindOriginal_(window, 'setTimeout'); - 50 jasmine.clearTimeout = jasmine.bindOriginal_(window, 'clearTimeout'); - 51 jasmine.setInterval = jasmine.bindOriginal_(window, 'setInterval'); - 52 jasmine.clearInterval = jasmine.bindOriginal_(window, 'clearInterval'); - 53 - 54 jasmine.MessageResult = function(text) { - 55 this.type = 'MessageResult'; - 56 this.text = text; - 57 this.trace = new Error(); // todo: test better - 58 }; - 59 - 60 jasmine.ExpectationResult = function(params) { - 61 this.type = 'ExpectationResult'; - 62 this.matcherName = params.matcherName; - 63 this.passed_ = params.passed; - 64 this.expected = params.expected; - 65 this.actual = params.actual; - 66 - 67 /** @deprecated */ - 68 this.details = params.details; - 69 - 70 this.message = this.passed_ ? 'Passed.' : params.message; - 71 this.trace = this.passed_ ? '' : new Error(this.message); - 72 }; - 73 - 74 jasmine.ExpectationResult.prototype.passed = function () { - 75 return this.passed_; - 76 }; - 77 - 78 /** - 79 * Getter for the Jasmine environment. Ensures one gets created - 80 */ - 81 jasmine.getEnv = function() { - 82 return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); - 83 }; - 84 - 85 /** - 86 * @ignore - 87 * @private - 88 * @param value - 89 * @returns {Boolean} - 90 */ - 91 jasmine.isArray_ = function(value) { - 92 return jasmine.isA_("Array", value); - 93 }; - 94 - 95 /** - 96 * @ignore - 97 * @private - 98 * @param value - 99 * @returns {Boolean} -100 */ -101 jasmine.isString_ = function(value) { -102 return jasmine.isA_("String", value); -103 }; -104 -105 /** -106 * @ignore -107 * @private -108 * @param value -109 * @returns {Boolean} -110 */ -111 jasmine.isNumber_ = function(value) { -112 return jasmine.isA_("Number", value); -113 }; -114 -115 /** -116 * @ignore -117 * @private -118 * @param {String} typeName -119 * @param value -120 * @returns {Boolean} -121 */ -122 jasmine.isA_ = function(typeName, value) { -123 return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; -124 }; -125 -126 /** -127 * Pretty printer for expecations. Takes any object and turns it into a human-readable string. -128 * -129 * @param value {Object} an object to be outputted -130 * @returns {String} -131 */ -132 jasmine.pp = function(value) { -133 var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); -134 stringPrettyPrinter.format(value); -135 return stringPrettyPrinter.string; -136 }; -137 -138 /** -139 * Returns true if the object is a DOM Node. -140 * -141 * @param {Object} obj object to check + 29 jasmine.getGlobal = function() { + 30 function getGlobal() { + 31 return this; + 32 } + 33 + 34 return getGlobal(); + 35 }; + 36 + 37 /** + 38 * Allows for bound functions to be compared. Internal use only. + 39 * + 40 * @ignore + 41 * @private + 42 * @param base {Object} bound 'this' for the function + 43 * @param name {Function} function to find + 44 */ + 45 jasmine.bindOriginal_ = function(base, name) { + 46 var original = base[name]; + 47 if (original.apply) { + 48 return function() { + 49 return original.apply(base, arguments); + 50 }; + 51 } else { + 52 // IE support + 53 return window[name]; + 54 } + 55 }; + 56 + 57 jasmine.setTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'setTimeout'); + 58 jasmine.clearTimeout = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearTimeout'); + 59 jasmine.setInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'setInterval'); + 60 jasmine.clearInterval = jasmine.bindOriginal_(jasmine.getGlobal(), 'clearInterval'); + 61 + 62 jasmine.MessageResult = function(values) { + 63 this.type = 'log'; + 64 this.values = values; + 65 this.trace = new Error(); // todo: test better + 66 }; + 67 + 68 jasmine.MessageResult.prototype.toString = function() { + 69 var text = ""; + 70 for(var i = 0; i < this.values.length; i++) { + 71 if (i > 0) text += " "; + 72 if (jasmine.isString_(this.values[i])) { + 73 text += this.values[i]; + 74 } else { + 75 text += jasmine.pp(this.values[i]); + 76 } + 77 } + 78 return text; + 79 }; + 80 + 81 jasmine.ExpectationResult = function(params) { + 82 this.type = 'expect'; + 83 this.matcherName = params.matcherName; + 84 this.passed_ = params.passed; + 85 this.expected = params.expected; + 86 this.actual = params.actual; + 87 + 88 this.message = this.passed_ ? 'Passed.' : params.message; + 89 this.trace = this.passed_ ? '' : new Error(this.message); + 90 }; + 91 + 92 jasmine.ExpectationResult.prototype.toString = function () { + 93 return this.message; + 94 }; + 95 + 96 jasmine.ExpectationResult.prototype.passed = function () { + 97 return this.passed_; + 98 }; + 99 +100 /** +101 * Getter for the Jasmine environment. Ensures one gets created +102 */ +103 jasmine.getEnv = function() { +104 return jasmine.currentEnv_ = jasmine.currentEnv_ || new jasmine.Env(); +105 }; +106 +107 /** +108 * @ignore +109 * @private +110 * @param value +111 * @returns {Boolean} +112 */ +113 jasmine.isArray_ = function(value) { +114 return jasmine.isA_("Array", value); +115 }; +116 +117 /** +118 * @ignore +119 * @private +120 * @param value +121 * @returns {Boolean} +122 */ +123 jasmine.isString_ = function(value) { +124 return jasmine.isA_("String", value); +125 }; +126 +127 /** +128 * @ignore +129 * @private +130 * @param value +131 * @returns {Boolean} +132 */ +133 jasmine.isNumber_ = function(value) { +134 return jasmine.isA_("Number", value); +135 }; +136 +137 /** +138 * @ignore +139 * @private +140 * @param {String} typeName +141 * @param value 142 * @returns {Boolean} 143 */ -144 jasmine.isDomNode = function(obj) { -145 return obj['nodeType'] > 0; +144 jasmine.isA_ = function(typeName, value) { +145 return Object.prototype.toString.apply(value) === '[object ' + typeName + ']'; 146 }; 147 148 /** -149 * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. +149 * Pretty printer for expecations. Takes any object and turns it into a human-readable string. 150 * -151 * @example -152 * // don't care about which function is passed in, as long as it's a function -153 * expect(mySpy).wasCalledWith(jasmine.any(Function)); -154 * -155 * @param {Class} clazz -156 * @returns matchable object of the type clazz -157 */ -158 jasmine.any = function(clazz) { -159 return new jasmine.Matchers.Any(clazz); -160 }; -161 -162 /** -163 * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. -164 * -165 * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine -166 * expectation syntax. Spies can be checked if they were called or not and what the calling params were. -167 * -168 * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs) -169 * Spies are torn down at the end of every spec. -170 * -171 * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. +151 * @param value {Object} an object to be outputted +152 * @returns {String} +153 */ +154 jasmine.pp = function(value) { +155 var stringPrettyPrinter = new jasmine.StringPrettyPrinter(); +156 stringPrettyPrinter.format(value); +157 return stringPrettyPrinter.string; +158 }; +159 +160 /** +161 * Returns true if the object is a DOM Node. +162 * +163 * @param {Object} obj object to check +164 * @returns {Boolean} +165 */ +166 jasmine.isDomNode = function(obj) { +167 return obj['nodeType'] > 0; +168 }; +169 +170 /** +171 * Returns a matchable 'generic' object of the class type. For use in expecations of type when values don't matter. 172 * 173 * @example -174 * // a stub -175 * var myStub = jasmine.createSpy('myStub'); // can be used anywhere +174 * // don't care about which function is passed in, as long as it's a function +175 * expect(mySpy).wasCalledWith(jasmine.any(Function)); 176 * -177 * // spy example -178 * var foo = { -179 * not: function(bool) { return !bool; } -180 * } -181 * -182 * // actual foo.not will not be called, execution stops -183 * spyOn(foo, 'not'); -184 -185 // foo.not spied upon, execution will continue to implementation -186 * spyOn(foo, 'not').andCallThrough(); -187 * -188 * // fake example -189 * var foo = { -190 * not: function(bool) { return !bool; } -191 * } +177 * @param {Class} clazz +178 * @returns matchable object of the type clazz +179 */ +180 jasmine.any = function(clazz) { +181 return new jasmine.Matchers.Any(clazz); +182 }; +183 +184 /** +185 * Jasmine Spies are test doubles that can act as stubs, spies, fakes or when used in an expecation, mocks. +186 * +187 * Spies should be created in test setup, before expectations. They can then be checked, using the standard Jasmine +188 * expectation syntax. Spies can be checked if they were called or not and what the calling params were. +189 * +190 * A Spy has the following mehtod: wasCalled, callCount, mostRecentCall, and argsForCall (see docs) +191 * Spies are torn down at the end of every spec. 192 * -193 * // foo.not(val) will return val -194 * spyOn(foo, 'not').andCallFake(function(value) {return value;}); -195 * -196 * // mock example -197 * foo.not(7 == 7); -198 * expect(foo.not).wasCalled(); -199 * expect(foo.not).wasCalledWith(true); -200 * -201 * @constructor -202 * @see spyOn, jasmine.createSpy, jasmine.createSpyObj -203 * @param {String} name -204 */ -205 jasmine.Spy = function(name) { -206 /** -207 * The name of the spy, if provided. -208 */ -209 this.identity = name || 'unknown'; -210 /** -211 * Is this Object a spy? -212 */ -213 this.isSpy = true; -214 /** -215 * The actual function this spy stubs. -216 */ -217 this.plan = function() { -218 }; -219 /** -220 * Tracking of the most recent call to the spy. -221 * @example -222 * var mySpy = jasmine.createSpy('foo'); -223 * mySpy(1, 2); -224 * mySpy.mostRecentCall.args = [1, 2]; -225 */ -226 this.mostRecentCall = {}; -227 +193 * Note: Do <b>not</b> call new jasmine.Spy() directly - a spy must be created using spyOn, jasmine.createSpy or jasmine.createSpyObj. +194 * +195 * @example +196 * // a stub +197 * var myStub = jasmine.createSpy('myStub'); // can be used anywhere +198 * +199 * // spy example +200 * var foo = { +201 * not: function(bool) { return !bool; } +202 * } +203 * +204 * // actual foo.not will not be called, execution stops +205 * spyOn(foo, 'not'); +206 +207 // foo.not spied upon, execution will continue to implementation +208 * spyOn(foo, 'not').andCallThrough(); +209 * +210 * // fake example +211 * var foo = { +212 * not: function(bool) { return !bool; } +213 * } +214 * +215 * // foo.not(val) will return val +216 * spyOn(foo, 'not').andCallFake(function(value) {return value;}); +217 * +218 * // mock example +219 * foo.not(7 == 7); +220 * expect(foo.not).wasCalled(); +221 * expect(foo.not).wasCalledWith(true); +222 * +223 * @constructor +224 * @see spyOn, jasmine.createSpy, jasmine.createSpyObj +225 * @param {String} name +226 */ +227 jasmine.Spy = function(name) { 228 /** -229 * Holds arguments for each call to the spy, indexed by call count -230 * @example -231 * var mySpy = jasmine.createSpy('foo'); -232 * mySpy(1, 2); -233 * mySpy(7, 8); -234 * mySpy.mostRecentCall.args = [7, 8]; -235 * mySpy.argsForCall[0] = [1, 2]; -236 * mySpy.argsForCall[1] = [7, 8]; -237 */ -238 this.argsForCall = []; -239 this.calls = []; -240 }; -241 -242 /** -243 * Tells a spy to call through to the actual implemenatation. -244 * -245 * @example -246 * var foo = { -247 * bar: function() { // do some stuff } -248 * } -249 * -250 * // defining a spy on an existing property: foo.bar -251 * spyOn(foo, 'bar').andCallThrough(); -252 */ -253 jasmine.Spy.prototype.andCallThrough = function() { -254 this.plan = this.originalValue; -255 return this; -256 }; -257 -258 /** -259 * For setting the return value of a spy. -260 * -261 * @example -262 * // defining a spy from scratch: foo() returns 'baz' -263 * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); -264 * -265 * // defining a spy on an existing property: foo.bar() returns 'baz' -266 * spyOn(foo, 'bar').andReturn('baz'); -267 * -268 * @param {Object} value -269 */ -270 jasmine.Spy.prototype.andReturn = function(value) { -271 this.plan = function() { -272 return value; -273 }; -274 return this; -275 }; -276 -277 /** -278 * For throwing an exception when a spy is called. -279 * -280 * @example -281 * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' -282 * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); -283 * -284 * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' -285 * spyOn(foo, 'bar').andThrow('baz'); +229 * The name of the spy, if provided. +230 */ +231 this.identity = name || 'unknown'; +232 /** +233 * Is this Object a spy? +234 */ +235 this.isSpy = true; +236 /** +237 * The actual function this spy stubs. +238 */ +239 this.plan = function() { +240 }; +241 /** +242 * Tracking of the most recent call to the spy. +243 * @example +244 * var mySpy = jasmine.createSpy('foo'); +245 * mySpy(1, 2); +246 * mySpy.mostRecentCall.args = [1, 2]; +247 */ +248 this.mostRecentCall = {}; +249 +250 /** +251 * Holds arguments for each call to the spy, indexed by call count +252 * @example +253 * var mySpy = jasmine.createSpy('foo'); +254 * mySpy(1, 2); +255 * mySpy(7, 8); +256 * mySpy.mostRecentCall.args = [7, 8]; +257 * mySpy.argsForCall[0] = [1, 2]; +258 * mySpy.argsForCall[1] = [7, 8]; +259 */ +260 this.argsForCall = []; +261 this.calls = []; +262 }; +263 +264 /** +265 * Tells a spy to call through to the actual implemenatation. +266 * +267 * @example +268 * var foo = { +269 * bar: function() { // do some stuff } +270 * } +271 * +272 * // defining a spy on an existing property: foo.bar +273 * spyOn(foo, 'bar').andCallThrough(); +274 */ +275 jasmine.Spy.prototype.andCallThrough = function() { +276 this.plan = this.originalValue; +277 return this; +278 }; +279 +280 /** +281 * For setting the return value of a spy. +282 * +283 * @example +284 * // defining a spy from scratch: foo() returns 'baz' +285 * var foo = jasmine.createSpy('spy on foo').andReturn('baz'); 286 * -287 * @param {String} exceptionMsg -288 */ -289 jasmine.Spy.prototype.andThrow = function(exceptionMsg) { -290 this.plan = function() { -291 throw exceptionMsg; -292 }; -293 return this; -294 }; -295 -296 /** -297 * Calls an alternate implementation when a spy is called. -298 * -299 * @example -300 * var baz = function() { -301 * // do some stuff, return something -302 * } -303 * // defining a spy from scratch: foo() calls the function baz -304 * var foo = jasmine.createSpy('spy on foo').andCall(baz); +287 * // defining a spy on an existing property: foo.bar() returns 'baz' +288 * spyOn(foo, 'bar').andReturn('baz'); +289 * +290 * @param {Object} value +291 */ +292 jasmine.Spy.prototype.andReturn = function(value) { +293 this.plan = function() { +294 return value; +295 }; +296 return this; +297 }; +298 +299 /** +300 * For throwing an exception when a spy is called. +301 * +302 * @example +303 * // defining a spy from scratch: foo() throws an exception w/ message 'ouch' +304 * var foo = jasmine.createSpy('spy on foo').andThrow('baz'); 305 * -306 * // defining a spy on an existing property: foo.bar() calls an anonymnous function -307 * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); +306 * // defining a spy on an existing property: foo.bar() throws an exception w/ message 'ouch' +307 * spyOn(foo, 'bar').andThrow('baz'); 308 * -309 * @param {Function} fakeFunc +309 * @param {String} exceptionMsg 310 */ -311 jasmine.Spy.prototype.andCallFake = function(fakeFunc) { -312 this.plan = fakeFunc; -313 return this; -314 }; -315 -316 /** -317 * Resets all of a spy's the tracking variables so that it can be used again. -318 * -319 * @example -320 * spyOn(foo, 'bar'); -321 * -322 * foo.bar(); -323 * -324 * expect(foo.bar.callCount).toEqual(1); -325 * -326 * foo.bar.reset(); +311 jasmine.Spy.prototype.andThrow = function(exceptionMsg) { +312 this.plan = function() { +313 throw exceptionMsg; +314 }; +315 return this; +316 }; +317 +318 /** +319 * Calls an alternate implementation when a spy is called. +320 * +321 * @example +322 * var baz = function() { +323 * // do some stuff, return something +324 * } +325 * // defining a spy from scratch: foo() calls the function baz +326 * var foo = jasmine.createSpy('spy on foo').andCall(baz); 327 * -328 * expect(foo.bar.callCount).toEqual(0); -329 */ -330 jasmine.Spy.prototype.reset = function() { -331 this.wasCalled = false; -332 this.callCount = 0; -333 this.argsForCall = []; -334 this.calls = []; -335 this.mostRecentCall = {}; +328 * // defining a spy on an existing property: foo.bar() calls an anonymnous function +329 * spyOn(foo, 'bar').andCall(function() { return 'baz';} ); +330 * +331 * @param {Function} fakeFunc +332 */ +333 jasmine.Spy.prototype.andCallFake = function(fakeFunc) { +334 this.plan = fakeFunc; +335 return this; 336 }; 337 -338 jasmine.createSpy = function(name) { -339 -340 var spyObj = function() { -341 spyObj.wasCalled = true; -342 spyObj.callCount++; -343 var args = jasmine.util.argsToArray(arguments); -344 spyObj.mostRecentCall.object = this; -345 spyObj.mostRecentCall.args = args; -346 spyObj.argsForCall.push(args); -347 spyObj.calls.push({object: this, args: args}); -348 return spyObj.plan.apply(this, arguments); -349 }; -350 -351 var spy = new jasmine.Spy(name); -352 -353 for (var prop in spy) { -354 spyObj[prop] = spy[prop]; -355 } -356 -357 spyObj.reset(); -358 -359 return spyObj; -360 }; +338 /** +339 * Resets all of a spy's the tracking variables so that it can be used again. +340 * +341 * @example +342 * spyOn(foo, 'bar'); +343 * +344 * foo.bar(); +345 * +346 * expect(foo.bar.callCount).toEqual(1); +347 * +348 * foo.bar.reset(); +349 * +350 * expect(foo.bar.callCount).toEqual(0); +351 */ +352 jasmine.Spy.prototype.reset = function() { +353 this.wasCalled = false; +354 this.callCount = 0; +355 this.argsForCall = []; +356 this.calls = []; +357 this.mostRecentCall = {}; +358 }; +359 +360 jasmine.createSpy = function(name) { 361 -362 /** -363 * Determines whether an object is a spy. -364 * -365 * @param {jasmine.Spy|Object} putativeSpy -366 * @returns {Boolean} -367 */ -368 jasmine.isSpy = function(putativeSpy) { -369 return putativeSpy && putativeSpy.isSpy; -370 }; -371 -372 /** -373 * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something -374 * large in one call. -375 * -376 * @param {String} baseName name of spy class -377 * @param {Array} methodNames array of names of methods to make spies -378 */ -379 jasmine.createSpyObj = function(baseName, methodNames) { -380 if (!jasmine.isArray_(methodNames) || methodNames.length == 0) { -381 throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); -382 } -383 var obj = {}; -384 for (var i = 0; i < methodNames.length; i++) { -385 obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); -386 } -387 return obj; -388 }; -389 -390 jasmine.log = function(message) { -391 jasmine.getEnv().currentSpec.log(message); +362 var spyObj = function() { +363 spyObj.wasCalled = true; +364 spyObj.callCount++; +365 var args = jasmine.util.argsToArray(arguments); +366 spyObj.mostRecentCall.object = this; +367 spyObj.mostRecentCall.args = args; +368 spyObj.argsForCall.push(args); +369 spyObj.calls.push({object: this, args: args}); +370 return spyObj.plan.apply(this, arguments); +371 }; +372 +373 var spy = new jasmine.Spy(name); +374 +375 for (var prop in spy) { +376 spyObj[prop] = spy[prop]; +377 } +378 +379 spyObj.reset(); +380 +381 return spyObj; +382 }; +383 +384 /** +385 * Determines whether an object is a spy. +386 * +387 * @param {jasmine.Spy|Object} putativeSpy +388 * @returns {Boolean} +389 */ +390 jasmine.isSpy = function(putativeSpy) { +391 return putativeSpy && putativeSpy.isSpy; 392 }; 393 394 /** -395 * Function that installs a spy on an existing object's method name. Used within a Spec to create a spy. -396 * -397 * @example -398 * // spy example -399 * var foo = { -400 * not: function(bool) { return !bool; } -401 * } -402 * spyOn(foo, 'not'); // actual foo.not will not be called, execution stops -403 * -404 * @see jasmine.createSpy -405 * @param obj -406 * @param methodName -407 * @returns a Jasmine spy that can be chained with all spy methods -408 */ -409 var spyOn = function(obj, methodName) { -410 return jasmine.getEnv().currentSpec.spyOn(obj, methodName); -411 }; -412 -413 /** -414 * Creates a Jasmine spec that will be added to the current suite. -415 * -416 * // TODO: pending tests -417 * -418 * @example -419 * it('should be true', function() { -420 * expect(true).toEqual(true); -421 * }); -422 * -423 * @param {String} desc description of this specification -424 * @param {Function} func defines the preconditions and expectations of the spec -425 */ -426 var it = function(desc, func) { -427 return jasmine.getEnv().it(desc, func); -428 }; -429 -430 /** -431 * Creates a <em>disabled</em> Jasmine spec. -432 * -433 * A convenience method that allows existing specs to be disabled temporarily during development. -434 * -435 * @param {String} desc description of this specification -436 * @param {Function} func defines the preconditions and expectations of the spec -437 */ -438 var xit = function(desc, func) { -439 return jasmine.getEnv().xit(desc, func); -440 }; -441 -442 /** -443 * Starts a chain for a Jasmine expectation. -444 * -445 * It is passed an Object that is the actual value and should chain to one of the many -446 * jasmine.Matchers functions. -447 * -448 * @param {Object} actual Actual value to test against and expected value -449 */ -450 var expect = function(actual) { -451 return jasmine.getEnv().currentSpec.expect(actual); -452 }; -453 -454 /** -455 * Defines part of a jasmine spec. Used in cominbination with waits or waitsFor in asynchrnous specs. -456 * -457 * @param {Function} func Function that defines part of a jasmine spec. -458 */ -459 var runs = function(func) { -460 jasmine.getEnv().currentSpec.runs(func); -461 }; -462 -463 /** -464 * Waits for a timeout before moving to the next runs()-defined block. -465 * @param {Number} timeout -466 */ -467 var waits = function(timeout) { -468 jasmine.getEnv().currentSpec.waits(timeout); -469 }; -470 -471 /** -472 * Waits for the latchFunction to return true before proceeding to the next runs()-defined block. -473 * -474 * @param {Number} timeout -475 * @param {Function} latchFunction -476 * @param {String} message -477 */ -478 var waitsFor = function(timeout, latchFunction, message) { -479 jasmine.getEnv().currentSpec.waitsFor(timeout, latchFunction, message); -480 }; -481 -482 /** -483 * A function that is called before each spec in a suite. -484 * -485 * Used for spec setup, including validating assumptions. -486 * -487 * @param {Function} beforeEachFunction -488 */ -489 var beforeEach = function(beforeEachFunction) { -490 jasmine.getEnv().beforeEach(beforeEachFunction); -491 }; -492 -493 /** -494 * A function that is called after each spec in a suite. -495 * -496 * Used for restoring any state that is hijacked during spec execution. -497 * -498 * @param {Function} afterEachFunction -499 */ -500 var afterEach = function(afterEachFunction) { -501 jasmine.getEnv().afterEach(afterEachFunction); -502 }; -503 -504 /** -505 * Defines a suite of specifications. -506 * -507 * Stores the description and all defined specs in the Jasmine environment as one suite of specs. Variables declared -508 * are accessible by calls to beforeEach, it, and afterEach. Describe blocks can be nested, allowing for specialization -509 * of setup in some tests. -510 * -511 * @example -512 * // TODO: a simple suite -513 * -514 * // TODO: a simple suite with a nested describe block -515 * -516 * @param {String} description A string, usually the class under test. -517 * @param {Function} specDefinitions function that defines several specs. -518 */ -519 var describe = function(description, specDefinitions) { -520 return jasmine.getEnv().describe(description, specDefinitions); -521 }; -522 -523 /** -524 * Disables a suite of specifications. Used to disable some suites in a file, or files, temporarily during development. -525 * -526 * @param {String} description A string, usually the class under test. -527 * @param {Function} specDefinitions function that defines several specs. -528 */ -529 var xdescribe = function(description, specDefinitions) { -530 return jasmine.getEnv().xdescribe(description, specDefinitions); -531 }; -532 -533 -534 // Provide the XMLHttpRequest class for IE 5.x-6.x: -535 jasmine.XmlHttpRequest = (typeof XMLHttpRequest == "undefined") ? function() { -536 try { -537 return new ActiveXObject("Msxml2.XMLHTTP.6.0"); -538 } catch(e) { -539 } -540 try { -541 return new ActiveXObject("Msxml2.XMLHTTP.3.0"); -542 } catch(e) { -543 } -544 try { -545 return new ActiveXObject("Msxml2.XMLHTTP"); -546 } catch(e) { -547 } -548 try { -549 return new ActiveXObject("Microsoft.XMLHTTP"); -550 } catch(e) { -551 } -552 throw new Error("This browser does not support XMLHttpRequest."); -553 } : XMLHttpRequest; -554 -555 /** -556 * Adds suite files to an HTML document so that they are executed, thus adding them to the current -557 * Jasmine environment. -558 * -559 * @param {String} url path to the file to include -560 * @param {Boolean} opt_global -561 */ -562 jasmine.include = function(url, opt_global) { -563 if (opt_global) { -564 document.write('<script type="text/javascript" src="' + url + '"></' + 'script>'); -565 } else { -566 var xhr; -567 try { -568 xhr = new jasmine.XmlHttpRequest(); -569 xhr.open("GET", url, false); -570 xhr.send(null); -571 } catch(e) { -572 throw new Error("couldn't fetch " + url + ": " + e); -573 } -574 -575 return eval(xhr.responseText); -576 } -577 }; -578 \ No newline at end of file +395 * Creates a more complicated spy: an Object that has every property a function that is a spy. Used for stubbing something +396 * large in one call. +397 * +398 * @param {String} baseName name of spy class +399 * @param {Array} methodNames array of names of methods to make spies +400 */ +401 jasmine.createSpyObj = function(baseName, methodNames) { +402 if (!jasmine.isArray_(methodNames) || methodNames.length == 0) { +403 throw new Error('createSpyObj requires a non-empty array of method names to create spies for'); +404 } +405 var obj = {}; +406 for (var i = 0; i < methodNames.length; i++) { +407 obj[methodNames[i]] = jasmine.createSpy(baseName + '.' + methodNames[i]); +408 } +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 * }); +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 +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 diff --git a/doc/symbols/src/src_mock-timeout.js.html b/doc/symbols/src/src_mock-timeout.js.html index 664a3c3..9e4e6f6 100644 --- a/doc/symbols/src/src_mock-timeout.js.html +++ b/doc/symbols/src/src_mock-timeout.js.html @@ -5,181 +5,181 @@ .STRN {color: #393;} .REGX {color: #339;} .line {border-right: 1px dotted #666; color: #666; font-style: normal;} -
  1 // Mock setTimeout, clearTimeout
-  2 // Contributed by Pivotal Computer Systems, www.pivotalsf.com
-  3 
-  4 jasmine.FakeTimer = function() {
-  5   this.reset();
-  6 
-  7   var self = this;
-  8   self.setTimeout = function(funcToCall, millis) {
-  9     self.timeoutsMade++;
- 10     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
- 11     return self.timeoutsMade;
- 12   };
- 13 
- 14   self.setInterval = function(funcToCall, millis) {
- 15     self.timeoutsMade++;
- 16     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
- 17     return self.timeoutsMade;
- 18   };
- 19 
- 20   self.clearTimeout = function(timeoutKey) {
- 21     self.scheduledFunctions[timeoutKey] = jasmine.undefined;
- 22   };
- 23 
- 24   self.clearInterval = function(timeoutKey) {
- 25     self.scheduledFunctions[timeoutKey] = jasmine.undefined;
- 26   };
- 27 
- 28 };
- 29 
- 30 jasmine.FakeTimer.prototype.reset = function() {
- 31   this.timeoutsMade = 0;
- 32   this.scheduledFunctions = {};
- 33   this.nowMillis = 0;
- 34 };
- 35 
- 36 jasmine.FakeTimer.prototype.tick = function(millis) {
- 37   var oldMillis = this.nowMillis;
- 38   var newMillis = oldMillis + millis;
- 39   this.runFunctionsWithinRange(oldMillis, newMillis);
- 40   this.nowMillis = newMillis;
- 41 };
- 42 
- 43 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
- 44   var scheduledFunc;
- 45   var funcsToRun = [];
- 46   for (var timeoutKey in this.scheduledFunctions) {
- 47     scheduledFunc = this.scheduledFunctions[timeoutKey];
- 48     if (scheduledFunc != jasmine.undefined &&
- 49         scheduledFunc.runAtMillis >= oldMillis &&
- 50         scheduledFunc.runAtMillis <= nowMillis) {
- 51       funcsToRun.push(scheduledFunc);
- 52       this.scheduledFunctions[timeoutKey] = jasmine.undefined;
- 53     }
- 54   }
- 55 
- 56   if (funcsToRun.length > 0) {
- 57     funcsToRun.sort(function(a, b) {
- 58       return a.runAtMillis - b.runAtMillis;
- 59     });
- 60     for (var i = 0; i < funcsToRun.length; ++i) {
- 61       try {
- 62         var funcToRun = funcsToRun[i];
- 63         this.nowMillis = funcToRun.runAtMillis;
- 64         funcToRun.funcToCall();
- 65         if (funcToRun.recurring) {
- 66           this.scheduleFunction(funcToRun.timeoutKey,
- 67             funcToRun.funcToCall,
- 68             funcToRun.millis,
- 69             true);
- 70         }
- 71       } catch(e) {
- 72       }
- 73     }
- 74     this.runFunctionsWithinRange(oldMillis, nowMillis);
- 75   }
- 76 };
- 77 
- 78 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
- 79   this.scheduledFunctions[timeoutKey] = {
- 80     runAtMillis: this.nowMillis + millis,
- 81     funcToCall: funcToCall,
- 82     recurring: recurring,
- 83     timeoutKey: timeoutKey,
- 84     millis: millis
- 85   };
- 86 };
- 87 
- 88 /**
- 89  * @namespace
- 90  */
- 91 jasmine.Clock = {
- 92   defaultFakeTimer: new jasmine.FakeTimer(),
- 93 
- 94   reset: function() {
- 95     jasmine.Clock.assertInstalled();
- 96     jasmine.Clock.defaultFakeTimer.reset();
- 97   },
- 98 
- 99   tick: function(millis) {
-100     jasmine.Clock.assertInstalled();
-101     jasmine.Clock.defaultFakeTimer.tick(millis);
-102   },
-103 
-104   runFunctionsWithinRange: function(oldMillis, nowMillis) {
-105     jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
-106   },
-107 
-108   scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
-109     jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
-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: window.setTimeout,
-130     clearTimeout: window.clearTimeout,
-131     setInterval: window.setInterval,
-132     clearInterval: window.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 window.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 window.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 window.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 window.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 
+	
  1 // Mock setTimeout, clearTimeout
+  2 // Contributed by Pivotal Computer Systems, www.pivotalsf.com
+  3 
+  4 jasmine.FakeTimer = function() {
+  5   this.reset();
+  6 
+  7   var self = this;
+  8   self.setTimeout = function(funcToCall, millis) {
+  9     self.timeoutsMade++;
+ 10     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false);
+ 11     return self.timeoutsMade;
+ 12   };
+ 13 
+ 14   self.setInterval = function(funcToCall, millis) {
+ 15     self.timeoutsMade++;
+ 16     self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true);
+ 17     return self.timeoutsMade;
+ 18   };
+ 19 
+ 20   self.clearTimeout = function(timeoutKey) {
+ 21     self.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ 22   };
+ 23 
+ 24   self.clearInterval = function(timeoutKey) {
+ 25     self.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ 26   };
+ 27 
+ 28 };
+ 29 
+ 30 jasmine.FakeTimer.prototype.reset = function() {
+ 31   this.timeoutsMade = 0;
+ 32   this.scheduledFunctions = {};
+ 33   this.nowMillis = 0;
+ 34 };
+ 35 
+ 36 jasmine.FakeTimer.prototype.tick = function(millis) {
+ 37   var oldMillis = this.nowMillis;
+ 38   var newMillis = oldMillis + millis;
+ 39   this.runFunctionsWithinRange(oldMillis, newMillis);
+ 40   this.nowMillis = newMillis;
+ 41 };
+ 42 
+ 43 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) {
+ 44   var scheduledFunc;
+ 45   var funcsToRun = [];
+ 46   for (var timeoutKey in this.scheduledFunctions) {
+ 47     scheduledFunc = this.scheduledFunctions[timeoutKey];
+ 48     if (scheduledFunc != jasmine.undefined &&
+ 49         scheduledFunc.runAtMillis >= oldMillis &&
+ 50         scheduledFunc.runAtMillis <= nowMillis) {
+ 51       funcsToRun.push(scheduledFunc);
+ 52       this.scheduledFunctions[timeoutKey] = jasmine.undefined;
+ 53     }
+ 54   }
+ 55 
+ 56   if (funcsToRun.length > 0) {
+ 57     funcsToRun.sort(function(a, b) {
+ 58       return a.runAtMillis - b.runAtMillis;
+ 59     });
+ 60     for (var i = 0; i < funcsToRun.length; ++i) {
+ 61       try {
+ 62         var funcToRun = funcsToRun[i];
+ 63         this.nowMillis = funcToRun.runAtMillis;
+ 64         funcToRun.funcToCall();
+ 65         if (funcToRun.recurring) {
+ 66           this.scheduleFunction(funcToRun.timeoutKey,
+ 67             funcToRun.funcToCall,
+ 68             funcToRun.millis,
+ 69             true);
+ 70         }
+ 71       } catch(e) {
+ 72       }
+ 73     }
+ 74     this.runFunctionsWithinRange(oldMillis, nowMillis);
+ 75   }
+ 76 };
+ 77 
+ 78 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) {
+ 79   this.scheduledFunctions[timeoutKey] = {
+ 80     runAtMillis: this.nowMillis + millis,
+ 81     funcToCall: funcToCall,
+ 82     recurring: recurring,
+ 83     timeoutKey: timeoutKey,
+ 84     millis: millis
+ 85   };
+ 86 };
+ 87 
+ 88 /**
+ 89  * @namespace
+ 90  */
+ 91 jasmine.Clock = {
+ 92   defaultFakeTimer: new jasmine.FakeTimer(),
+ 93 
+ 94   reset: function() {
+ 95     jasmine.Clock.assertInstalled();
+ 96     jasmine.Clock.defaultFakeTimer.reset();
+ 97   },
+ 98 
+ 99   tick: function(millis) {
+100     jasmine.Clock.assertInstalled();
+101     jasmine.Clock.defaultFakeTimer.tick(millis);
+102   },
+103 
+104   runFunctionsWithinRange: function(oldMillis, nowMillis) {
+105     jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis);
+106   },
+107 
+108   scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
+109     jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring);
+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 diff --git a/lib/jasmine-0.10.4.js b/lib/jasmine-0.11.0.js similarity index 99% rename from lib/jasmine-0.10.4.js rename to lib/jasmine-0.11.0.js index ef4c88e..65c5a10 100644 --- a/lib/jasmine-0.10.4.js +++ b/lib/jasmine-0.11.0.js @@ -2294,7 +2294,7 @@ jasmine.getGlobal().clearInterval = function(timeoutKey) { jasmine.version_= { "major": 0, - "minor": 10, - "build": 4, - "revision": 1277253444 + "minor": 11, + "build": 0, + "revision": 1277253997 }; diff --git a/src/version.json b/src/version.json index eb721ef..bd55012 100644 --- a/src/version.json +++ b/src/version.json @@ -1,5 +1,5 @@ { "major": 0, - "minor": 10, - "build": 4 + "minor": 11, + "build": 0 }