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