jasmine-core 1.3.1 → 2.0.0.rc2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/jasmine-core.rb +14 -1
- data/lib/jasmine-core/boot.js +131 -0
- data/lib/jasmine-core/boot/boot.js +109 -0
- data/lib/jasmine-core/example/spec/PlayerSpec.js +2 -2
- data/lib/jasmine-core/example/spec/SpecHelper.js +14 -8
- data/lib/jasmine-core/jasmine-html.js +289 -616
- data/lib/jasmine-core/jasmine.css +52 -80
- data/lib/jasmine-core/jasmine.js +1972 -2211
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +161 -386
- data/lib/jasmine-core/spec/core/AnySpec.js +45 -0
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +105 -0
- data/lib/jasmine-core/spec/core/ClockSpec.js +314 -0
- data/lib/jasmine-core/spec/core/CustomMatchersSpec.js +96 -97
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +179 -0
- data/lib/jasmine-core/spec/core/EnvSpec.js +454 -102
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +56 -0
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +15 -126
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +61 -0
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +320 -0
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +150 -38
- data/lib/jasmine-core/spec/core/ObjectContainingSpec.js +64 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +43 -42
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +147 -0
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +40 -0
- data/lib/jasmine-core/spec/core/SpecRunningSpec.js +92 -1075
- data/lib/jasmine-core/spec/core/SpecSpec.js +215 -95
- data/lib/jasmine-core/spec/core/SpySpec.js +28 -196
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +101 -0
- data/lib/jasmine-core/spec/core/SuiteSpec.js +216 -106
- data/lib/jasmine-core/spec/core/TimerSpec.js +13 -0
- data/lib/jasmine-core/spec/core/UtilSpec.js +19 -30
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +219 -0
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +51 -0
- data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +18 -0
- data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +38 -0
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +19 -0
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +20 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +36 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +38 -0
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +17 -0
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +24 -0
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +28 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +46 -0
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +57 -0
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +34 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +280 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +98 -0
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +19 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +494 -0
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +18 -0
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +8 -8
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +3 -3
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +43 -0
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +62 -0
- data/lib/jasmine-core/spec/node_suite.js +137 -79
- data/lib/jasmine-core/spec/performance/performance_test.js +10 -0
- data/lib/jasmine-core/spec/support/dev_boot.js +118 -0
- data/lib/jasmine-core/version.rb +5 -2
- metadata +47 -103
- data/lib/jasmine-core/example/SpecRunner.html +0 -54
- data/lib/jasmine-core/spec/core/BaseSpec.js +0 -27
- data/lib/jasmine-core/spec/core/MatchersSpec.js +0 -1157
- data/lib/jasmine-core/spec/core/MockClockSpec.js +0 -38
- data/lib/jasmine-core/spec/core/MultiReporterSpec.js +0 -45
- data/lib/jasmine-core/spec/core/NestedResultsSpec.js +0 -54
- data/lib/jasmine-core/spec/core/QueueSpec.js +0 -23
- data/lib/jasmine-core/spec/core/ReporterSpec.js +0 -56
- data/lib/jasmine-core/spec/core/RunnerSpec.js +0 -280
- data/lib/jasmine-core/spec/core/WaitsForBlockSpec.js +0 -118
- data/lib/jasmine-core/spec/html/HTMLReporterSpec.js +0 -209
- data/lib/jasmine-core/spec/html/TrivialReporterSpec.js +0 -239
@@ -0,0 +1,98 @@
|
|
1
|
+
describe("toThrow", function() {
|
2
|
+
it("throws an error when the actual is not a function", function() {
|
3
|
+
var matcher = j$.matchers.toThrow();
|
4
|
+
|
5
|
+
expect(function() {
|
6
|
+
matcher.compare({});
|
7
|
+
}).toThrow(new Error("Actual is not a Function")); // TODO: this needs to change for self-test
|
8
|
+
});
|
9
|
+
|
10
|
+
it("fails if actual does not throw", function() {
|
11
|
+
var matcher = j$.matchers.toThrow(),
|
12
|
+
fn = function() {
|
13
|
+
return true;
|
14
|
+
},
|
15
|
+
result;
|
16
|
+
|
17
|
+
result = matcher.compare(fn);
|
18
|
+
|
19
|
+
expect(result.pass).toBe(false);
|
20
|
+
expect(result.message).toEqual("Expected function to throw an exception.");
|
21
|
+
});
|
22
|
+
|
23
|
+
it("passes if it throws but there is no expected", function() {
|
24
|
+
var util = {
|
25
|
+
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
|
26
|
+
},
|
27
|
+
matcher = j$.matchers.toThrow(util),
|
28
|
+
fn = function() {
|
29
|
+
throw 5;
|
30
|
+
},
|
31
|
+
result;
|
32
|
+
|
33
|
+
result = matcher.compare(fn);
|
34
|
+
|
35
|
+
expect(result.pass).toBe(true);
|
36
|
+
expect(result.message).toEqual("Expected function not to throw, but it threw 5.");
|
37
|
+
});
|
38
|
+
|
39
|
+
it("passes even if what is thrown is falsy", function() {
|
40
|
+
var matcher = j$.matchers.toThrow(),
|
41
|
+
fn = function() {
|
42
|
+
throw undefined;
|
43
|
+
},
|
44
|
+
result;
|
45
|
+
|
46
|
+
result = matcher.compare(fn);
|
47
|
+
expect(result.pass).toBe(true);
|
48
|
+
expect(result.message).toEqual("Expected function not to throw, but it threw undefined.");
|
49
|
+
});
|
50
|
+
|
51
|
+
it("passes if what is thrown is equivalent to what is expected", function() {
|
52
|
+
var util = {
|
53
|
+
equals: jasmine.createSpy('delegated-equal').and.callReturn(true)
|
54
|
+
},
|
55
|
+
matcher = j$.matchers.toThrow(util),
|
56
|
+
fn = function() {
|
57
|
+
throw 5;
|
58
|
+
},
|
59
|
+
result;
|
60
|
+
|
61
|
+
result = matcher.compare(fn, 5);
|
62
|
+
|
63
|
+
expect(result.pass).toBe(true);
|
64
|
+
expect(result.message).toEqual("Expected function not to throw 5.");
|
65
|
+
});
|
66
|
+
|
67
|
+
it("fails if what is thrown is not equivalent to what is expected", function() {
|
68
|
+
var util = {
|
69
|
+
equals: jasmine.createSpy('delegated-equal').and.callReturn(false)
|
70
|
+
},
|
71
|
+
matcher = j$.matchers.toThrow(util),
|
72
|
+
fn = function() {
|
73
|
+
throw 5;
|
74
|
+
},
|
75
|
+
result;
|
76
|
+
|
77
|
+
result = matcher.compare(fn, "foo");
|
78
|
+
|
79
|
+
expect(result.pass).toBe(false);
|
80
|
+
expect(result.message).toEqual("Expected function to throw 'foo', but it threw 5.");
|
81
|
+
});
|
82
|
+
|
83
|
+
it("fails if what is thrown is not equivalent to undefined", function() {
|
84
|
+
var util = {
|
85
|
+
equals: jasmine.createSpy('delegated-equal').and.callReturn(false)
|
86
|
+
},
|
87
|
+
matcher = j$.matchers.toThrow(util),
|
88
|
+
fn = function() {
|
89
|
+
throw 5;
|
90
|
+
},
|
91
|
+
result;
|
92
|
+
|
93
|
+
result = matcher.compare(fn, void 0);
|
94
|
+
|
95
|
+
expect(result.pass).toBe(false);
|
96
|
+
expect(result.message).toEqual("Expected function to throw undefined, but it threw 5.");
|
97
|
+
});
|
98
|
+
});
|
@@ -0,0 +1,19 @@
|
|
1
|
+
(function(env) {
|
2
|
+
env.ieVersion = (function() {
|
3
|
+
var userAgent = jasmine.getGlobal().navigator.userAgent;
|
4
|
+
if (!userAgent) { return Number.MAX_VALUE; }
|
5
|
+
|
6
|
+
var match = /MSIE ([0-9]{1,}[\.0-9]{0,})/.exec(userAgent);
|
7
|
+
|
8
|
+
return match ? parseFloat(match[1]) : Number.MAX_VALUE;
|
9
|
+
})();
|
10
|
+
|
11
|
+
env.safariVersion = (function() {
|
12
|
+
var userAgent = jasmine.getGlobal().navigator.userAgent;
|
13
|
+
if (!userAgent) { return Number.MAX_VALUE; }
|
14
|
+
|
15
|
+
var match = /Safari/.exec(userAgent) && /Version\/([0-9]{0,})/.exec(userAgent);
|
16
|
+
|
17
|
+
return match ? parseFloat(match[1]) : Number.MAX_VALUE;
|
18
|
+
})();
|
19
|
+
})(jasmine.getEnv());
|
@@ -0,0 +1,494 @@
|
|
1
|
+
describe("New HtmlReporter", function() {
|
2
|
+
// TODO: Figure out why this isn't rendering...
|
3
|
+
it("builds the initial DOM elements, including the title banner", function() {
|
4
|
+
var env = new j$.Env(),
|
5
|
+
container = document.createElement("div"),
|
6
|
+
getContainer = function() { return container; },
|
7
|
+
reporter = new j$.HtmlReporter({
|
8
|
+
env: env,
|
9
|
+
getContainer: getContainer,
|
10
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
11
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
12
|
+
});
|
13
|
+
reporter.initialize();
|
14
|
+
|
15
|
+
// Main top-level elements
|
16
|
+
expect(container.querySelector("div.html-reporter")).toBeTruthy();
|
17
|
+
expect(container.querySelector("div.banner")).toBeTruthy();
|
18
|
+
expect(container.querySelector("div.alert")).toBeTruthy();
|
19
|
+
expect(container.querySelector("div.results")).toBeTruthy();
|
20
|
+
|
21
|
+
expect(container.querySelector("ul.symbol-summary")).toBeTruthy();
|
22
|
+
|
23
|
+
// title banner
|
24
|
+
var banner = container.querySelector(".banner");
|
25
|
+
|
26
|
+
var title = banner.querySelector(".title");
|
27
|
+
expect(title.innerHTML).toMatch(/Jasmine/);
|
28
|
+
|
29
|
+
var version = banner.querySelector(".version"),
|
30
|
+
versionText = 'textContent' in version ? version.textContent : version.innerText;
|
31
|
+
expect(versionText).toEqual(j$.version);
|
32
|
+
});
|
33
|
+
|
34
|
+
it("starts the timer when jasmine begins", function() {
|
35
|
+
var env = new jasmine.Env(),
|
36
|
+
startTimerSpy = jasmine.createSpy("start-timer-spy"),
|
37
|
+
reporter = new jasmine.HtmlReporter({
|
38
|
+
env: env,
|
39
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
40
|
+
timer: { start: startTimerSpy }
|
41
|
+
});
|
42
|
+
|
43
|
+
reporter.jasmineStarted({});
|
44
|
+
|
45
|
+
expect(startTimerSpy).toHaveBeenCalled();
|
46
|
+
});
|
47
|
+
|
48
|
+
describe("when a spec is done", function() {
|
49
|
+
it("reports the status symbol of a disabled spec", function() {
|
50
|
+
var env = new j$.Env(),
|
51
|
+
container = document.createElement("div"),
|
52
|
+
getContainer = function() { return container; },
|
53
|
+
reporter = new j$.HtmlReporter({
|
54
|
+
env: env,
|
55
|
+
getContainer: getContainer,
|
56
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
57
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
58
|
+
});
|
59
|
+
reporter.initialize();
|
60
|
+
|
61
|
+
reporter.specDone({id: 789, status: "disabled", fullName: "symbols should have titles"});
|
62
|
+
|
63
|
+
var specEl = container.querySelector('.symbol-summary li');
|
64
|
+
expect(specEl.getAttribute("class")).toEqual("disabled");
|
65
|
+
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
66
|
+
expect(specEl.getAttribute("title")).toEqual("symbols should have titles");
|
67
|
+
});
|
68
|
+
|
69
|
+
it("reports the status symbol of a pending spec", function() {
|
70
|
+
var env = new j$.Env(),
|
71
|
+
container = document.createElement("div"),
|
72
|
+
getContainer = function() { return container; },
|
73
|
+
reporter = new j$.HtmlReporter({
|
74
|
+
env: env,
|
75
|
+
getContainer: getContainer,
|
76
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
77
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
78
|
+
});
|
79
|
+
reporter.initialize();
|
80
|
+
|
81
|
+
reporter.specDone({id: 789, status: "pending"});
|
82
|
+
|
83
|
+
var specEl = container.querySelector('.symbol-summary li');
|
84
|
+
expect(specEl.getAttribute("class")).toEqual("pending");
|
85
|
+
expect(specEl.getAttribute("id")).toEqual("spec_789");
|
86
|
+
});
|
87
|
+
|
88
|
+
it("reports the status symbol of a passing spec", function() {
|
89
|
+
var env = new j$.Env(),
|
90
|
+
container = document.createElement("div"),
|
91
|
+
getContainer = function() { return container; },
|
92
|
+
reporter = new j$.HtmlReporter({
|
93
|
+
env: env,
|
94
|
+
getContainer: getContainer,
|
95
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
96
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
97
|
+
});
|
98
|
+
reporter.initialize();
|
99
|
+
|
100
|
+
reporter.specDone({id: 123, status: "passed"});
|
101
|
+
|
102
|
+
var statuses = container.querySelector(".symbol-summary");
|
103
|
+
var specEl = statuses.querySelector("li");
|
104
|
+
expect(specEl.getAttribute("class")).toEqual("passed");
|
105
|
+
expect(specEl.getAttribute("id")).toEqual("spec_123");
|
106
|
+
});
|
107
|
+
|
108
|
+
it("reports the status symbol of a failing spec", function() {
|
109
|
+
var env = new j$.Env(),
|
110
|
+
container = document.createElement("div"),
|
111
|
+
getContainer = function() { return container; },
|
112
|
+
reporter = new j$.HtmlReporter({
|
113
|
+
env: env,
|
114
|
+
getContainer: getContainer,
|
115
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
116
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
117
|
+
});
|
118
|
+
|
119
|
+
reporter.initialize();
|
120
|
+
|
121
|
+
reporter.specDone({
|
122
|
+
id: 345,
|
123
|
+
status: "failed",
|
124
|
+
failedExpectations: []
|
125
|
+
});
|
126
|
+
|
127
|
+
var specEl = container.querySelector(".symbol-summary li");
|
128
|
+
expect(specEl.getAttribute("class")).toEqual("failed");
|
129
|
+
expect(specEl.getAttribute("id")).toEqual("spec_345");
|
130
|
+
});
|
131
|
+
});
|
132
|
+
|
133
|
+
describe("when Jasmine is done", function() {
|
134
|
+
it("reports the run time", function() {
|
135
|
+
var env = new j$.Env(),
|
136
|
+
container = document.createElement("div"),
|
137
|
+
timer = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
138
|
+
getContainer = function() { return container; },
|
139
|
+
reporter = new j$.HtmlReporter({
|
140
|
+
env: env,
|
141
|
+
getContainer: getContainer,
|
142
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
143
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
144
|
+
timer: timer
|
145
|
+
});
|
146
|
+
|
147
|
+
reporter.initialize();
|
148
|
+
|
149
|
+
reporter.jasmineStarted({});
|
150
|
+
|
151
|
+
timer.elapsed.and.callReturn(100);
|
152
|
+
reporter.jasmineDone();
|
153
|
+
|
154
|
+
var duration = container.querySelector(".banner .duration");
|
155
|
+
expect(duration.innerHTML).toMatch(/finished in 0.1s/);
|
156
|
+
});
|
157
|
+
|
158
|
+
it("reports the suite and spec names with status", function() {
|
159
|
+
var env = new j$.Env(),
|
160
|
+
container = document.createElement("div"),
|
161
|
+
getContainer = function() { return container; },
|
162
|
+
reporter = new j$.HtmlReporter({
|
163
|
+
env: env,
|
164
|
+
getContainer: getContainer,
|
165
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
166
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
167
|
+
});
|
168
|
+
reporter.initialize();
|
169
|
+
|
170
|
+
reporter.jasmineStarted({});
|
171
|
+
reporter.suiteStarted({
|
172
|
+
id: 1,
|
173
|
+
description: "A Suite",
|
174
|
+
fullName: "A Suite"
|
175
|
+
});
|
176
|
+
|
177
|
+
var specResult = {
|
178
|
+
id: 123,
|
179
|
+
description: "with a spec",
|
180
|
+
fullName: "A Suite with a spec",
|
181
|
+
status: "passed"
|
182
|
+
};
|
183
|
+
reporter.specStarted(specResult);
|
184
|
+
reporter.specDone(specResult);
|
185
|
+
|
186
|
+
reporter.suiteStarted({
|
187
|
+
id: 2,
|
188
|
+
description: "inner suite",
|
189
|
+
fullName: "A Suite inner suite"
|
190
|
+
});
|
191
|
+
|
192
|
+
var specResult = {
|
193
|
+
id: 124,
|
194
|
+
description: "with another spec",
|
195
|
+
fullName: "A Suite inner suite with another spec",
|
196
|
+
status: "passed"
|
197
|
+
};
|
198
|
+
reporter.specStarted(specResult);
|
199
|
+
reporter.specDone(specResult);
|
200
|
+
|
201
|
+
reporter.suiteDone({id: 2});
|
202
|
+
|
203
|
+
specResult = {
|
204
|
+
id: 209,
|
205
|
+
description: "with a failing spec",
|
206
|
+
fullName: "A Suite inner with a failing spec",
|
207
|
+
status: "failed",
|
208
|
+
failedExpectations: []
|
209
|
+
};
|
210
|
+
reporter.specStarted(specResult);
|
211
|
+
reporter.specDone(specResult);
|
212
|
+
|
213
|
+
reporter.suiteDone({id: 1});
|
214
|
+
|
215
|
+
reporter.jasmineDone({});
|
216
|
+
var summary = container.querySelector(".summary");
|
217
|
+
|
218
|
+
expect(summary.childNodes.length).toEqual(1);
|
219
|
+
|
220
|
+
var outerSuite = summary.childNodes[0];
|
221
|
+
expect(outerSuite.childNodes.length).toEqual(4);
|
222
|
+
|
223
|
+
var classes = [];
|
224
|
+
for (var i = 0; i < outerSuite.childNodes.length; i++) {
|
225
|
+
var node = outerSuite.childNodes[i];
|
226
|
+
classes.push(node.getAttribute("class"));
|
227
|
+
}
|
228
|
+
expect(classes).toEqual(["suite-detail", "specs", "suite", "specs"]);
|
229
|
+
|
230
|
+
var suiteDetail = outerSuite.childNodes[0];
|
231
|
+
var suiteLink = suiteDetail.childNodes[0];
|
232
|
+
expect(suiteLink.innerHTML).toEqual("A Suite");
|
233
|
+
expect(suiteLink.getAttribute('href')).toEqual("?spec=A%20Suite");
|
234
|
+
|
235
|
+
var specs = outerSuite.childNodes[1];
|
236
|
+
var spec = specs.childNodes[0];
|
237
|
+
expect(spec.getAttribute("class")).toEqual("passed");
|
238
|
+
expect(spec.getAttribute("id")).toEqual("spec-123");
|
239
|
+
|
240
|
+
var specLink = spec.childNodes[0];
|
241
|
+
expect(specLink.innerHTML).toEqual("with a spec");
|
242
|
+
expect(specLink.getAttribute("href")).toEqual("?spec=A%20Suite%20with%20a%20spec");
|
243
|
+
// expect(specLink.getAttribute("title")).toEqual("A Suite with a spec");
|
244
|
+
});
|
245
|
+
|
246
|
+
describe("UI for raising/catching exceptions", function() {
|
247
|
+
it("should be unchecked if the env is catching", function() {
|
248
|
+
var env = new j$.Env(),
|
249
|
+
container = document.createElement("div"),
|
250
|
+
getContainer = function() {
|
251
|
+
return container;
|
252
|
+
},
|
253
|
+
reporter = new j$.HtmlReporter({
|
254
|
+
env: env,
|
255
|
+
getContainer: getContainer,
|
256
|
+
createElement: function() {
|
257
|
+
return document.createElement.apply(document, arguments);
|
258
|
+
},
|
259
|
+
createTextNode: function() {
|
260
|
+
return document.createTextNode.apply(document, arguments);
|
261
|
+
}
|
262
|
+
});
|
263
|
+
|
264
|
+
reporter.initialize();
|
265
|
+
reporter.jasmineDone({});
|
266
|
+
|
267
|
+
var raisingExceptionsUI = container.querySelector(".raise");
|
268
|
+
expect(raisingExceptionsUI.checked).toBe(false);
|
269
|
+
});
|
270
|
+
|
271
|
+
it("should be checked if the env is not catching", function() {
|
272
|
+
var env = new j$.Env(),
|
273
|
+
container = document.createElement("div"),
|
274
|
+
getContainer = function() {
|
275
|
+
return container;
|
276
|
+
},
|
277
|
+
reporter = new j$.HtmlReporter({
|
278
|
+
env: env,
|
279
|
+
getContainer: getContainer,
|
280
|
+
createElement: function() {
|
281
|
+
return document.createElement.apply(document, arguments);
|
282
|
+
},
|
283
|
+
createTextNode: function() {
|
284
|
+
return document.createTextNode.apply(document, arguments);
|
285
|
+
}
|
286
|
+
});
|
287
|
+
|
288
|
+
reporter.initialize();
|
289
|
+
env.catchExceptions(false);
|
290
|
+
reporter.jasmineDone({});
|
291
|
+
|
292
|
+
var raisingExceptionsUI = container.querySelector(".raise");
|
293
|
+
expect(raisingExceptionsUI.checked).toBe(true);
|
294
|
+
});
|
295
|
+
|
296
|
+
it("should affect the query param for catching exceptions", function() {
|
297
|
+
var env = new j$.Env(),
|
298
|
+
container = document.createElement("div"),
|
299
|
+
exceptionsClickHandler = jasmine.createSpy("raise exceptions checked"),
|
300
|
+
getContainer = function() {
|
301
|
+
return container;
|
302
|
+
},
|
303
|
+
reporter = new j$.HtmlReporter({
|
304
|
+
env: env,
|
305
|
+
getContainer: getContainer,
|
306
|
+
onRaiseExceptionsClick: exceptionsClickHandler,
|
307
|
+
createElement: function() {
|
308
|
+
return document.createElement.apply(document, arguments);
|
309
|
+
},
|
310
|
+
createTextNode: function() {
|
311
|
+
return document.createTextNode.apply(document, arguments);
|
312
|
+
}
|
313
|
+
});
|
314
|
+
|
315
|
+
reporter.initialize();
|
316
|
+
reporter.jasmineDone({});
|
317
|
+
|
318
|
+
var input = container.querySelector(".raise");
|
319
|
+
input.click();
|
320
|
+
expect(exceptionsClickHandler).toHaveBeenCalled();
|
321
|
+
});
|
322
|
+
});
|
323
|
+
|
324
|
+
describe("and all specs pass", function() {
|
325
|
+
var env, container, reporter;
|
326
|
+
beforeEach(function() {
|
327
|
+
env = new j$.Env();
|
328
|
+
container = document.createElement("div");
|
329
|
+
getContainer = function() { return container; },
|
330
|
+
reporter = new j$.HtmlReporter({
|
331
|
+
env: env,
|
332
|
+
getContainer: getContainer,
|
333
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
334
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
335
|
+
});
|
336
|
+
reporter.initialize();
|
337
|
+
|
338
|
+
reporter.jasmineStarted({});
|
339
|
+
reporter.specDone({
|
340
|
+
id: 123,
|
341
|
+
description: "with a spec",
|
342
|
+
fullName: "A Suite with a spec",
|
343
|
+
status: "passed"
|
344
|
+
});
|
345
|
+
reporter.specDone({
|
346
|
+
id: 124,
|
347
|
+
description: "with another spec",
|
348
|
+
fullName: "A Suite inner suite with another spec",
|
349
|
+
status: "passed"
|
350
|
+
});
|
351
|
+
reporter.jasmineDone({});
|
352
|
+
});
|
353
|
+
|
354
|
+
it("reports the specs counts", function() {
|
355
|
+
var alertBars = container.querySelectorAll(".alert .bar");
|
356
|
+
|
357
|
+
expect(alertBars.length).toEqual(1);
|
358
|
+
expect(alertBars[0].getAttribute('class')).toMatch(/passed/);
|
359
|
+
expect(alertBars[0].innerHTML).toMatch(/2 specs, 0 failures/);
|
360
|
+
});
|
361
|
+
|
362
|
+
it("reports no failure details", function() {
|
363
|
+
var specFailure = container.querySelector(".failures");
|
364
|
+
|
365
|
+
expect(specFailure.childNodes.length).toEqual(0);
|
366
|
+
});
|
367
|
+
|
368
|
+
it("reports no pending specs", function() {
|
369
|
+
var alertBar = container.querySelector(".alert .bar");
|
370
|
+
|
371
|
+
expect(alertBar.innerHTML).not.toMatch(/pending spec[s]/);
|
372
|
+
});
|
373
|
+
});
|
374
|
+
|
375
|
+
describe("and there are pending specs", function() {
|
376
|
+
var env, container, reporter;
|
377
|
+
beforeEach(function() {
|
378
|
+
env = new j$.Env();
|
379
|
+
container = document.createElement("div");
|
380
|
+
getContainer = function() { return container; },
|
381
|
+
reporter = new j$.HtmlReporter({
|
382
|
+
env: env,
|
383
|
+
getContainer: getContainer,
|
384
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
385
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
386
|
+
});
|
387
|
+
reporter.initialize();
|
388
|
+
|
389
|
+
reporter.jasmineStarted({});
|
390
|
+
reporter.specDone({
|
391
|
+
id: 123,
|
392
|
+
description: "with a spec",
|
393
|
+
fullName: "A Suite with a spec",
|
394
|
+
status: "pending"
|
395
|
+
});
|
396
|
+
reporter.jasmineDone({});
|
397
|
+
});
|
398
|
+
|
399
|
+
it("reports the pending specs count", function() {
|
400
|
+
var alertBar = container.querySelector(".alert .bar");
|
401
|
+
|
402
|
+
expect(alertBar.innerHTML).toMatch(/1 spec, 0 failures, 1 pending spec/);
|
403
|
+
});
|
404
|
+
|
405
|
+
it("reports no failure details", function() {
|
406
|
+
var specFailure = container.querySelector(".failures");
|
407
|
+
|
408
|
+
expect(specFailure.childNodes.length).toEqual(0);
|
409
|
+
});
|
410
|
+
});
|
411
|
+
|
412
|
+
describe("and some tests fail", function() {
|
413
|
+
var env, container, reporter;
|
414
|
+
|
415
|
+
beforeEach(function() {
|
416
|
+
env = new j$.Env();
|
417
|
+
container = document.createElement("div"),
|
418
|
+
getContainer = function() { return container; },
|
419
|
+
reporter = new j$.HtmlReporter({
|
420
|
+
env: env,
|
421
|
+
getContainer: getContainer,
|
422
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
423
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); }
|
424
|
+
});
|
425
|
+
reporter.initialize();
|
426
|
+
|
427
|
+
reporter.jasmineStarted({});
|
428
|
+
|
429
|
+
var passingResult = {id: 123, status: "passed"};
|
430
|
+
reporter.specStarted(passingResult);
|
431
|
+
reporter.specDone(passingResult);
|
432
|
+
|
433
|
+
var failingResult = {
|
434
|
+
id: 124,
|
435
|
+
status: "failed",
|
436
|
+
description: "a failing spec",
|
437
|
+
fullName: "a suite with a failing spec",
|
438
|
+
failedExpectations: [
|
439
|
+
{
|
440
|
+
message: "a failure message",
|
441
|
+
stack: "a stack trace"
|
442
|
+
}
|
443
|
+
]
|
444
|
+
};
|
445
|
+
reporter.specStarted(failingResult);
|
446
|
+
reporter.specDone(failingResult);
|
447
|
+
reporter.jasmineDone({});
|
448
|
+
});
|
449
|
+
|
450
|
+
it("reports the specs counts", function() {
|
451
|
+
var alertBar = container.querySelector(".alert .bar");
|
452
|
+
|
453
|
+
expect(alertBar.getAttribute('class')).toMatch(/failed/);
|
454
|
+
expect(alertBar.innerHTML).toMatch(/2 specs, 1 failure/);
|
455
|
+
});
|
456
|
+
|
457
|
+
it("reports failure messages and stack traces", function() {
|
458
|
+
var specFailures = container.querySelector(".failures");
|
459
|
+
|
460
|
+
var failure = specFailures.childNodes[0];
|
461
|
+
expect(failure.getAttribute("class")).toMatch(/failed/);
|
462
|
+
expect(failure.getAttribute("class")).toMatch(/spec-detail/);
|
463
|
+
|
464
|
+
var specLink = failure.childNodes[0];
|
465
|
+
expect(specLink.getAttribute("class")).toEqual("description");
|
466
|
+
expect(specLink.getAttribute("title")).toEqual("a suite with a failing spec");
|
467
|
+
expect(specLink.getAttribute("href")).toEqual("?spec=a%20suite%20with%20a%20failing%20spec");
|
468
|
+
|
469
|
+
var message = failure.childNodes[1].childNodes[0];
|
470
|
+
expect(message.getAttribute("class")).toEqual("result-message");
|
471
|
+
expect(message.innerHTML).toEqual("a failure message");
|
472
|
+
|
473
|
+
var stackTrace = failure.childNodes[1].childNodes[1];
|
474
|
+
expect(stackTrace.getAttribute("class")).toEqual("stack-trace");
|
475
|
+
expect(stackTrace.innerHTML).toEqual("a stack trace");
|
476
|
+
});
|
477
|
+
|
478
|
+
it("allows switching between failure details and the spec summary", function() {
|
479
|
+
var menuBar = container.querySelectorAll(".bar")[1];
|
480
|
+
|
481
|
+
expect(menuBar.getAttribute("class")).not.toMatch(/hidden/);
|
482
|
+
|
483
|
+
var link = menuBar.querySelector('a');
|
484
|
+
expect(link.innerHTML).toEqual("Failures");
|
485
|
+
expect(link.getAttribute("href")).toEqual("#");
|
486
|
+
});
|
487
|
+
|
488
|
+
it("sets the reporter to 'Failures List' mode", function() {
|
489
|
+
var reporterNode = container.querySelector(".html-reporter");
|
490
|
+
expect(reporterNode.getAttribute("class")).toMatch("failure-list");
|
491
|
+
});
|
492
|
+
});
|
493
|
+
});
|
494
|
+
});
|