jazz_money 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,117 @@
1
+ jasmine.TrivialReporter = function(doc) {
2
+ this.document = doc || document;
3
+ this.suiteDivs = {};
4
+ };
5
+
6
+ jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
7
+ var el = document.createElement(type);
8
+
9
+ for (var i = 2; i < arguments.length; i++) {
10
+ var child = arguments[i];
11
+
12
+ if (typeof child === 'string') {
13
+ el.appendChild(document.createTextNode(child));
14
+ } else {
15
+ if (child) { el.appendChild(child); }
16
+ }
17
+ }
18
+
19
+ for (var attr in attrs) {
20
+ el[attr] = attrs[attr];
21
+ }
22
+
23
+ return el;
24
+ };
25
+
26
+ jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
27
+ var suites = runner.suites();
28
+
29
+ this.runnerDiv = this.createDom('div', { className: 'runner running' },
30
+ this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
31
+ this.runnerMessageSpan = this.createDom('span', {}, "Running..."));
32
+ this.document.body.appendChild(this.runnerDiv);
33
+
34
+ for (var i = 0; i < suites.length; i++) {
35
+ var suite = suites[i];
36
+ var suiteDiv = this.createDom('div', { className: 'suite' },
37
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
38
+ this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
39
+ this.suiteDivs[suite.getFullName()] = suiteDiv;
40
+ var parentDiv = this.document.body;
41
+ if (suite.parentSuite) {
42
+ parentDiv = this.suiteDivs[suite.parentSuite.getFullName()];
43
+ }
44
+ parentDiv.appendChild(suiteDiv);
45
+ }
46
+
47
+ this.startedAt = new Date();
48
+ };
49
+
50
+ jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
51
+ var results = runner.results();
52
+ var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
53
+ this.runnerDiv.setAttribute("class", className);
54
+ //do it twice for IE
55
+ this.runnerDiv.setAttribute("className", className);
56
+ var specs = runner.specs();
57
+ var specCount = 0;
58
+ for (var i = 0; i < specs.length; i++) {
59
+ if (this.specFilter(specs[i])) {
60
+ specCount++;
61
+ }
62
+ }
63
+ var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
64
+ message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
65
+ this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
66
+ };
67
+
68
+ jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
69
+ var results = suite.results();
70
+ var status = results.passed() ? 'passed' : 'failed';
71
+ if (results.totalCount == 0) { // todo: change this to check results.skipped
72
+ status = 'skipped';
73
+ }
74
+ this.suiteDivs[suite.getFullName()].className += " " + status;
75
+ };
76
+
77
+ jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
78
+ var results = spec.results();
79
+ var status = results.passed() ? 'passed' : 'failed';
80
+ if (results.skipped) {
81
+ status = 'skipped';
82
+ }
83
+ var specDiv = this.createDom('div', { className: 'spec ' + status },
84
+ this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
85
+ this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, spec.getFullName()));
86
+
87
+
88
+ var resultItems = results.getItems();
89
+ for (var i = 0; i < resultItems.length; i++) {
90
+ var result = resultItems[i];
91
+ if (result.passed && !result.passed()) {
92
+ specDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
93
+ specDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
94
+ }
95
+ }
96
+ this.suiteDivs[spec.suite.getFullName()].appendChild(specDiv);
97
+ };
98
+
99
+ jasmine.TrivialReporter.prototype.log = function() {
100
+ console.log.apply(console, arguments);
101
+ };
102
+
103
+ jasmine.TrivialReporter.prototype.getLocation = function() {
104
+ return this.document.location;
105
+ };
106
+
107
+ jasmine.TrivialReporter.prototype.specFilter = function(spec) {
108
+ var paramMap = {};
109
+ var params = this.getLocation().search.substring(1).split('&');
110
+ for (var i = 0; i < params.length; i++) {
111
+ var p = params[i].split('=');
112
+ paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
113
+ }
114
+
115
+ if (!paramMap["spec"]) return true;
116
+ return spec.getFullName().indexOf(paramMap["spec"]) == 0;
117
+ };
@@ -0,0 +1,28 @@
1
+ /** Console X
2
+ * http://github.com/deadlyicon/consolex.js
3
+ *
4
+ * By Jared Grippe <jared@jaredgrippe.com>
5
+ *
6
+ * Copyright (c) 2009 Jared Grippe
7
+ * Licensed under the MIT license.
8
+ *
9
+ * consolex avoids ever having to see javascript bugs in browsers that do not implement the entire
10
+ * firebug console suit
11
+ *
12
+ */
13
+ (function(window) {
14
+ window.console || (window.console = {});
15
+
16
+ var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml",
17
+ "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];
18
+
19
+ function emptyFunction(){}
20
+
21
+ for (var i = 0; i < names.length; ++i){
22
+ window.console[names[i]] || (window.console[names[i]] = emptyFunction);
23
+ if (typeof window.console[names[i]] !== 'function')
24
+ window.console[names[i]] = (function(method) {
25
+ return function(){ return Function.prototype.apply.apply(method, [console,arguments]); };
26
+ })(window.console[names[i]]);
27
+ }
28
+ })(this);