From 65cec7a2b9a0c081fd0af12354f2f5dfc29bb683 Mon Sep 17 00:00:00 2001 From: ragaskar Date: Fri, 4 Sep 2009 19:46:39 -0700 Subject: [PATCH] Updated require for SimpleClient for greater selenium compatibility --- contrib/ruby/jasmine_runner.rb | 2 +- doc/files.html | 2 +- doc/index.html | 2 +- doc/symbols/_global_.html | 2 +- doc/symbols/jasmine.Block.html | 2 +- doc/symbols/jasmine.Env.html | 2 +- doc/symbols/jasmine.JsApiReporter.html | 2 +- doc/symbols/jasmine.MultiReporter.html | 2 +- doc/symbols/jasmine.NestedResults.html | 2 +- doc/symbols/jasmine.Reporter.html | 2 +- doc/symbols/jasmine.Runner.html | 2 +- doc/symbols/jasmine.Spec.html | 2 +- doc/symbols/jasmine.Spy.html | 2 +- doc/symbols/jasmine.Suite.html | 2 +- doc/symbols/jasmine.html | 2 +- doc/symbols/jasmine.util.html | 2 +- doc/symbols/src/lib_jasmine-0.9.0.js.html | 2808 +++++++++++---------- lib/jasmine-0.9.0.js | 2 +- 18 files changed, 1426 insertions(+), 1416 deletions(-) diff --git a/contrib/ruby/jasmine_runner.rb b/contrib/ruby/jasmine_runner.rb index 5dac7acf..ee9756e2 100644 --- a/contrib/ruby/jasmine_runner.rb +++ b/contrib/ruby/jasmine_runner.rb @@ -96,7 +96,7 @@ module Jasmine class SimpleClient def initialize(selenium_host, selenium_port, selenium_browser_start_command, http_address) - require 'selenium' + require 'selenium/client' @driver = Selenium::Client::Driver.new( selenium_host, selenium_port, diff --git a/doc/files.html b/doc/files.html index a6c8551e..cf9fbc2e 100644 --- a/doc/files.html +++ b/doc/files.html @@ -258,7 +258,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/index.html b/doc/index.html index ce8e9dbc..47552455 100644 --- a/doc/index.html +++ b/doc/index.html @@ -300,7 +300,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
\ No newline at end of file diff --git a/doc/symbols/_global_.html b/doc/symbols/_global_.html index 58454038..b65f072d 100644 --- a/doc/symbols/_global_.html +++ b/doc/symbols/_global_.html @@ -908,7 +908,7 @@ A convenience method that allows existing specs to be disabled temporarily durin
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Block.html b/doc/symbols/jasmine.Block.html index 6835fbd6..fa33e31a 100644 --- a/doc/symbols/jasmine.Block.html +++ b/doc/symbols/jasmine.Block.html @@ -339,7 +339,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Env.html b/doc/symbols/jasmine.Env.html index 2a8f660a..9bc64639 100644 --- a/doc/symbols/jasmine.Env.html +++ b/doc/symbols/jasmine.Env.html @@ -384,7 +384,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.JsApiReporter.html b/doc/symbols/jasmine.JsApiReporter.html index 8e70791c..a9b815b5 100644 --- a/doc/symbols/jasmine.JsApiReporter.html +++ b/doc/symbols/jasmine.JsApiReporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.MultiReporter.html b/doc/symbols/jasmine.MultiReporter.html index c60536d3..374c612b 100644 --- a/doc/symbols/jasmine.MultiReporter.html +++ b/doc/symbols/jasmine.MultiReporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.NestedResults.html b/doc/symbols/jasmine.NestedResults.html index 5e59f6f6..8324b74c 100644 --- a/doc/symbols/jasmine.NestedResults.html +++ b/doc/symbols/jasmine.NestedResults.html @@ -700,7 +700,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Reporter.html b/doc/symbols/jasmine.Reporter.html index d2e7b635..2b92aa09 100644 --- a/doc/symbols/jasmine.Reporter.html +++ b/doc/symbols/jasmine.Reporter.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Runner.html b/doc/symbols/jasmine.Runner.html index fd14f4ce..1bf3b299 100644 --- a/doc/symbols/jasmine.Runner.html +++ b/doc/symbols/jasmine.Runner.html @@ -384,7 +384,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spec.html b/doc/symbols/jasmine.Spec.html index d46090df..f4f9779c 100644 --- a/doc/symbols/jasmine.Spec.html +++ b/doc/symbols/jasmine.Spec.html @@ -339,7 +339,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Spy.html b/doc/symbols/jasmine.Spy.html index 3885e031..f90344df 100644 --- a/doc/symbols/jasmine.Spy.html +++ b/doc/symbols/jasmine.Spy.html @@ -845,7 +845,7 @@ expect(foo.bar.callCount).toEqual(0);
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.Suite.html b/doc/symbols/jasmine.Suite.html index 69cf1703..942ebe97 100644 --- a/doc/symbols/jasmine.Suite.html +++ b/doc/symbols/jasmine.Suite.html @@ -402,7 +402,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.html b/doc/symbols/jasmine.html index 4fd0f11c..5b25be63 100644 --- a/doc/symbols/jasmine.html +++ b/doc/symbols/jasmine.html @@ -678,7 +678,7 @@ Jasmine environment.
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/jasmine.util.html b/doc/symbols/jasmine.util.html index 3d3e25d7..84dd4511 100644 --- a/doc/symbols/jasmine.util.html +++ b/doc/symbols/jasmine.util.html @@ -316,7 +316,7 @@ ul.inheritsList
- Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 10:56:11 GMT-0700 (PDT) + Documentation generated by JsDoc Toolkit 2.1.0 on Fri Sep 04 2009 19:44:54 GMT-0700 (PDT)
diff --git a/doc/symbols/src/lib_jasmine-0.9.0.js.html b/doc/symbols/src/lib_jasmine-0.9.0.js.html index 2060fa6a..4cd1d25b 100644 --- a/doc/symbols/src/lib_jasmine-0.9.0.js.html +++ b/doc/symbols/src/lib_jasmine-0.9.0.js.html @@ -524,7 +524,7 @@ 517 "major": 0, 518 "minor": 9, 519 "build": 0, -520 "revision": 1251902474 +520 "revision": 1252086971 521 }; 522 /** 523 * @namespace @@ -599,1434 +599,1444 @@ 592 this.reporter = new jasmine.MultiReporter(); 593 594 this.updateInterval = 0; -595 this.lastUpdate = 0; -596 this.specFilter = function() { -597 return true; -598 }; -599 -600 this.nextSpecId_ = 0; -601 this.nextSuiteId_ = 0; -602 this.equalityTesters_ = []; -603 }; -604 -605 -606 jasmine.Env.prototype.setTimeout = jasmine.setTimeout; -607 jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; -608 jasmine.Env.prototype.setInterval = jasmine.setInterval; -609 jasmine.Env.prototype.clearInterval = jasmine.clearInterval; -610 -611 jasmine.Env.prototype.version = function () { -612 if (jasmine.version_) { -613 return jasmine.version_; -614 } else { -615 throw new Error('Version not set'); -616 } -617 }; -618 -619 /** -620 * Register a reporter to receive status updates from Jasmine. -621 * @param {jasmine.Reporter} reporter An object which will receive status updates. -622 */ -623 jasmine.Env.prototype.addReporter = function(reporter) { -624 this.reporter.addReporter(reporter); -625 }; -626 -627 jasmine.Env.prototype.execute = function() { -628 this.currentRunner.execute(); -629 }; -630 -631 jasmine.Env.prototype.describe = function(description, specDefinitions) { -632 var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); -633 -634 var parentSuite = this.currentSuite; -635 if (parentSuite) { -636 parentSuite.add(suite); -637 } else { -638 this.currentRunner.add(suite); -639 } -640 -641 this.currentSuite = suite; +595 +596 this.updateInterval = 0; +597 this.lastUpdate = 0; +598 this.specFilter = function() { +599 return true; +600 }; +601 +602 this.nextSpecId_ = 0; +603 this.nextSuiteId_ = 0; +604 this.equalityTesters_ = []; +605 }; +606 +607 +608 jasmine.Env.prototype.setTimeout = jasmine.setTimeout; +609 jasmine.Env.prototype.clearTimeout = jasmine.clearTimeout; +610 jasmine.Env.prototype.setInterval = jasmine.setInterval; +611 jasmine.Env.prototype.clearInterval = jasmine.clearInterval; +612 +613 jasmine.Env.prototype.version = function () { +614 if (jasmine.version_) { +615 return jasmine.version_; +616 } else { +617 throw new Error('Version not set'); +618 } +619 }; +620 +621 /** +622 * Register a reporter to receive status updates from Jasmine. +623 * @param {jasmine.Reporter} reporter An object which will receive status updates. +624 */ +625 jasmine.Env.prototype.addReporter = function(reporter) { +626 this.reporter.addReporter(reporter); +627 }; +628 +629 jasmine.Env.prototype.execute = function() { +630 this.currentRunner.execute(); +631 }; +632 +633 jasmine.Env.prototype.describe = function(description, specDefinitions) { +634 var suite = new jasmine.Suite(this, description, specDefinitions, this.currentSuite); +635 +636 var parentSuite = this.currentSuite; +637 if (parentSuite) { +638 parentSuite.add(suite); +639 } else { +640 this.currentRunner.add(suite); +641 } 642 -643 specDefinitions.call(suite); +643 this.currentSuite = suite; 644 -645 this.currentSuite = parentSuite; +645 specDefinitions.call(suite); 646 -647 return suite; -648 }; -649 -650 jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { -651 this.currentSuite.beforeEach(beforeEachFunction); -652 }; -653 -654 jasmine.Env.prototype.afterEach = function(afterEachFunction) { -655 this.currentSuite.afterEach(afterEachFunction); -656 }; -657 -658 jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { -659 return { -660 execute: function() { -661 } -662 }; -663 }; -664 -665 jasmine.Env.prototype.it = function(description, func) { -666 var spec = new jasmine.Spec(this, this.currentSuite, description); -667 this.currentSuite.add(spec); -668 this.currentSpec = spec; -669 -670 if (func) { -671 spec.runs(func); -672 } -673 -674 return spec; -675 }; -676 -677 jasmine.Env.prototype.xit = function(desc, func) { -678 return { -679 id: this.nextSpecId_++, -680 runs: function() { -681 } -682 }; -683 }; -684 -685 jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { -686 if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { -687 return true; -688 } -689 -690 a.__Jasmine_been_here_before__ = b; -691 b.__Jasmine_been_here_before__ = a; -692 -693 var hasKey = function(obj, keyName) { -694 return obj != null && obj[keyName] !== undefined; -695 }; -696 -697 for (var property in b) { -698 if (!hasKey(a, property) && hasKey(b, property)) { -699 mismatchKeys.push("expected has key '" + property + "', but missing from <b>actual</b>."); -700 } -701 } -702 for (property in a) { -703 if (!hasKey(b, property) && hasKey(a, property)) { -704 mismatchKeys.push("<b>expected</b> missing key '" + property + "', but present in actual."); -705 } -706 } -707 for (property in b) { -708 if (property == '__Jasmine_been_here_before__') continue; -709 if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { -710 mismatchValues.push("'" + property + "' was<br /><br />'" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "'<br /><br />in expected, but was<br /><br />'" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "'<br /><br />in actual.<br />"); -711 } -712 } -713 -714 if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { -715 mismatchValues.push("arrays were not the same length"); -716 } -717 -718 delete a.__Jasmine_been_here_before__; -719 delete b.__Jasmine_been_here_before__; -720 return (mismatchKeys.length == 0 && mismatchValues.length == 0); -721 }; -722 -723 jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { -724 mismatchKeys = mismatchKeys || []; -725 mismatchValues = mismatchValues || []; -726 -727 if (a === b) return true; +647 this.currentSuite = parentSuite; +648 +649 return suite; +650 }; +651 +652 jasmine.Env.prototype.beforeEach = function(beforeEachFunction) { +653 this.currentSuite.beforeEach(beforeEachFunction); +654 }; +655 +656 jasmine.Env.prototype.afterEach = function(afterEachFunction) { +657 this.currentSuite.afterEach(afterEachFunction); +658 }; +659 +660 jasmine.Env.prototype.xdescribe = function(desc, specDefinitions) { +661 return { +662 execute: function() { +663 } +664 }; +665 }; +666 +667 jasmine.Env.prototype.it = function(description, func) { +668 var spec = new jasmine.Spec(this, this.currentSuite, description); +669 this.currentSuite.add(spec); +670 this.currentSpec = spec; +671 +672 if (func) { +673 spec.runs(func); +674 } +675 +676 return spec; +677 }; +678 +679 jasmine.Env.prototype.xit = function(desc, func) { +680 return { +681 id: this.nextSpecId_++, +682 runs: function() { +683 } +684 }; +685 }; +686 +687 jasmine.Env.prototype.compareObjects_ = function(a, b, mismatchKeys, mismatchValues) { +688 if (a.__Jasmine_been_here_before__ === b && b.__Jasmine_been_here_before__ === a) { +689 return true; +690 } +691 +692 a.__Jasmine_been_here_before__ = b; +693 b.__Jasmine_been_here_before__ = a; +694 +695 var hasKey = function(obj, keyName) { +696 return obj != null && obj[keyName] !== undefined; +697 }; +698 +699 for (var property in b) { +700 if (!hasKey(a, property) && hasKey(b, property)) { +701 mismatchKeys.push("expected has key '" + property + "', but missing from <b>actual</b>."); +702 } +703 } +704 for (property in a) { +705 if (!hasKey(b, property) && hasKey(a, property)) { +706 mismatchKeys.push("<b>expected</b> missing key '" + property + "', but present in actual."); +707 } +708 } +709 for (property in b) { +710 if (property == '__Jasmine_been_here_before__') continue; +711 if (!this.equals_(a[property], b[property], mismatchKeys, mismatchValues)) { +712 mismatchValues.push("'" + property + "' was<br /><br />'" + (b[property] ? jasmine.util.htmlEscape(b[property].toString()) : b[property]) + "'<br /><br />in expected, but was<br /><br />'" + (a[property] ? jasmine.util.htmlEscape(a[property].toString()) : a[property]) + "'<br /><br />in actual.<br />"); +713 } +714 } +715 +716 if (jasmine.isArray_(a) && jasmine.isArray_(b) && a.length != b.length) { +717 mismatchValues.push("arrays were not the same length"); +718 } +719 +720 delete a.__Jasmine_been_here_before__; +721 delete b.__Jasmine_been_here_before__; +722 return (mismatchKeys.length == 0 && mismatchValues.length == 0); +723 }; +724 +725 jasmine.Env.prototype.equals_ = function(a, b, mismatchKeys, mismatchValues) { +726 mismatchKeys = mismatchKeys || []; +727 mismatchValues = mismatchValues || []; 728 -729 if (a === undefined || a === null || b === undefined || b === null) { -730 return (a == undefined && b == undefined); -731 } -732 -733 if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { -734 return a === b; -735 } -736 -737 if (a instanceof Date && b instanceof Date) { -738 return a.getTime() == b.getTime(); -739 } -740 -741 if (a instanceof jasmine.Matchers.Any) { -742 return a.matches(b); -743 } -744 -745 if (b instanceof jasmine.Matchers.Any) { -746 return b.matches(a); -747 } -748 -749 if (typeof a === "object" && typeof b === "object") { -750 return this.compareObjects_(a, b, mismatchKeys, mismatchValues); -751 } -752 -753 for (var i = 0; i < this.equalityTesters_.length; i++) { -754 var equalityTester = this.equalityTesters_[i]; -755 var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); -756 if (result !== undefined) return result; -757 } -758 -759 //Straight check -760 return (a === b); -761 }; -762 -763 jasmine.Env.prototype.contains_ = function(haystack, needle) { -764 if (jasmine.isArray_(haystack)) { -765 for (var i = 0; i < haystack.length; i++) { -766 if (this.equals_(haystack[i], needle)) return true; -767 } -768 return false; -769 } -770 return haystack.indexOf(needle) >= 0; -771 }; -772 -773 jasmine.Env.prototype.addEqualityTester = function(equalityTester) { -774 this.equalityTesters_.push(equalityTester); -775 }; -776 /** No-op base class for Jasmine reporters. -777 * -778 * @constructor -779 */ -780 jasmine.Reporter = function() { -781 }; -782 -783 //noinspection JSUnusedLocalSymbols -784 jasmine.Reporter.prototype.reportRunnerStarting = function(runner) { -785 }; -786 -787 //noinspection JSUnusedLocalSymbols -788 jasmine.Reporter.prototype.reportRunnerResults = function(runner) { -789 }; -790 -791 //noinspection JSUnusedLocalSymbols -792 jasmine.Reporter.prototype.reportSuiteResults = function(suite) { -793 }; -794 -795 //noinspection JSUnusedLocalSymbols -796 jasmine.Reporter.prototype.reportSpecResults = function(spec) { -797 }; -798 -799 //noinspection JSUnusedLocalSymbols -800 jasmine.Reporter.prototype.log = function(str) { -801 }; -802 -803 /** -804 * Blocks are functions with executable code that make up a spec. -805 * -806 * @constructor -807 * @param {jasmine.Env} env -808 * @param {Function} func -809 * @param {jasmine.Spec} spec -810 */ -811 jasmine.Block = function(env, func, spec) { -812 this.env = env; -813 this.func = func; -814 this.spec = spec; -815 }; -816 -817 jasmine.Block.prototype.execute = function(onComplete) { -818 try { -819 this.func.apply(this.spec); -820 } catch (e) { -821 this.fail(e); -822 } -823 onComplete(); -824 }; -825 -826 jasmine.Block.prototype.fail = function(e) { -827 this.spec.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null)); -828 }; -829 /** JavaScript API reporter. -830 * -831 * @constructor -832 */ -833 jasmine.JsApiReporter = function() { -834 this.started = false; -835 this.finished = false; -836 this.suites = []; -837 this.results = {}; -838 }; -839 -840 jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { -841 this.started = true; -842 var suites = runner.suites(); -843 for (var i = 0; i < suites.length; i++) { -844 var suite = suites[i]; -845 this.suites.push(this.summarize_(suite)); -846 } -847 }; -848 -849 jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { -850 var isSuite = suiteOrSpec instanceof jasmine.Suite -851 var summary = { -852 id: suiteOrSpec.id, -853 name: suiteOrSpec.description, -854 type: isSuite ? 'suite' : 'spec', -855 children: [] -856 }; -857 if (isSuite) { -858 var specs = suiteOrSpec.specs(); -859 for (var i = 0; i < specs.length; i++) { -860 summary.children.push(this.summarize_(specs[i])); -861 } -862 } -863 return summary; -864 }; -865 -866 //noinspection JSUnusedLocalSymbols -867 jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { -868 this.finished = true; -869 }; -870 -871 //noinspection JSUnusedLocalSymbols -872 jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { -873 }; -874 -875 //noinspection JSUnusedLocalSymbols -876 jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { -877 this.results[spec.id] = { -878 messages: spec.results.getItems(), -879 result: spec.results.failedCount > 0 ? "failed" : "passed" -880 }; -881 }; -882 -883 //noinspection JSUnusedLocalSymbols -884 jasmine.JsApiReporter.prototype.log = function(str) { -885 }; -886 -887 jasmine.Matchers = function(env, actual, results) { -888 this.env = env; -889 this.actual = actual; -890 this.passing_message = 'Passed.'; -891 this.results = results || new jasmine.NestedResults(); -892 }; -893 -894 jasmine.Matchers.pp = function(str) { -895 return jasmine.util.htmlEscape(jasmine.pp(str)); -896 }; -897 -898 jasmine.Matchers.prototype.getResults = function() { -899 return this.results; -900 }; -901 -902 jasmine.Matchers.prototype.report = function(result, failing_message, details) { -903 this.results.addResult(new jasmine.ExpectationResult(result, result ? this.passing_message : failing_message, details)); -904 return result; -905 }; -906 -907 /** -908 * Matcher that compares the actual to the expected using ===. -909 * -910 * @param expected -911 */ -912 jasmine.Matchers.prototype.toBe = function(expected) { -913 return this.report(this.actual === expected, 'Expected<br /><br />' + jasmine.Matchers.pp(expected) -914 + '<br /><br />to be the same object as<br /><br />' + jasmine.Matchers.pp(this.actual) -915 + '<br />'); -916 }; -917 -918 /** -919 * Matcher that compares the actual to the expected using !== -920 * @param expected -921 */ -922 jasmine.Matchers.prototype.toNotBe = function(expected) { -923 return this.report(this.actual !== expected, 'Expected<br /><br />' + jasmine.Matchers.pp(expected) -924 + '<br /><br />to be a different object from actual, but they were the same.'); -925 }; -926 -927 /** -928 * Matcher that compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. -929 * -930 * @param expected -931 */ -932 jasmine.Matchers.prototype.toEqual = function(expected) { -933 var mismatchKeys = []; -934 var mismatchValues = []; -935 -936 var formatMismatches = function(name, array) { -937 if (array.length == 0) return ''; -938 var errorOutput = '<br /><br />Different ' + name + ':<br />'; -939 for (var i = 0; i < array.length; i++) { -940 errorOutput += array[i] + '<br />'; -941 } -942 return errorOutput; -943 }; -944 -945 return this.report(this.env.equals_(this.actual, expected, mismatchKeys, mismatchValues), -946 'Expected<br /><br />' + jasmine.Matchers.pp(expected) -947 + '<br /><br />but got<br /><br />' + jasmine.Matchers.pp(this.actual) -948 + '<br />' -949 + formatMismatches('Keys', mismatchKeys) -950 + formatMismatches('Values', mismatchValues), { -951 matcherName: 'toEqual', expected: expected, actual: this.actual -952 }); -953 }; -954 /** @deprecated */ -955 jasmine.Matchers.prototype.should_equal = jasmine.Matchers.prototype.toEqual; -956 -957 /** -958 * Matcher that compares the actual to the expected using the ! of jasmine.Matchers.toEqual -959 * @param expected -960 */ -961 jasmine.Matchers.prototype.toNotEqual = function(expected) { -962 return this.report(!this.env.equals_(this.actual, expected), -963 'Expected ' + jasmine.Matchers.pp(expected) + ' to not equal ' + jasmine.Matchers.pp(this.actual) + ', but it does.'); -964 }; -965 /** @deprecated */ -966 jasmine.Matchers.prototype.should_not_equal = jasmine.Matchers.prototype.toNotEqual; -967 -968 /** -969 * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes -970 * a pattern or a String. -971 * -972 * @param reg_exp -973 */ -974 jasmine.Matchers.prototype.toMatch = function(reg_exp) { -975 return this.report((new RegExp(reg_exp).test(this.actual)), -976 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to match ' + reg_exp + '.'); -977 }; -978 /** @deprecated */ -979 jasmine.Matchers.prototype.should_match = jasmine.Matchers.prototype.toMatch; -980 -981 /** -982 * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch -983 * @param reg_exp -984 */ -985 jasmine.Matchers.prototype.toNotMatch = function(reg_exp) { -986 return this.report((!new RegExp(reg_exp).test(this.actual)), -987 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to not match ' + reg_exp + '.'); -988 }; -989 /** @deprecated */ -990 jasmine.Matchers.prototype.should_not_match = jasmine.Matchers.prototype.toNotMatch; -991 -992 /** -993 * Matcher that compares the acutal to undefined. -994 */ -995 jasmine.Matchers.prototype.toBeDefined = function() { -996 return this.report((this.actual !== undefined), -997 'Expected a value to be defined but it was undefined.'); -998 }; -999 /** @deprecated */ -1000 jasmine.Matchers.prototype.should_be_defined = jasmine.Matchers.prototype.toBeDefined; -1001 -1002 /** -1003 * Matcher that compares the actual to null. -1004 * -1005 */ -1006 jasmine.Matchers.prototype.toBeNull = function() { -1007 return this.report((this.actual === null), -1008 'Expected a value to be null but it was ' + jasmine.Matchers.pp(this.actual) + '.'); -1009 }; -1010 /** @deprecated */ -1011 jasmine.Matchers.prototype.should_be_null = jasmine.Matchers.prototype.toBeNull; -1012 -1013 /** -1014 * Matcher that boolean not-nots the actual. -1015 */ -1016 jasmine.Matchers.prototype.toBeTruthy = function() { -1017 return this.report(!!this.actual, -1018 'Expected a value to be truthy but it was ' + jasmine.Matchers.pp(this.actual) + '.'); -1019 }; -1020 /** @deprecated */ -1021 jasmine.Matchers.prototype.should_be_truthy = jasmine.Matchers.prototype.toBeTruthy; -1022 -1023 /** -1024 * Matcher that boolean nots the actual. -1025 */ -1026 jasmine.Matchers.prototype.toBeFalsy = function() { -1027 return this.report(!this.actual, -1028 'Expected a value to be falsy but it was ' + jasmine.Matchers.pp(this.actual) + '.'); -1029 }; -1030 /** @deprecated */ -1031 jasmine.Matchers.prototype.should_be_falsy = jasmine.Matchers.prototype.toBeFalsy; -1032 -1033 /** -1034 * Matcher that checks to see if the acutal, a Jasmine spy, was called. -1035 */ -1036 jasmine.Matchers.prototype.wasCalled = function() { -1037 if (!this.actual || !this.actual.isSpy) { -1038 return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); -1039 } -1040 if (arguments.length > 0) { -1041 return this.report(false, 'wasCalled matcher does not take arguments'); -1042 } -1043 return this.report((this.actual.wasCalled), -1044 'Expected spy "' + this.actual.identity + '" to have been called, but it was not.'); -1045 }; -1046 /** @deprecated */ -1047 jasmine.Matchers.prototype.was_called = jasmine.Matchers.prototype.wasCalled; -1048 -1049 /** -1050 * Matcher that checks to see if the acutal, a Jasmine spy, was not called. -1051 */ -1052 jasmine.Matchers.prototype.wasNotCalled = function() { -1053 if (!this.actual || !this.actual.isSpy) { -1054 return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); -1055 } -1056 return this.report((!this.actual.wasCalled), -1057 'Expected spy "' + this.actual.identity + '" to not have been called, but it was.'); -1058 }; -1059 /** @deprecated */ -1060 jasmine.Matchers.prototype.was_not_called = jasmine.Matchers.prototype.wasNotCalled; -1061 -1062 /** -1063 * Matcher that checks to see if the acutal, a Jasmine spy, was called with a set of parameters. -1064 * -1065 * @example +729 if (a === b) return true; +730 +731 if (a === undefined || a === null || b === undefined || b === null) { +732 return (a == undefined && b == undefined); +733 } +734 +735 if (jasmine.isDomNode(a) && jasmine.isDomNode(b)) { +736 return a === b; +737 } +738 +739 if (a instanceof Date && b instanceof Date) { +740 return a.getTime() == b.getTime(); +741 } +742 +743 if (a instanceof jasmine.Matchers.Any) { +744 return a.matches(b); +745 } +746 +747 if (b instanceof jasmine.Matchers.Any) { +748 return b.matches(a); +749 } +750 +751 if (typeof a === "object" && typeof b === "object") { +752 return this.compareObjects_(a, b, mismatchKeys, mismatchValues); +753 } +754 +755 for (var i = 0; i < this.equalityTesters_.length; i++) { +756 var equalityTester = this.equalityTesters_[i]; +757 var result = equalityTester(a, b, this, mismatchKeys, mismatchValues); +758 if (result !== undefined) return result; +759 } +760 +761 //Straight check +762 return (a === b); +763 }; +764 +765 jasmine.Env.prototype.contains_ = function(haystack, needle) { +766 if (jasmine.isArray_(haystack)) { +767 for (var i = 0; i < haystack.length; i++) { +768 if (this.equals_(haystack[i], needle)) return true; +769 } +770 return false; +771 } +772 return haystack.indexOf(needle) >= 0; +773 }; +774 +775 jasmine.Env.prototype.addEqualityTester = function(equalityTester) { +776 this.equalityTesters_.push(equalityTester); +777 }; +778 /** No-op base class for Jasmine reporters. +779 * +780 * @constructor +781 */ +782 jasmine.Reporter = function() { +783 }; +784 +785 //noinspection JSUnusedLocalSymbols +786 jasmine.Reporter.prototype.reportRunnerStarting = function(runner) { +787 }; +788 +789 //noinspection JSUnusedLocalSymbols +790 jasmine.Reporter.prototype.reportRunnerResults = function(runner) { +791 }; +792 +793 //noinspection JSUnusedLocalSymbols +794 jasmine.Reporter.prototype.reportSuiteResults = function(suite) { +795 }; +796 +797 //noinspection JSUnusedLocalSymbols +798 jasmine.Reporter.prototype.reportSpecResults = function(spec) { +799 }; +800 +801 //noinspection JSUnusedLocalSymbols +802 jasmine.Reporter.prototype.log = function(str) { +803 }; +804 +805 /** +806 * Blocks are functions with executable code that make up a spec. +807 * +808 * @constructor +809 * @param {jasmine.Env} env +810 * @param {Function} func +811 * @param {jasmine.Spec} spec +812 */ +813 jasmine.Block = function(env, func, spec) { +814 this.env = env; +815 this.func = func; +816 this.spec = spec; +817 }; +818 +819 jasmine.Block.prototype.execute = function(onComplete) { +820 try { +821 this.func.apply(this.spec); +822 } catch (e) { +823 this.fail(e); +824 } +825 onComplete(); +826 }; +827 +828 jasmine.Block.prototype.fail = function(e) { +829 this.spec.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null)); +830 }; +831 /** JavaScript API reporter. +832 * +833 * @constructor +834 */ +835 jasmine.JsApiReporter = function() { +836 this.started = false; +837 this.finished = false; +838 this.suites = []; +839 this.results = {}; +840 }; +841 +842 jasmine.JsApiReporter.prototype.reportRunnerStarting = function(runner) { +843 this.started = true; +844 var suites = runner.suites(); +845 for (var i = 0; i < suites.length; i++) { +846 var suite = suites[i]; +847 this.suites.push(this.summarize_(suite)); +848 } +849 }; +850 +851 jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) { +852 var isSuite = suiteOrSpec instanceof jasmine.Suite +853 var summary = { +854 id: suiteOrSpec.id, +855 name: suiteOrSpec.description, +856 type: isSuite ? 'suite' : 'spec', +857 children: [] +858 }; +859 if (isSuite) { +860 var specs = suiteOrSpec.specs(); +861 for (var i = 0; i < specs.length; i++) { +862 summary.children.push(this.summarize_(specs[i])); +863 } +864 } +865 return summary; +866 }; +867 +868 //noinspection JSUnusedLocalSymbols +869 jasmine.JsApiReporter.prototype.reportRunnerResults = function(runner) { +870 this.finished = true; +871 }; +872 +873 //noinspection JSUnusedLocalSymbols +874 jasmine.JsApiReporter.prototype.reportSuiteResults = function(suite) { +875 }; +876 +877 //noinspection JSUnusedLocalSymbols +878 jasmine.JsApiReporter.prototype.reportSpecResults = function(spec) { +879 this.results[spec.id] = { +880 messages: spec.results.getItems(), +881 result: spec.results.failedCount > 0 ? "failed" : "passed" +882 }; +883 }; +884 +885 //noinspection JSUnusedLocalSymbols +886 jasmine.JsApiReporter.prototype.log = function(str) { +887 }; +888 +889 jasmine.Matchers = function(env, actual, results) { +890 this.env = env; +891 this.actual = actual; +892 this.passing_message = 'Passed.'; +893 this.results = results || new jasmine.NestedResults(); +894 }; +895 +896 jasmine.Matchers.pp = function(str) { +897 return jasmine.util.htmlEscape(jasmine.pp(str)); +898 }; +899 +900 jasmine.Matchers.prototype.getResults = function() { +901 return this.results; +902 }; +903 +904 jasmine.Matchers.prototype.report = function(result, failing_message, details) { +905 this.results.addResult(new jasmine.ExpectationResult(result, result ? this.passing_message : failing_message, details)); +906 return result; +907 }; +908 +909 /** +910 * Matcher that compares the actual to the expected using ===. +911 * +912 * @param expected +913 */ +914 jasmine.Matchers.prototype.toBe = function(expected) { +915 return this.report(this.actual === expected, 'Expected<br /><br />' + jasmine.Matchers.pp(expected) +916 + '<br /><br />to be the same object as<br /><br />' + jasmine.Matchers.pp(this.actual) +917 + '<br />'); +918 }; +919 +920 /** +921 * Matcher that compares the actual to the expected using !== +922 * @param expected +923 */ +924 jasmine.Matchers.prototype.toNotBe = function(expected) { +925 return this.report(this.actual !== expected, 'Expected<br /><br />' + jasmine.Matchers.pp(expected) +926 + '<br /><br />to be a different object from actual, but they were the same.'); +927 }; +928 +929 /** +930 * Matcher that compares the actual to the expected using common sense equality. Handles Objects, Arrays, etc. +931 * +932 * @param expected +933 */ +934 jasmine.Matchers.prototype.toEqual = function(expected) { +935 var mismatchKeys = []; +936 var mismatchValues = []; +937 +938 var formatMismatches = function(name, array) { +939 if (array.length == 0) return ''; +940 var errorOutput = '<br /><br />Different ' + name + ':<br />'; +941 for (var i = 0; i < array.length; i++) { +942 errorOutput += array[i] + '<br />'; +943 } +944 return errorOutput; +945 }; +946 +947 return this.report(this.env.equals_(this.actual, expected, mismatchKeys, mismatchValues), +948 'Expected<br /><br />' + jasmine.Matchers.pp(expected) +949 + '<br /><br />but got<br /><br />' + jasmine.Matchers.pp(this.actual) +950 + '<br />' +951 + formatMismatches('Keys', mismatchKeys) +952 + formatMismatches('Values', mismatchValues), { +953 matcherName: 'toEqual', expected: expected, actual: this.actual +954 }); +955 }; +956 /** @deprecated */ +957 jasmine.Matchers.prototype.should_equal = jasmine.Matchers.prototype.toEqual; +958 +959 /** +960 * Matcher that compares the actual to the expected using the ! of jasmine.Matchers.toEqual +961 * @param expected +962 */ +963 jasmine.Matchers.prototype.toNotEqual = function(expected) { +964 return this.report(!this.env.equals_(this.actual, expected), +965 'Expected ' + jasmine.Matchers.pp(expected) + ' to not equal ' + jasmine.Matchers.pp(this.actual) + ', but it does.'); +966 }; +967 /** @deprecated */ +968 jasmine.Matchers.prototype.should_not_equal = jasmine.Matchers.prototype.toNotEqual; +969 +970 /** +971 * Matcher that compares the actual to the expected using a regular expression. Constructs a RegExp, so takes +972 * a pattern or a String. +973 * +974 * @param reg_exp +975 */ +976 jasmine.Matchers.prototype.toMatch = function(reg_exp) { +977 return this.report((new RegExp(reg_exp).test(this.actual)), +978 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to match ' + reg_exp + '.'); +979 }; +980 /** @deprecated */ +981 jasmine.Matchers.prototype.should_match = jasmine.Matchers.prototype.toMatch; +982 +983 /** +984 * Matcher that compares the actual to the expected using the boolean inverse of jasmine.Matchers.toMatch +985 * @param reg_exp +986 */ +987 jasmine.Matchers.prototype.toNotMatch = function(reg_exp) { +988 return this.report((!new RegExp(reg_exp).test(this.actual)), +989 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to not match ' + reg_exp + '.'); +990 }; +991 /** @deprecated */ +992 jasmine.Matchers.prototype.should_not_match = jasmine.Matchers.prototype.toNotMatch; +993 +994 /** +995 * Matcher that compares the acutal to undefined. +996 */ +997 jasmine.Matchers.prototype.toBeDefined = function() { +998 return this.report((this.actual !== undefined), +999 'Expected a value to be defined but it was undefined.'); +1000 }; +1001 /** @deprecated */ +1002 jasmine.Matchers.prototype.should_be_defined = jasmine.Matchers.prototype.toBeDefined; +1003 +1004 /** +1005 * Matcher that compares the actual to null. +1006 * +1007 */ +1008 jasmine.Matchers.prototype.toBeNull = function() { +1009 return this.report((this.actual === null), +1010 'Expected a value to be null but it was ' + jasmine.Matchers.pp(this.actual) + '.'); +1011 }; +1012 /** @deprecated */ +1013 jasmine.Matchers.prototype.should_be_null = jasmine.Matchers.prototype.toBeNull; +1014 +1015 /** +1016 * Matcher that boolean not-nots the actual. +1017 */ +1018 jasmine.Matchers.prototype.toBeTruthy = function() { +1019 return this.report(!!this.actual, +1020 'Expected a value to be truthy but it was ' + jasmine.Matchers.pp(this.actual) + '.'); +1021 }; +1022 /** @deprecated */ +1023 jasmine.Matchers.prototype.should_be_truthy = jasmine.Matchers.prototype.toBeTruthy; +1024 +1025 /** +1026 * Matcher that boolean nots the actual. +1027 */ +1028 jasmine.Matchers.prototype.toBeFalsy = function() { +1029 return this.report(!this.actual, +1030 'Expected a value to be falsy but it was ' + jasmine.Matchers.pp(this.actual) + '.'); +1031 }; +1032 /** @deprecated */ +1033 jasmine.Matchers.prototype.should_be_falsy = jasmine.Matchers.prototype.toBeFalsy; +1034 +1035 /** +1036 * Matcher that checks to see if the acutal, a Jasmine spy, was called. +1037 */ +1038 jasmine.Matchers.prototype.wasCalled = function() { +1039 if (!this.actual || !this.actual.isSpy) { +1040 return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +1041 } +1042 if (arguments.length > 0) { +1043 return this.report(false, 'wasCalled matcher does not take arguments'); +1044 } +1045 return this.report((this.actual.wasCalled), +1046 'Expected spy "' + this.actual.identity + '" to have been called, but it was not.'); +1047 }; +1048 /** @deprecated */ +1049 jasmine.Matchers.prototype.was_called = jasmine.Matchers.prototype.wasCalled; +1050 +1051 /** +1052 * Matcher that checks to see if the acutal, a Jasmine spy, was not called. +1053 */ +1054 jasmine.Matchers.prototype.wasNotCalled = function() { +1055 if (!this.actual || !this.actual.isSpy) { +1056 return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.'); +1057 } +1058 return this.report((!this.actual.wasCalled), +1059 'Expected spy "' + this.actual.identity + '" to not have been called, but it was.'); +1060 }; +1061 /** @deprecated */ +1062 jasmine.Matchers.prototype.was_not_called = jasmine.Matchers.prototype.wasNotCalled; +1063 +1064 /** +1065 * Matcher that checks to see if the acutal, a Jasmine spy, was called with a set of parameters. 1066 * -1067 */ -1068 jasmine.Matchers.prototype.wasCalledWith = function() { -1069 if (!this.actual || !this.actual.isSpy) { -1070 return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.', { -1071 matcherName: 'wasCalledWith' -1072 }); -1073 } -1074 -1075 var args = jasmine.util.argsToArray(arguments); +1067 * @example +1068 * +1069 */ +1070 jasmine.Matchers.prototype.wasCalledWith = function() { +1071 if (!this.actual || !this.actual.isSpy) { +1072 return this.report(false, 'Expected a spy, but got ' + jasmine.Matchers.pp(this.actual) + '.', { +1073 matcherName: 'wasCalledWith' +1074 }); +1075 } 1076 -1077 return this.report(this.env.contains_(this.actual.argsForCall, args), -1078 'Expected ' + jasmine.Matchers.pp(this.actual.argsForCall) + ' to contain ' + jasmine.Matchers.pp(args) + ', but it does not.', { -1079 matcherName: 'wasCalledWith', expected: args, actual: this.actual.argsForCall -1080 }); -1081 }; -1082 -1083 /** -1084 * Matcher that checks that the expected item is an element in the actual Array. -1085 * -1086 * @param {Object} item -1087 */ -1088 jasmine.Matchers.prototype.toContain = function(item) { -1089 return this.report(this.env.contains_(this.actual, item), -1090 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to contain ' + jasmine.Matchers.pp(item) + ', but it does not.', { -1091 matcherName: 'toContain', expected: item, actual: this.actual -1092 }); -1093 }; -1094 -1095 /** -1096 * Matcher that checks that the expected item is NOT an element in the actual Array. -1097 * -1098 * @param {Object} item -1099 */ -1100 jasmine.Matchers.prototype.toNotContain = function(item) { -1101 return this.report(!this.env.contains_(this.actual, item), -1102 'Expected ' + jasmine.Matchers.pp(this.actual) + ' not to contain ' + jasmine.Matchers.pp(item) + ', but it does.'); -1103 }; -1104 -1105 jasmine.Matchers.prototype.toBeLessThan = function(expected) { -1106 return this.report(this.actual < expected, -1107 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to be less than ' + jasmine.Matchers.pp(expected) + ', but it was not.'); -1108 }; -1109 -1110 jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { -1111 return this.report(this.actual > expected, -1112 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to be greater than ' + jasmine.Matchers.pp(expected) + ', but it was not.'); -1113 }; -1114 -1115 /** -1116 * Matcher that checks that the expected exception was thrown by the actual. -1117 * -1118 * @param {String} expectedException -1119 */ -1120 jasmine.Matchers.prototype.toThrow = function(expectedException) { -1121 var exception = null; -1122 try { -1123 this.actual(); -1124 } catch (e) { -1125 exception = e; -1126 } -1127 if (expectedException !== undefined) { -1128 if (exception == null) { -1129 return this.report(false, "Expected function to throw " + jasmine.Matchers.pp(expectedException) + ", but it did not."); -1130 } -1131 return this.report( -1132 this.env.equals_( -1133 exception.message || exception, -1134 expectedException.message || expectedException), -1135 "Expected function to throw " + jasmine.Matchers.pp(expectedException) + ", but it threw " + jasmine.Matchers.pp(exception) + "."); -1136 } else { -1137 return this.report(exception != null, "Expected function to throw an exception, but it did not."); -1138 } -1139 }; -1140 -1141 jasmine.Matchers.Any = function(expectedClass) { -1142 this.expectedClass = expectedClass; -1143 }; -1144 -1145 jasmine.Matchers.Any.prototype.matches = function(other) { -1146 if (this.expectedClass == String) { -1147 return typeof other == 'string' || other instanceof String; -1148 } -1149 -1150 if (this.expectedClass == Number) { -1151 return typeof other == 'number' || other instanceof Number; -1152 } -1153 -1154 if (this.expectedClass == Function) { -1155 return typeof other == 'function' || other instanceof Function; -1156 } -1157 -1158 if (this.expectedClass == Object) { -1159 return typeof other == 'object'; -1160 } -1161 -1162 return other instanceof this.expectedClass; -1163 }; -1164 -1165 jasmine.Matchers.Any.prototype.toString = function() { -1166 return '<jasmine.any(' + this.expectedClass + ')>'; -1167 }; -1168 -1169 /** -1170 * @constructor -1171 */ -1172 jasmine.MultiReporter = function() { -1173 this.subReporters_ = []; -1174 }; -1175 jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter); -1176 -1177 jasmine.MultiReporter.prototype.addReporter = function(reporter) { -1178 this.subReporters_.push(reporter); -1179 }; -1180 -1181 (function() { -1182 var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"]; -1183 for (var i = 0; i < functionNames.length; i++) { -1184 var functionName = functionNames[i]; -1185 jasmine.MultiReporter.prototype[functionName] = (function(functionName) { -1186 return function() { -1187 for (var j = 0; j < this.subReporters_.length; j++) { -1188 var subReporter = this.subReporters_[j]; -1189 if (subReporter[functionName]) { -1190 subReporter[functionName].apply(subReporter, arguments); -1191 } -1192 } -1193 }; -1194 })(functionName); -1195 } -1196 })(); -1197 /** -1198 * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults -1199 * -1200 * @constructor -1201 */ -1202 jasmine.NestedResults = function() { -1203 /** -1204 * The total count of results -1205 */ -1206 this.totalCount = 0; -1207 /** -1208 * Number of passed results -1209 */ -1210 this.passedCount = 0; -1211 /** -1212 * Number of failed results -1213 */ -1214 this.failedCount = 0; -1215 /** -1216 * Was this suite/spec skipped? -1217 */ -1218 this.skipped = false; -1219 /** -1220 * @ignore -1221 */ -1222 this.items_ = []; -1223 }; -1224 -1225 /** -1226 * Roll up the result counts. -1227 * -1228 * @param result -1229 */ -1230 jasmine.NestedResults.prototype.rollupCounts = function(result) { -1231 this.totalCount += result.totalCount; -1232 this.passedCount += result.passedCount; -1233 this.failedCount += result.failedCount; -1234 }; -1235 -1236 /** -1237 * Tracks a result's message. -1238 * @param message -1239 */ -1240 jasmine.NestedResults.prototype.log = function(message) { -1241 this.items_.push(new jasmine.MessageResult(message)); -1242 }; -1243 -1244 /** -1245 * Getter for the results: message & results. -1246 */ -1247 jasmine.NestedResults.prototype.getItems = function() { -1248 return this.items_; -1249 }; -1250 -1251 /** -1252 * Adds a result, tracking counts (total, passed, & failed) -1253 * @param {jasmine.ExpectationResult|jasmine.NestedResults} result -1254 */ -1255 jasmine.NestedResults.prototype.addResult = function(result) { -1256 if (result.type != 'MessageResult') { -1257 if (result.items_) { -1258 this.rollupCounts(result); -1259 } else { -1260 this.totalCount++; -1261 if (result.passed()) { -1262 this.passedCount++; -1263 } else { -1264 this.failedCount++; -1265 } -1266 } -1267 } -1268 this.items_.push(result); -1269 }; -1270 -1271 /** -1272 * @returns {Boolean} True if <b>everything</b> below passed -1273 */ -1274 jasmine.NestedResults.prototype.passed = function() { -1275 return this.passedCount === this.totalCount; -1276 }; -1277 /** -1278 * Base class for pretty printing for expectation results. -1279 */ -1280 jasmine.PrettyPrinter = function() { -1281 this.ppNestLevel_ = 0; -1282 }; -1283 -1284 /** -1285 * Formats a value in a nice, human-readable string. -1286 * -1287 * @param value -1288 * @returns {String} -1289 */ -1290 jasmine.PrettyPrinter.prototype.format = function(value) { -1291 if (this.ppNestLevel_ > 40) { -1292 // return '(jasmine.pp nested too deeply!)'; -1293 throw new Error('jasmine.PrettyPrinter: format() nested too deeply!'); -1294 } -1295 -1296 this.ppNestLevel_++; -1297 try { -1298 if (value === undefined) { -1299 this.emitScalar('undefined'); -1300 } else if (value === null) { -1301 this.emitScalar('null'); -1302 } else if (value.navigator && value.frames && value.setTimeout) { -1303 this.emitScalar('<window>'); -1304 } else if (value instanceof jasmine.Matchers.Any) { -1305 this.emitScalar(value.toString()); -1306 } else if (typeof value === 'string') { -1307 this.emitString(value); -1308 } else if (typeof value === 'function') { -1309 this.emitScalar('Function'); -1310 } else if (typeof value.nodeType === 'number') { -1311 this.emitScalar('HTMLNode'); -1312 } else if (value instanceof Date) { -1313 this.emitScalar('Date(' + value + ')'); -1314 } else if (value.__Jasmine_been_here_before__) { -1315 this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>'); -1316 } else if (jasmine.isArray_(value) || typeof value == 'object') { -1317 value.__Jasmine_been_here_before__ = true; -1318 if (jasmine.isArray_(value)) { -1319 this.emitArray(value); -1320 } else { -1321 this.emitObject(value); -1322 } -1323 delete value.__Jasmine_been_here_before__; -1324 } else { -1325 this.emitScalar(value.toString()); -1326 } -1327 } finally { -1328 this.ppNestLevel_--; -1329 } -1330 }; -1331 -1332 jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { -1333 for (var property in obj) { -1334 if (property == '__Jasmine_been_here_before__') continue; -1335 fn(property, obj.__lookupGetter__(property) != null); -1336 } -1337 }; -1338 -1339 jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; -1340 jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; -1341 jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; -1342 jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; -1343 -1344 jasmine.StringPrettyPrinter = function() { -1345 jasmine.PrettyPrinter.call(this); -1346 -1347 this.string = ''; -1348 }; -1349 jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); -1350 -1351 jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { -1352 this.append(value); -1353 }; -1354 -1355 jasmine.StringPrettyPrinter.prototype.emitString = function(value) { -1356 this.append("'" + value + "'"); -1357 }; -1358 -1359 jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { -1360 this.append('[ '); -1361 for (var i = 0; i < array.length; i++) { -1362 if (i > 0) { -1363 this.append(', '); -1364 } -1365 this.format(array[i]); -1366 } -1367 this.append(' ]'); -1368 }; -1369 -1370 jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { -1371 var self = this; -1372 this.append('{ '); -1373 var first = true; -1374 -1375 this.iterateObject(obj, function(property, isGetter) { -1376 if (first) { -1377 first = false; -1378 } else { -1379 self.append(', '); -1380 } -1381 -1382 self.append(property); -1383 self.append(' : '); -1384 if (isGetter) { -1385 self.append('<getter>'); -1386 } else { -1387 self.format(obj[property]); -1388 } -1389 }); -1390 -1391 this.append(' }'); -1392 }; -1393 -1394 jasmine.StringPrettyPrinter.prototype.append = function(value) { -1395 this.string += value; -1396 }; -1397 jasmine.Queue = function(env) { -1398 this.env = env; -1399 this.blocks = []; -1400 this.running = false; -1401 this.index = 0; -1402 this.offset = 0; -1403 }; -1404 -1405 jasmine.Queue.prototype.addBefore = function (block) { -1406 this.blocks.unshift(block); -1407 }; -1408 -1409 jasmine.Queue.prototype.add = function(block) { -1410 this.blocks.push(block); -1411 }; -1412 -1413 jasmine.Queue.prototype.insertNext = function (block) { -1414 this.blocks.splice((this.index + this.offset + 1), 0, block); -1415 this.offset++; -1416 }; -1417 -1418 jasmine.Queue.prototype.start = function(onComplete) { -1419 var self = this; -1420 self.running = true; -1421 self.onComplete = onComplete; -1422 if (self.blocks[0]) { -1423 self.blocks[0].execute(function () { -1424 self._next(); -1425 }); -1426 } else { -1427 self.finish(); -1428 } -1429 }; -1430 -1431 jasmine.Queue.prototype.isRunning = function () { -1432 return this.running; -1433 }; -1434 -1435 jasmine.Queue.prototype._next = function () { -1436 var self = this; -1437 self.env.setTimeout(function () { -1438 self.offset = 0; -1439 self.index++; -1440 if (self.index < self.blocks.length) { -1441 self.blocks[self.index].execute(function () { -1442 self._next(); -1443 }); -1444 } else { -1445 self.finish(); -1446 } -1447 }, 0); -1448 }; -1449 -1450 jasmine.Queue.prototype.finish = function () { -1451 this.running = false; -1452 if (this.onComplete) { -1453 this.onComplete(); -1454 } -1455 }; -1456 -1457 jasmine.Queue.prototype.getResults = function () { -1458 var results = new jasmine.NestedResults(); -1459 for (var i = 0; i < this.blocks.length; i++) { -1460 if (this.blocks[i].getResults) { -1461 results.addResult(this.blocks[i].getResults()); -1462 } -1463 } -1464 return results; +1077 var args = jasmine.util.argsToArray(arguments); +1078 +1079 return this.report(this.env.contains_(this.actual.argsForCall, args), +1080 'Expected ' + jasmine.Matchers.pp(this.actual.argsForCall) + ' to contain ' + jasmine.Matchers.pp(args) + ', but it does not.', { +1081 matcherName: 'wasCalledWith', expected: args, actual: this.actual.argsForCall +1082 }); +1083 }; +1084 +1085 /** +1086 * Matcher that checks that the expected item is an element in the actual Array. +1087 * +1088 * @param {Object} item +1089 */ +1090 jasmine.Matchers.prototype.toContain = function(item) { +1091 return this.report(this.env.contains_(this.actual, item), +1092 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to contain ' + jasmine.Matchers.pp(item) + ', but it does not.', { +1093 matcherName: 'toContain', expected: item, actual: this.actual +1094 }); +1095 }; +1096 +1097 /** +1098 * Matcher that checks that the expected item is NOT an element in the actual Array. +1099 * +1100 * @param {Object} item +1101 */ +1102 jasmine.Matchers.prototype.toNotContain = function(item) { +1103 return this.report(!this.env.contains_(this.actual, item), +1104 'Expected ' + jasmine.Matchers.pp(this.actual) + ' not to contain ' + jasmine.Matchers.pp(item) + ', but it does.'); +1105 }; +1106 +1107 jasmine.Matchers.prototype.toBeLessThan = function(expected) { +1108 return this.report(this.actual < expected, +1109 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to be less than ' + jasmine.Matchers.pp(expected) + ', but it was not.'); +1110 }; +1111 +1112 jasmine.Matchers.prototype.toBeGreaterThan = function(expected) { +1113 return this.report(this.actual > expected, +1114 'Expected ' + jasmine.Matchers.pp(this.actual) + ' to be greater than ' + jasmine.Matchers.pp(expected) + ', but it was not.'); +1115 }; +1116 +1117 /** +1118 * Matcher that checks that the expected exception was thrown by the actual. +1119 * +1120 * @param {String} expectedException +1121 */ +1122 jasmine.Matchers.prototype.toThrow = function(expectedException) { +1123 var exception = null; +1124 try { +1125 this.actual(); +1126 } catch (e) { +1127 exception = e; +1128 } +1129 if (expectedException !== undefined) { +1130 if (exception == null) { +1131 return this.report(false, "Expected function to throw " + jasmine.Matchers.pp(expectedException) + ", but it did not."); +1132 } +1133 return this.report( +1134 this.env.equals_( +1135 exception.message || exception, +1136 expectedException.message || expectedException), +1137 "Expected function to throw " + jasmine.Matchers.pp(expectedException) + ", but it threw " + jasmine.Matchers.pp(exception) + "."); +1138 } else { +1139 return this.report(exception != null, "Expected function to throw an exception, but it did not."); +1140 } +1141 }; +1142 +1143 jasmine.Matchers.Any = function(expectedClass) { +1144 this.expectedClass = expectedClass; +1145 }; +1146 +1147 jasmine.Matchers.Any.prototype.matches = function(other) { +1148 if (this.expectedClass == String) { +1149 return typeof other == 'string' || other instanceof String; +1150 } +1151 +1152 if (this.expectedClass == Number) { +1153 return typeof other == 'number' || other instanceof Number; +1154 } +1155 +1156 if (this.expectedClass == Function) { +1157 return typeof other == 'function' || other instanceof Function; +1158 } +1159 +1160 if (this.expectedClass == Object) { +1161 return typeof other == 'object'; +1162 } +1163 +1164 return other instanceof this.expectedClass; +1165 }; +1166 +1167 jasmine.Matchers.Any.prototype.toString = function() { +1168 return '<jasmine.any(' + this.expectedClass + ')>'; +1169 }; +1170 +1171 /** +1172 * @constructor +1173 */ +1174 jasmine.MultiReporter = function() { +1175 this.subReporters_ = []; +1176 }; +1177 jasmine.util.inherit(jasmine.MultiReporter, jasmine.Reporter); +1178 +1179 jasmine.MultiReporter.prototype.addReporter = function(reporter) { +1180 this.subReporters_.push(reporter); +1181 }; +1182 +1183 (function() { +1184 var functionNames = ["reportRunnerStarting", "reportRunnerResults", "reportSuiteResults", "reportSpecResults", "log"]; +1185 for (var i = 0; i < functionNames.length; i++) { +1186 var functionName = functionNames[i]; +1187 jasmine.MultiReporter.prototype[functionName] = (function(functionName) { +1188 return function() { +1189 for (var j = 0; j < this.subReporters_.length; j++) { +1190 var subReporter = this.subReporters_[j]; +1191 if (subReporter[functionName]) { +1192 subReporter[functionName].apply(subReporter, arguments); +1193 } +1194 } +1195 }; +1196 })(functionName); +1197 } +1198 })(); +1199 /** +1200 * Holds results for a set of Jasmine spec. Allows for the results array to hold another jasmine.NestedResults +1201 * +1202 * @constructor +1203 */ +1204 jasmine.NestedResults = function() { +1205 /** +1206 * The total count of results +1207 */ +1208 this.totalCount = 0; +1209 /** +1210 * Number of passed results +1211 */ +1212 this.passedCount = 0; +1213 /** +1214 * Number of failed results +1215 */ +1216 this.failedCount = 0; +1217 /** +1218 * Was this suite/spec skipped? +1219 */ +1220 this.skipped = false; +1221 /** +1222 * @ignore +1223 */ +1224 this.items_ = []; +1225 }; +1226 +1227 /** +1228 * Roll up the result counts. +1229 * +1230 * @param result +1231 */ +1232 jasmine.NestedResults.prototype.rollupCounts = function(result) { +1233 this.totalCount += result.totalCount; +1234 this.passedCount += result.passedCount; +1235 this.failedCount += result.failedCount; +1236 }; +1237 +1238 /** +1239 * Tracks a result's message. +1240 * @param message +1241 */ +1242 jasmine.NestedResults.prototype.log = function(message) { +1243 this.items_.push(new jasmine.MessageResult(message)); +1244 }; +1245 +1246 /** +1247 * Getter for the results: message & results. +1248 */ +1249 jasmine.NestedResults.prototype.getItems = function() { +1250 return this.items_; +1251 }; +1252 +1253 /** +1254 * Adds a result, tracking counts (total, passed, & failed) +1255 * @param {jasmine.ExpectationResult|jasmine.NestedResults} result +1256 */ +1257 jasmine.NestedResults.prototype.addResult = function(result) { +1258 if (result.type != 'MessageResult') { +1259 if (result.items_) { +1260 this.rollupCounts(result); +1261 } else { +1262 this.totalCount++; +1263 if (result.passed()) { +1264 this.passedCount++; +1265 } else { +1266 this.failedCount++; +1267 } +1268 } +1269 } +1270 this.items_.push(result); +1271 }; +1272 +1273 /** +1274 * @returns {Boolean} True if <b>everything</b> below passed +1275 */ +1276 jasmine.NestedResults.prototype.passed = function() { +1277 return this.passedCount === this.totalCount; +1278 }; +1279 /** +1280 * Base class for pretty printing for expectation results. +1281 */ +1282 jasmine.PrettyPrinter = function() { +1283 this.ppNestLevel_ = 0; +1284 }; +1285 +1286 /** +1287 * Formats a value in a nice, human-readable string. +1288 * +1289 * @param value +1290 * @returns {String} +1291 */ +1292 jasmine.PrettyPrinter.prototype.format = function(value) { +1293 if (this.ppNestLevel_ > 40) { +1294 // return '(jasmine.pp nested too deeply!)'; +1295 throw new Error('jasmine.PrettyPrinter: format() nested too deeply!'); +1296 } +1297 +1298 this.ppNestLevel_++; +1299 try { +1300 if (value === undefined) { +1301 this.emitScalar('undefined'); +1302 } else if (value === null) { +1303 this.emitScalar('null'); +1304 } else if (value.navigator && value.frames && value.setTimeout) { +1305 this.emitScalar('<window>'); +1306 } else if (value instanceof jasmine.Matchers.Any) { +1307 this.emitScalar(value.toString()); +1308 } else if (typeof value === 'string') { +1309 this.emitString(value); +1310 } else if (typeof value === 'function') { +1311 this.emitScalar('Function'); +1312 } else if (typeof value.nodeType === 'number') { +1313 this.emitScalar('HTMLNode'); +1314 } else if (value instanceof Date) { +1315 this.emitScalar('Date(' + value + ')'); +1316 } else if (value.__Jasmine_been_here_before__) { +1317 this.emitScalar('<circular reference: ' + (jasmine.isArray_(value) ? 'Array' : 'Object') + '>'); +1318 } else if (jasmine.isArray_(value) || typeof value == 'object') { +1319 value.__Jasmine_been_here_before__ = true; +1320 if (jasmine.isArray_(value)) { +1321 this.emitArray(value); +1322 } else { +1323 this.emitObject(value); +1324 } +1325 delete value.__Jasmine_been_here_before__; +1326 } else { +1327 this.emitScalar(value.toString()); +1328 } +1329 } finally { +1330 this.ppNestLevel_--; +1331 } +1332 }; +1333 +1334 jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { +1335 for (var property in obj) { +1336 if (property == '__Jasmine_been_here_before__') continue; +1337 fn(property, obj.__lookupGetter__(property) != null); +1338 } +1339 }; +1340 +1341 jasmine.PrettyPrinter.prototype.emitArray = jasmine.unimplementedMethod_; +1342 jasmine.PrettyPrinter.prototype.emitObject = jasmine.unimplementedMethod_; +1343 jasmine.PrettyPrinter.prototype.emitScalar = jasmine.unimplementedMethod_; +1344 jasmine.PrettyPrinter.prototype.emitString = jasmine.unimplementedMethod_; +1345 +1346 jasmine.StringPrettyPrinter = function() { +1347 jasmine.PrettyPrinter.call(this); +1348 +1349 this.string = ''; +1350 }; +1351 jasmine.util.inherit(jasmine.StringPrettyPrinter, jasmine.PrettyPrinter); +1352 +1353 jasmine.StringPrettyPrinter.prototype.emitScalar = function(value) { +1354 this.append(value); +1355 }; +1356 +1357 jasmine.StringPrettyPrinter.prototype.emitString = function(value) { +1358 this.append("'" + value + "'"); +1359 }; +1360 +1361 jasmine.StringPrettyPrinter.prototype.emitArray = function(array) { +1362 this.append('[ '); +1363 for (var i = 0; i < array.length; i++) { +1364 if (i > 0) { +1365 this.append(', '); +1366 } +1367 this.format(array[i]); +1368 } +1369 this.append(' ]'); +1370 }; +1371 +1372 jasmine.StringPrettyPrinter.prototype.emitObject = function(obj) { +1373 var self = this; +1374 this.append('{ '); +1375 var first = true; +1376 +1377 this.iterateObject(obj, function(property, isGetter) { +1378 if (first) { +1379 first = false; +1380 } else { +1381 self.append(', '); +1382 } +1383 +1384 self.append(property); +1385 self.append(' : '); +1386 if (isGetter) { +1387 self.append('<getter>'); +1388 } else { +1389 self.format(obj[property]); +1390 } +1391 }); +1392 +1393 this.append(' }'); +1394 }; +1395 +1396 jasmine.StringPrettyPrinter.prototype.append = function(value) { +1397 this.string += value; +1398 }; +1399 jasmine.Queue = function(env) { +1400 this.env = env; +1401 this.blocks = []; +1402 this.running = false; +1403 this.index = 0; +1404 this.offset = 0; +1405 }; +1406 +1407 jasmine.Queue.prototype.addBefore = function (block) { +1408 this.blocks.unshift(block); +1409 }; +1410 +1411 jasmine.Queue.prototype.add = function(block) { +1412 this.blocks.push(block); +1413 }; +1414 +1415 jasmine.Queue.prototype.insertNext = function (block) { +1416 this.blocks.splice((this.index + this.offset + 1), 0, block); +1417 this.offset++; +1418 }; +1419 +1420 jasmine.Queue.prototype.start = function(onComplete) { +1421 var self = this; +1422 self.running = true; +1423 self.onComplete = onComplete; +1424 if (self.blocks[0]) { +1425 self.blocks[0].execute(function () { +1426 self._next(); +1427 }); +1428 } else { +1429 self.finish(); +1430 } +1431 }; +1432 +1433 jasmine.Queue.prototype.isRunning = function () { +1434 return this.running; +1435 }; +1436 +1437 jasmine.Queue.prototype._next = function () { +1438 var self = this; +1439 var doNext = function () { +1440 self.offset = 0; +1441 self.index++; +1442 if (self.index < self.blocks.length) { +1443 self.blocks[self.index].execute(function () { +1444 self._next(); +1445 }); +1446 } else { +1447 self.finish(); +1448 } +1449 }; +1450 var now = new Date().getTime(); +1451 if (this.env.updateInterval && now - this.env.lastUpdate > this.env.updateInterval) { +1452 this.env.lastUpdate = now; +1453 this.env.setTimeout(doNext, 0); +1454 } else { +1455 doNext(); +1456 } +1457 +1458 }; +1459 +1460 jasmine.Queue.prototype.finish = function () { +1461 this.running = false; +1462 if (this.onComplete) { +1463 this.onComplete(); +1464 } 1465 }; 1466 -1467 -1468 /* JasmineReporters.reporter -1469 * Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to -1470 * descendants of this object to do something with the results (see json_reporter.js) -1471 */ -1472 jasmine.Reporters = {}; -1473 -1474 jasmine.Reporters.reporter = function(callbacks) { -1475 var that = { -1476 callbacks: callbacks || {}, +1467 jasmine.Queue.prototype.getResults = function () { +1468 var results = new jasmine.NestedResults(); +1469 for (var i = 0; i < this.blocks.length; i++) { +1470 if (this.blocks[i].getResults) { +1471 results.addResult(this.blocks[i].getResults()); +1472 } +1473 } +1474 return results; +1475 }; +1476 1477 -1478 doCallback: function(callback, results) { -1479 if (callback) { -1480 callback(results); -1481 } -1482 }, +1478 /* JasmineReporters.reporter +1479 * Base object that will get called whenever a Spec, Suite, or Runner is done. It is up to +1480 * descendants of this object to do something with the results (see json_reporter.js) +1481 */ +1482 jasmine.Reporters = {}; 1483 -1484 reportRunnerResults: function(runner) { -1485 that.doCallback(that.callbacks.runnerCallback, runner); -1486 }, -1487 reportSuiteResults: function(suite) { -1488 that.doCallback(that.callbacks.suiteCallback, suite); -1489 }, -1490 reportSpecResults: function(spec) { -1491 that.doCallback(that.callbacks.specCallback, spec); +1484 jasmine.Reporters.reporter = function(callbacks) { +1485 var that = { +1486 callbacks: callbacks || {}, +1487 +1488 doCallback: function(callback, results) { +1489 if (callback) { +1490 callback(results); +1491 } 1492 }, -1493 log: function (str) { -1494 if (console && console.log) console.log(str); -1495 } -1496 }; -1497 -1498 return that; -1499 }; -1500 -1501 /** -1502 * Runner -1503 * -1504 * @constructor -1505 * @param {jasmine.Env} env -1506 */ -1507 jasmine.Runner = function(env) { -1508 var self = this; -1509 self.env = env; -1510 self.queue = new jasmine.Queue(env); -1511 self.suites_ = []; -1512 }; -1513 -1514 jasmine.Runner.prototype.execute = function() { -1515 var self = this; -1516 if (self.env.reporter.reportRunnerStarting) { -1517 self.env.reporter.reportRunnerStarting(this); -1518 } -1519 self.queue.start(function () { -1520 self.finishCallback(); -1521 }); +1493 +1494 reportRunnerResults: function(runner) { +1495 that.doCallback(that.callbacks.runnerCallback, runner); +1496 }, +1497 reportSuiteResults: function(suite) { +1498 that.doCallback(that.callbacks.suiteCallback, suite); +1499 }, +1500 reportSpecResults: function(spec) { +1501 that.doCallback(that.callbacks.specCallback, spec); +1502 }, +1503 log: function (str) { +1504 if (console && console.log) console.log(str); +1505 } +1506 }; +1507 +1508 return that; +1509 }; +1510 +1511 /** +1512 * Runner +1513 * +1514 * @constructor +1515 * @param {jasmine.Env} env +1516 */ +1517 jasmine.Runner = function(env) { +1518 var self = this; +1519 self.env = env; +1520 self.queue = new jasmine.Queue(env); +1521 self.suites_ = []; 1522 }; 1523 -1524 jasmine.Runner.prototype.finishCallback = function() { -1525 this.env.reporter.reportRunnerResults(this); -1526 }; -1527 -1528 jasmine.Runner.prototype.addSuite = function(suite) { -1529 this.suites_.push(suite); -1530 }; -1531 -1532 jasmine.Runner.prototype.add = function(block) { -1533 if (block instanceof jasmine.Suite) { -1534 this.addSuite(block); -1535 } -1536 this.queue.add(block); -1537 }; -1538 -1539 /** @deprecated */ -1540 jasmine.Runner.prototype.getAllSuites = function() { -1541 return this.suites_; -1542 }; -1543 -1544 -1545 jasmine.Runner.prototype.suites = function() { -1546 return this.suites_; +1524 jasmine.Runner.prototype.execute = function() { +1525 var self = this; +1526 if (self.env.reporter.reportRunnerStarting) { +1527 self.env.reporter.reportRunnerStarting(this); +1528 } +1529 self.queue.start(function () { +1530 self.finishCallback(); +1531 }); +1532 }; +1533 +1534 jasmine.Runner.prototype.finishCallback = function() { +1535 this.env.reporter.reportRunnerResults(this); +1536 }; +1537 +1538 jasmine.Runner.prototype.addSuite = function(suite) { +1539 this.suites_.push(suite); +1540 }; +1541 +1542 jasmine.Runner.prototype.add = function(block) { +1543 if (block instanceof jasmine.Suite) { +1544 this.addSuite(block); +1545 } +1546 this.queue.add(block); 1547 }; 1548 -1549 jasmine.Runner.prototype.getResults = function() { -1550 return this.queue.getResults(); -1551 }; -1552 /** -1553 * Internal representation of a Jasmine specification, or test. -1554 * -1555 * @constructor -1556 * @param {jasmine.Env} env -1557 * @param {jasmine.Suite} suite -1558 * @param {String} description -1559 */ -1560 jasmine.Spec = function(env, suite, description) { -1561 var spec = this; -1562 spec.id = env.nextSpecId_++; -1563 spec.env = env; -1564 spec.suite = suite; -1565 spec.description = description; -1566 spec.queue = new jasmine.Queue(env); -1567 -1568 spec.afterCallbacks = []; -1569 spec.spies_ = []; -1570 -1571 spec.results = new jasmine.NestedResults(); -1572 spec.results.description = description; -1573 spec.matchersClass = null; -1574 }; -1575 -1576 jasmine.Spec.prototype.getFullName = function() { -1577 return this.suite.getFullName() + ' ' + this.description + '.'; -1578 }; -1579 -1580 jasmine.Spec.prototype.getResults = function() { -1581 return this.results; -1582 }; -1583 -1584 jasmine.Spec.prototype.runs = function (func) { -1585 var block = new jasmine.Block(this.env, func, this); -1586 this.addToQueue(block); -1587 return this; +1549 /** @deprecated */ +1550 jasmine.Runner.prototype.getAllSuites = function() { +1551 return this.suites_; +1552 }; +1553 +1554 +1555 jasmine.Runner.prototype.suites = function() { +1556 return this.suites_; +1557 }; +1558 +1559 jasmine.Runner.prototype.getResults = function() { +1560 return this.queue.getResults(); +1561 }; +1562 /** +1563 * Internal representation of a Jasmine specification, or test. +1564 * +1565 * @constructor +1566 * @param {jasmine.Env} env +1567 * @param {jasmine.Suite} suite +1568 * @param {String} description +1569 */ +1570 jasmine.Spec = function(env, suite, description) { +1571 var spec = this; +1572 spec.id = env.nextSpecId_++; +1573 spec.env = env; +1574 spec.suite = suite; +1575 spec.description = description; +1576 spec.queue = new jasmine.Queue(env); +1577 +1578 spec.afterCallbacks = []; +1579 spec.spies_ = []; +1580 +1581 spec.results = new jasmine.NestedResults(); +1582 spec.results.description = description; +1583 spec.matchersClass = null; +1584 }; +1585 +1586 jasmine.Spec.prototype.getFullName = function() { +1587 return this.suite.getFullName() + ' ' + this.description + '.'; 1588 }; 1589 -1590 jasmine.Spec.prototype.addToQueue = function (block) { -1591 if (this.queue.isRunning()) { -1592 this.queue.insertNext(block); -1593 } else { -1594 this.queue.add(block); -1595 } -1596 }; -1597 -1598 /** -1599 * @private -1600 * @deprecated -1601 */ -1602 jasmine.Spec.prototype.expects_that = function(actual) { -1603 return this.expect(actual); -1604 }; -1605 -1606 /** -1607 * @private -1608 */ -1609 jasmine.Spec.prototype.expect = function(actual) { -1610 return new (this.getMatchersClass_())(this.env, actual, this.results); -1611 }; -1612 -1613 jasmine.Spec.prototype.waits = function(timeout) { -1614 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); -1615 this.addToQueue(waitsFunc); -1616 return this; -1617 }; -1618 -1619 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { -1620 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); -1621 this.addToQueue(waitsForFunc); -1622 return this; -1623 }; -1624 -1625 jasmine.Spec.prototype.failWithException = function (e) { -1626 this.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null)); +1590 jasmine.Spec.prototype.getResults = function() { +1591 return this.results; +1592 }; +1593 +1594 jasmine.Spec.prototype.runs = function (func) { +1595 var block = new jasmine.Block(this.env, func, this); +1596 this.addToQueue(block); +1597 return this; +1598 }; +1599 +1600 jasmine.Spec.prototype.addToQueue = function (block) { +1601 if (this.queue.isRunning()) { +1602 this.queue.insertNext(block); +1603 } else { +1604 this.queue.add(block); +1605 } +1606 }; +1607 +1608 /** +1609 * @private +1610 * @deprecated +1611 */ +1612 jasmine.Spec.prototype.expects_that = function(actual) { +1613 return this.expect(actual); +1614 }; +1615 +1616 /** +1617 * @private +1618 */ +1619 jasmine.Spec.prototype.expect = function(actual) { +1620 return new (this.getMatchersClass_())(this.env, actual, this.results); +1621 }; +1622 +1623 jasmine.Spec.prototype.waits = function(timeout) { +1624 var waitsFunc = new jasmine.WaitsBlock(this.env, timeout, this); +1625 this.addToQueue(waitsFunc); +1626 return this; 1627 }; 1628 -1629 jasmine.Spec.prototype.getMatchersClass_ = function() { -1630 return this.matchersClass || jasmine.Matchers; -1631 }; -1632 -1633 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { -1634 var parent = this.getMatchersClass_(); -1635 var newMatchersClass = function() { -1636 parent.apply(this, arguments); -1637 }; -1638 jasmine.util.inherit(newMatchersClass, parent); -1639 for (var method in matchersPrototype) { -1640 newMatchersClass.prototype[method] = matchersPrototype[method]; -1641 } -1642 this.matchersClass = newMatchersClass; -1643 }; -1644 -1645 jasmine.Spec.prototype.finishCallback = function() { -1646 this.env.reporter.reportSpecResults(this); -1647 }; -1648 -1649 jasmine.Spec.prototype.finish = function(onComplete) { -1650 this.removeAllSpies(); -1651 this.finishCallback(); -1652 if (onComplete) { -1653 onComplete(); -1654 } -1655 }; -1656 -1657 jasmine.Spec.prototype.after = function(doAfter, test) { +1629 jasmine.Spec.prototype.waitsFor = function(timeout, latchFunction, timeoutMessage) { +1630 var waitsForFunc = new jasmine.WaitsForBlock(this.env, timeout, latchFunction, timeoutMessage, this); +1631 this.addToQueue(waitsForFunc); +1632 return this; +1633 }; +1634 +1635 jasmine.Spec.prototype.failWithException = function (e) { +1636 this.results.addResult(new jasmine.ExpectationResult(false, jasmine.util.formatException(e), null)); +1637 }; +1638 +1639 jasmine.Spec.prototype.getMatchersClass_ = function() { +1640 return this.matchersClass || jasmine.Matchers; +1641 }; +1642 +1643 jasmine.Spec.prototype.addMatchers = function(matchersPrototype) { +1644 var parent = this.getMatchersClass_(); +1645 var newMatchersClass = function() { +1646 parent.apply(this, arguments); +1647 }; +1648 jasmine.util.inherit(newMatchersClass, parent); +1649 for (var method in matchersPrototype) { +1650 newMatchersClass.prototype[method] = matchersPrototype[method]; +1651 } +1652 this.matchersClass = newMatchersClass; +1653 }; +1654 +1655 jasmine.Spec.prototype.finishCallback = function() { +1656 this.env.reporter.reportSpecResults(this); +1657 }; 1658 -1659 if (this.queue.isRunning()) { -1660 this.queue.add(new jasmine.Block(this.env, doAfter, this)); -1661 } else { -1662 this.afterCallbacks.unshift(doAfter); -1663 } -1664 }; -1665 -1666 jasmine.Spec.prototype.execute = function(onComplete) { -1667 var spec = this; -1668 if (!spec.env.specFilter(spec)) { -1669 spec.results.skipped = true; -1670 spec.finish(onComplete); -1671 return; -1672 } -1673 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); -1674 -1675 spec.env.currentSpec = spec; -1676 spec.env.currentlyRunningTests = true; -1677 -1678 spec.addBeforesAndAftersToQueue(); -1679 -1680 spec.queue.start(function () { -1681 spec.finish(onComplete); -1682 }); -1683 spec.env.currentlyRunningTests = false; -1684 }; -1685 -1686 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { -1687 for (var suite = this.suite; suite; suite = suite.parentSuite) { -1688 if (suite.beforeQueue) { -1689 for (var i = 0; i < suite.beforeQueue.length; i++) -1690 this.queue.addBefore(new jasmine.Block(this.env, suite.beforeQueue[i], this)); -1691 } -1692 } -1693 for (i = 0; i < this.afterCallbacks.length; i++) { -1694 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); -1695 } -1696 for (suite = this.suite; suite; suite = suite.parentSuite) { -1697 if (suite.afterQueue) { -1698 for (var j = 0; j < suite.afterQueue.length; j++) -1699 this.queue.add(new jasmine.Block(this.env, suite.afterQueue[j], this)); -1700 } -1701 } -1702 }; -1703 -1704 jasmine.Spec.prototype.explodes = function() { -1705 throw 'explodes function should not have been called'; -1706 }; -1707 -1708 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { -1709 if (obj == undefined) { -1710 throw "spyOn could not find an object to spy upon for " + methodName + "()"; +1659 jasmine.Spec.prototype.finish = function(onComplete) { +1660 this.removeAllSpies(); +1661 this.finishCallback(); +1662 if (onComplete) { +1663 onComplete(); +1664 } +1665 }; +1666 +1667 jasmine.Spec.prototype.after = function(doAfter, test) { +1668 +1669 if (this.queue.isRunning()) { +1670 this.queue.add(new jasmine.Block(this.env, doAfter, this)); +1671 } else { +1672 this.afterCallbacks.unshift(doAfter); +1673 } +1674 }; +1675 +1676 jasmine.Spec.prototype.execute = function(onComplete) { +1677 var spec = this; +1678 if (!spec.env.specFilter(spec)) { +1679 spec.results.skipped = true; +1680 spec.finish(onComplete); +1681 return; +1682 } +1683 this.env.reporter.log('>> Jasmine Running ' + this.suite.description + ' ' + this.description + '...'); +1684 +1685 spec.env.currentSpec = spec; +1686 spec.env.currentlyRunningTests = true; +1687 +1688 spec.addBeforesAndAftersToQueue(); +1689 +1690 spec.queue.start(function () { +1691 spec.finish(onComplete); +1692 }); +1693 spec.env.currentlyRunningTests = false; +1694 }; +1695 +1696 jasmine.Spec.prototype.addBeforesAndAftersToQueue = function() { +1697 for (var suite = this.suite; suite; suite = suite.parentSuite) { +1698 if (suite.beforeQueue) { +1699 for (var i = 0; i < suite.beforeQueue.length; i++) +1700 this.queue.addBefore(new jasmine.Block(this.env, suite.beforeQueue[i], this)); +1701 } +1702 } +1703 for (i = 0; i < this.afterCallbacks.length; i++) { +1704 this.queue.add(new jasmine.Block(this.env, this.afterCallbacks[i], this)); +1705 } +1706 for (suite = this.suite; suite; suite = suite.parentSuite) { +1707 if (suite.afterQueue) { +1708 for (var j = 0; j < suite.afterQueue.length; j++) +1709 this.queue.add(new jasmine.Block(this.env, suite.afterQueue[j], this)); +1710 } 1711 } -1712 -1713 if (!ignoreMethodDoesntExist && obj[methodName] === undefined) { -1714 throw methodName + '() method does not exist'; -1715 } -1716 -1717 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { -1718 throw new Error(methodName + ' has already been spied upon'); -1719 } -1720 -1721 var spyObj = jasmine.createSpy(methodName); +1712 }; +1713 +1714 jasmine.Spec.prototype.explodes = function() { +1715 throw 'explodes function should not have been called'; +1716 }; +1717 +1718 jasmine.Spec.prototype.spyOn = function(obj, methodName, ignoreMethodDoesntExist) { +1719 if (obj == undefined) { +1720 throw "spyOn could not find an object to spy upon for " + methodName + "()"; +1721 } 1722 -1723 this.spies_.push(spyObj); -1724 spyObj.baseObj = obj; -1725 spyObj.methodName = methodName; -1726 spyObj.originalValue = obj[methodName]; -1727 -1728 obj[methodName] = spyObj; -1729 -1730 return spyObj; -1731 }; +1723 if (!ignoreMethodDoesntExist && obj[methodName] === undefined) { +1724 throw methodName + '() method does not exist'; +1725 } +1726 +1727 if (!ignoreMethodDoesntExist && obj[methodName] && obj[methodName].isSpy) { +1728 throw new Error(methodName + ' has already been spied upon'); +1729 } +1730 +1731 var spyObj = jasmine.createSpy(methodName); 1732 -1733 jasmine.Spec.prototype.removeAllSpies = function() { -1734 for (var i = 0; i < this.spies_.length; i++) { -1735 var spy = this.spies_[i]; -1736 spy.baseObj[spy.methodName] = spy.originalValue; -1737 } -1738 this.spies_ = []; -1739 }; -1740 -1741 /** -1742 * Internal representation of a Jasmine suite. -1743 * -1744 * @constructor -1745 * @param {jasmine.Env} env -1746 * @param {String} description -1747 * @param {Function} specDefinitions -1748 * @param {jasmine.Suite} parentSuite -1749 */ -1750 jasmine.Suite = function(env, description, specDefinitions, parentSuite) { -1751 var self = this; -1752 self.id = env.nextSuiteId_++; -1753 self.description = description; -1754 self.queue = new jasmine.Queue(env); -1755 self.parentSuite = parentSuite; -1756 self.env = env; -1757 self.beforeQueue = []; -1758 self.afterQueue = []; -1759 self.specs_ = []; -1760 }; -1761 -1762 jasmine.Suite.prototype.getFullName = function() { -1763 var fullName = this.description; -1764 for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { -1765 fullName = parentSuite.description + ' ' + fullName; -1766 } -1767 return fullName; -1768 }; -1769 -1770 jasmine.Suite.prototype.finish = function(onComplete) { -1771 this.env.reporter.reportSuiteResults(this); -1772 this.finished = true; -1773 if (typeof(onComplete) == 'function') { -1774 onComplete(); -1775 } -1776 }; -1777 -1778 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { -1779 beforeEachFunction.typeName = 'beforeEach'; -1780 this.beforeQueue.push(beforeEachFunction); -1781 }; -1782 -1783 jasmine.Suite.prototype.afterEach = function(afterEachFunction) { -1784 afterEachFunction.typeName = 'afterEach'; -1785 this.afterQueue.push(afterEachFunction); +1733 this.spies_.push(spyObj); +1734 spyObj.baseObj = obj; +1735 spyObj.methodName = methodName; +1736 spyObj.originalValue = obj[methodName]; +1737 +1738 obj[methodName] = spyObj; +1739 +1740 return spyObj; +1741 }; +1742 +1743 jasmine.Spec.prototype.removeAllSpies = function() { +1744 for (var i = 0; i < this.spies_.length; i++) { +1745 var spy = this.spies_[i]; +1746 spy.baseObj[spy.methodName] = spy.originalValue; +1747 } +1748 this.spies_ = []; +1749 }; +1750 +1751 /** +1752 * Internal representation of a Jasmine suite. +1753 * +1754 * @constructor +1755 * @param {jasmine.Env} env +1756 * @param {String} description +1757 * @param {Function} specDefinitions +1758 * @param {jasmine.Suite} parentSuite +1759 */ +1760 jasmine.Suite = function(env, description, specDefinitions, parentSuite) { +1761 var self = this; +1762 self.id = env.nextSuiteId_++; +1763 self.description = description; +1764 self.queue = new jasmine.Queue(env); +1765 self.parentSuite = parentSuite; +1766 self.env = env; +1767 self.beforeQueue = []; +1768 self.afterQueue = []; +1769 self.specs_ = []; +1770 }; +1771 +1772 jasmine.Suite.prototype.getFullName = function() { +1773 var fullName = this.description; +1774 for (var parentSuite = this.parentSuite; parentSuite; parentSuite = parentSuite.parentSuite) { +1775 fullName = parentSuite.description + ' ' + fullName; +1776 } +1777 return fullName; +1778 }; +1779 +1780 jasmine.Suite.prototype.finish = function(onComplete) { +1781 this.env.reporter.reportSuiteResults(this); +1782 this.finished = true; +1783 if (typeof(onComplete) == 'function') { +1784 onComplete(); +1785 } 1786 }; 1787 -1788 jasmine.Suite.prototype.getResults = function() { -1789 return this.queue.getResults(); -1790 }; -1791 -1792 jasmine.Suite.prototype.add = function(block) { -1793 if (block instanceof jasmine.Suite) { -1794 this.env.currentRunner.addSuite(block); -1795 } else { -1796 this.specs_.push(block); -1797 } -1798 this.queue.add(block); -1799 }; -1800 -1801 /** @deprecated */ -1802 jasmine.Suite.prototype.specCount = function() { -1803 return this.specs_.length; -1804 }; -1805 -1806 jasmine.Suite.prototype.specs = function() { -1807 return this.specs_; -1808 }; -1809 -1810 jasmine.Suite.prototype.execute = function(onComplete) { -1811 var self = this; -1812 this.queue.start(function () { -1813 self.finish(onComplete); -1814 }); -1815 }; -1816 jasmine.WaitsBlock = function(env, timeout, spec) { -1817 this.timeout = timeout; -1818 jasmine.Block.call(this, env, null, spec); -1819 }; -1820 -1821 jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); -1822 -1823 jasmine.WaitsBlock.prototype.execute = function (onComplete) { -1824 this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); -1825 this.env.setTimeout(function () { -1826 onComplete(); -1827 }, this.timeout); -1828 }; -1829 jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { -1830 this.timeout = timeout; -1831 this.latchFunction = latchFunction; -1832 this.message = message; -1833 this.totalTimeSpentWaitingForLatch = 0; -1834 jasmine.Block.call(this, env, null, spec); -1835 }; -1836 -1837 jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); -1838 -1839 jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100; -1840 -1841 jasmine.WaitsForBlock.prototype.execute = function (onComplete) { -1842 var self = this; -1843 self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen')); -1844 var latchFunctionResult; -1845 try { -1846 latchFunctionResult = self.latchFunction.apply(self.spec); -1847 } catch (e) { -1848 self.fail(e); -1849 onComplete(); -1850 return; -1851 } -1852 -1853 if (latchFunctionResult) { -1854 onComplete(); -1855 } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) { -1856 var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen'); -1857 self.fail({ -1858 name: 'timeout', -1859 message: message -1860 }); -1861 self.spec._next(); -1862 } else { -1863 self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; -1864 self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); -1865 } -1866 }; -1867 // Mock setTimeout, clearTimeout -1868 // Contributed by Pivotal Computer Systems, www.pivotalsf.com -1869 -1870 jasmine.FakeTimer = function() { -1871 this.reset(); -1872 -1873 var self = this; -1874 self.setTimeout = function(funcToCall, millis) { -1875 self.timeoutsMade++; -1876 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); -1877 return self.timeoutsMade; -1878 }; +1788 jasmine.Suite.prototype.beforeEach = function(beforeEachFunction) { +1789 beforeEachFunction.typeName = 'beforeEach'; +1790 this.beforeQueue.push(beforeEachFunction); +1791 }; +1792 +1793 jasmine.Suite.prototype.afterEach = function(afterEachFunction) { +1794 afterEachFunction.typeName = 'afterEach'; +1795 this.afterQueue.push(afterEachFunction); +1796 }; +1797 +1798 jasmine.Suite.prototype.getResults = function() { +1799 return this.queue.getResults(); +1800 }; +1801 +1802 jasmine.Suite.prototype.add = function(block) { +1803 if (block instanceof jasmine.Suite) { +1804 this.env.currentRunner.addSuite(block); +1805 } else { +1806 this.specs_.push(block); +1807 } +1808 this.queue.add(block); +1809 }; +1810 +1811 /** @deprecated */ +1812 jasmine.Suite.prototype.specCount = function() { +1813 return this.specs_.length; +1814 }; +1815 +1816 jasmine.Suite.prototype.specs = function() { +1817 return this.specs_; +1818 }; +1819 +1820 jasmine.Suite.prototype.execute = function(onComplete) { +1821 var self = this; +1822 this.queue.start(function () { +1823 self.finish(onComplete); +1824 }); +1825 }; +1826 jasmine.WaitsBlock = function(env, timeout, spec) { +1827 this.timeout = timeout; +1828 jasmine.Block.call(this, env, null, spec); +1829 }; +1830 +1831 jasmine.util.inherit(jasmine.WaitsBlock, jasmine.Block); +1832 +1833 jasmine.WaitsBlock.prototype.execute = function (onComplete) { +1834 this.env.reporter.log('>> Jasmine waiting for ' + this.timeout + ' ms...'); +1835 this.env.setTimeout(function () { +1836 onComplete(); +1837 }, this.timeout); +1838 }; +1839 jasmine.WaitsForBlock = function(env, timeout, latchFunction, message, spec) { +1840 this.timeout = timeout; +1841 this.latchFunction = latchFunction; +1842 this.message = message; +1843 this.totalTimeSpentWaitingForLatch = 0; +1844 jasmine.Block.call(this, env, null, spec); +1845 }; +1846 +1847 jasmine.util.inherit(jasmine.WaitsForBlock, jasmine.Block); +1848 +1849 jasmine.WaitsForBlock.TIMEOUT_INCREMENT = 100; +1850 +1851 jasmine.WaitsForBlock.prototype.execute = function (onComplete) { +1852 var self = this; +1853 self.env.reporter.log('>> Jasmine waiting for ' + (self.message || 'something to happen')); +1854 var latchFunctionResult; +1855 try { +1856 latchFunctionResult = self.latchFunction.apply(self.spec); +1857 } catch (e) { +1858 self.fail(e); +1859 onComplete(); +1860 return; +1861 } +1862 +1863 if (latchFunctionResult) { +1864 onComplete(); +1865 } else if (self.totalTimeSpentWaitingForLatch >= self.timeout) { +1866 var message = 'timed out after ' + self.timeout + ' msec waiting for ' + (self.message || 'something to happen'); +1867 self.fail({ +1868 name: 'timeout', +1869 message: message +1870 }); +1871 self.spec._next(); +1872 } else { +1873 self.totalTimeSpentWaitingForLatch += jasmine.WaitsForBlock.TIMEOUT_INCREMENT; +1874 self.env.setTimeout(function () { self.execute(onComplete); }, jasmine.WaitsForBlock.TIMEOUT_INCREMENT); +1875 } +1876 }; +1877 // Mock setTimeout, clearTimeout +1878 // Contributed by Pivotal Computer Systems, www.pivotalsf.com 1879 -1880 self.setInterval = function(funcToCall, millis) { -1881 self.timeoutsMade++; -1882 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); -1883 return self.timeoutsMade; -1884 }; -1885 -1886 self.clearTimeout = function(timeoutKey) { -1887 self.scheduledFunctions[timeoutKey] = undefined; +1880 jasmine.FakeTimer = function() { +1881 this.reset(); +1882 +1883 var self = this; +1884 self.setTimeout = function(funcToCall, millis) { +1885 self.timeoutsMade++; +1886 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, false); +1887 return self.timeoutsMade; 1888 }; 1889 -1890 self.clearInterval = function(timeoutKey) { -1891 self.scheduledFunctions[timeoutKey] = undefined; -1892 }; -1893 -1894 }; +1890 self.setInterval = function(funcToCall, millis) { +1891 self.timeoutsMade++; +1892 self.scheduleFunction(self.timeoutsMade, funcToCall, millis, true); +1893 return self.timeoutsMade; +1894 }; 1895 -1896 jasmine.FakeTimer.prototype.reset = function() { -1897 this.timeoutsMade = 0; -1898 this.scheduledFunctions = {}; -1899 this.nowMillis = 0; -1900 }; -1901 -1902 jasmine.FakeTimer.prototype.tick = function(millis) { -1903 var oldMillis = this.nowMillis; -1904 var newMillis = oldMillis + millis; -1905 this.runFunctionsWithinRange(oldMillis, newMillis); -1906 this.nowMillis = newMillis; -1907 }; -1908 -1909 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { -1910 var scheduledFunc; -1911 var funcsToRun = []; -1912 for (var timeoutKey in this.scheduledFunctions) { -1913 scheduledFunc = this.scheduledFunctions[timeoutKey]; -1914 if (scheduledFunc != undefined && -1915 scheduledFunc.runAtMillis >= oldMillis && -1916 scheduledFunc.runAtMillis <= nowMillis) { -1917 funcsToRun.push(scheduledFunc); -1918 this.scheduledFunctions[timeoutKey] = undefined; -1919 } -1920 } -1921 -1922 if (funcsToRun.length > 0) { -1923 funcsToRun.sort(function(a, b) { -1924 return a.runAtMillis - b.runAtMillis; -1925 }); -1926 for (var i = 0; i < funcsToRun.length; ++i) { -1927 try { -1928 var funcToRun = funcsToRun[i]; -1929 this.nowMillis = funcToRun.runAtMillis; -1930 funcToRun.funcToCall(); -1931 if (funcToRun.recurring) { -1932 this.scheduleFunction(funcToRun.timeoutKey, -1933 funcToRun.funcToCall, -1934 funcToRun.millis, -1935 true); -1936 } -1937 } catch(e) { -1938 } -1939 } -1940 this.runFunctionsWithinRange(oldMillis, nowMillis); -1941 } -1942 }; -1943 -1944 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { -1945 this.scheduledFunctions[timeoutKey] = { -1946 runAtMillis: this.nowMillis + millis, -1947 funcToCall: funcToCall, -1948 recurring: recurring, -1949 timeoutKey: timeoutKey, -1950 millis: millis -1951 }; +1896 self.clearTimeout = function(timeoutKey) { +1897 self.scheduledFunctions[timeoutKey] = undefined; +1898 }; +1899 +1900 self.clearInterval = function(timeoutKey) { +1901 self.scheduledFunctions[timeoutKey] = undefined; +1902 }; +1903 +1904 }; +1905 +1906 jasmine.FakeTimer.prototype.reset = function() { +1907 this.timeoutsMade = 0; +1908 this.scheduledFunctions = {}; +1909 this.nowMillis = 0; +1910 }; +1911 +1912 jasmine.FakeTimer.prototype.tick = function(millis) { +1913 var oldMillis = this.nowMillis; +1914 var newMillis = oldMillis + millis; +1915 this.runFunctionsWithinRange(oldMillis, newMillis); +1916 this.nowMillis = newMillis; +1917 }; +1918 +1919 jasmine.FakeTimer.prototype.runFunctionsWithinRange = function(oldMillis, nowMillis) { +1920 var scheduledFunc; +1921 var funcsToRun = []; +1922 for (var timeoutKey in this.scheduledFunctions) { +1923 scheduledFunc = this.scheduledFunctions[timeoutKey]; +1924 if (scheduledFunc != undefined && +1925 scheduledFunc.runAtMillis >= oldMillis && +1926 scheduledFunc.runAtMillis <= nowMillis) { +1927 funcsToRun.push(scheduledFunc); +1928 this.scheduledFunctions[timeoutKey] = undefined; +1929 } +1930 } +1931 +1932 if (funcsToRun.length > 0) { +1933 funcsToRun.sort(function(a, b) { +1934 return a.runAtMillis - b.runAtMillis; +1935 }); +1936 for (var i = 0; i < funcsToRun.length; ++i) { +1937 try { +1938 var funcToRun = funcsToRun[i]; +1939 this.nowMillis = funcToRun.runAtMillis; +1940 funcToRun.funcToCall(); +1941 if (funcToRun.recurring) { +1942 this.scheduleFunction(funcToRun.timeoutKey, +1943 funcToRun.funcToCall, +1944 funcToRun.millis, +1945 true); +1946 } +1947 } catch(e) { +1948 } +1949 } +1950 this.runFunctionsWithinRange(oldMillis, nowMillis); +1951 } 1952 }; 1953 -1954 -1955 jasmine.Clock = { -1956 defaultFakeTimer: new jasmine.FakeTimer(), -1957 -1958 reset: function() { -1959 jasmine.Clock.assertInstalled(); -1960 jasmine.Clock.defaultFakeTimer.reset(); -1961 }, -1962 -1963 tick: function(millis) { -1964 jasmine.Clock.assertInstalled(); -1965 jasmine.Clock.defaultFakeTimer.tick(millis); -1966 }, +1954 jasmine.FakeTimer.prototype.scheduleFunction = function(timeoutKey, funcToCall, millis, recurring) { +1955 this.scheduledFunctions[timeoutKey] = { +1956 runAtMillis: this.nowMillis + millis, +1957 funcToCall: funcToCall, +1958 recurring: recurring, +1959 timeoutKey: timeoutKey, +1960 millis: millis +1961 }; +1962 }; +1963 +1964 +1965 jasmine.Clock = { +1966 defaultFakeTimer: new jasmine.FakeTimer(), 1967 -1968 runFunctionsWithinRange: function(oldMillis, nowMillis) { -1969 jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); -1970 }, -1971 -1972 scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { -1973 jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); -1974 }, -1975 -1976 useMock: function() { -1977 var spec = jasmine.getEnv().currentSpec; -1978 spec.after(jasmine.Clock.uninstallMock); -1979 -1980 jasmine.Clock.installMock(); -1981 }, -1982 -1983 installMock: function() { -1984 jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; -1985 }, -1986 -1987 uninstallMock: function() { -1988 jasmine.Clock.assertInstalled(); -1989 jasmine.Clock.installed = jasmine.Clock.real; -1990 }, -1991 -1992 real: { -1993 setTimeout: window.setTimeout, -1994 clearTimeout: window.clearTimeout, -1995 setInterval: window.setInterval, -1996 clearInterval: window.clearInterval -1997 }, -1998 -1999 assertInstalled: function() { -2000 if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) { -2001 throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); -2002 } -2003 }, -2004 -2005 installed: null -2006 }; -2007 jasmine.Clock.installed = jasmine.Clock.real; +1968 reset: function() { +1969 jasmine.Clock.assertInstalled(); +1970 jasmine.Clock.defaultFakeTimer.reset(); +1971 }, +1972 +1973 tick: function(millis) { +1974 jasmine.Clock.assertInstalled(); +1975 jasmine.Clock.defaultFakeTimer.tick(millis); +1976 }, +1977 +1978 runFunctionsWithinRange: function(oldMillis, nowMillis) { +1979 jasmine.Clock.defaultFakeTimer.runFunctionsWithinRange(oldMillis, nowMillis); +1980 }, +1981 +1982 scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) { +1983 jasmine.Clock.defaultFakeTimer.scheduleFunction(timeoutKey, funcToCall, millis, recurring); +1984 }, +1985 +1986 useMock: function() { +1987 var spec = jasmine.getEnv().currentSpec; +1988 spec.after(jasmine.Clock.uninstallMock); +1989 +1990 jasmine.Clock.installMock(); +1991 }, +1992 +1993 installMock: function() { +1994 jasmine.Clock.installed = jasmine.Clock.defaultFakeTimer; +1995 }, +1996 +1997 uninstallMock: function() { +1998 jasmine.Clock.assertInstalled(); +1999 jasmine.Clock.installed = jasmine.Clock.real; +2000 }, +2001 +2002 real: { +2003 setTimeout: window.setTimeout, +2004 clearTimeout: window.clearTimeout, +2005 setInterval: window.setInterval, +2006 clearInterval: window.clearInterval +2007 }, 2008 -2009 window.setTimeout = function(funcToCall, millis) { -2010 return jasmine.Clock.installed.setTimeout.apply(this, arguments); -2011 }; -2012 -2013 window.setInterval = function(funcToCall, millis) { -2014 return jasmine.Clock.installed.setInterval.apply(this, arguments); -2015 }; -2016 -2017 window.clearTimeout = function(timeoutKey) { -2018 return jasmine.Clock.installed.clearTimeout.apply(this, arguments); -2019 }; -2020 -2021 window.clearInterval = function(timeoutKey) { -2022 return jasmine.Clock.installed.clearInterval.apply(this, arguments); -2023 }; -2024 -2025 \ No newline at end of file +2009 assertInstalled: function() { +2010 if (jasmine.Clock.installed != jasmine.Clock.defaultFakeTimer) { +2011 throw new Error("Mock clock is not installed, use jasmine.Clock.useMock()"); +2012 } +2013 }, +2014 +2015 installed: null +2016 }; +2017 jasmine.Clock.installed = jasmine.Clock.real; +2018 +2019 window.setTimeout = function(funcToCall, millis) { +2020 return jasmine.Clock.installed.setTimeout.apply(this, arguments); +2021 }; +2022 +2023 window.setInterval = function(funcToCall, millis) { +2024 return jasmine.Clock.installed.setInterval.apply(this, arguments); +2025 }; +2026 +2027 window.clearTimeout = function(timeoutKey) { +2028 return jasmine.Clock.installed.clearTimeout.apply(this, arguments); +2029 }; +2030 +2031 window.clearInterval = function(timeoutKey) { +2032 return jasmine.Clock.installed.clearInterval.apply(this, arguments); +2033 }; +2034 +2035 \ No newline at end of file diff --git a/lib/jasmine-0.9.0.js b/lib/jasmine-0.9.0.js index 537371d2..56dc2392 100644 --- a/lib/jasmine-0.9.0.js +++ b/lib/jasmine-0.9.0.js @@ -517,7 +517,7 @@ jasmine.version_= { "major": 0, "minor": 9, "build": 0, - "revision": 1252086971 + "revision": 1252118695 }; /** * @namespace