rally-jasmine-core 1.2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/lib/jasmine-core.rb +36 -0
  2. data/lib/jasmine-core/example/SpecRunner.html +54 -0
  3. data/lib/jasmine-core/example/spec/PlayerSpec.js +58 -0
  4. data/lib/jasmine-core/example/spec/SpecHelper.js +9 -0
  5. data/lib/jasmine-core/example/src/Player.js +22 -0
  6. data/lib/jasmine-core/example/src/Song.js +7 -0
  7. data/lib/jasmine-core/jasmine-html.js +681 -0
  8. data/lib/jasmine-core/jasmine.css +82 -0
  9. data/lib/jasmine-core/jasmine.js +2568 -0
  10. data/lib/jasmine-core/json2.js +478 -0
  11. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +451 -0
  12. data/lib/jasmine-core/spec/core/BaseSpec.js +27 -0
  13. data/lib/jasmine-core/spec/core/CustomMatchersSpec.js +97 -0
  14. data/lib/jasmine-core/spec/core/EnvSpec.js +159 -0
  15. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +175 -0
  16. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +103 -0
  17. data/lib/jasmine-core/spec/core/MatchersSpec.js +1145 -0
  18. data/lib/jasmine-core/spec/core/MockClockSpec.js +38 -0
  19. data/lib/jasmine-core/spec/core/MultiReporterSpec.js +45 -0
  20. data/lib/jasmine-core/spec/core/NestedResultsSpec.js +54 -0
  21. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +94 -0
  22. data/lib/jasmine-core/spec/core/QueueSpec.js +23 -0
  23. data/lib/jasmine-core/spec/core/ReporterSpec.js +56 -0
  24. data/lib/jasmine-core/spec/core/RunnerSpec.js +280 -0
  25. data/lib/jasmine-core/spec/core/SpecRunningSpec.js +1291 -0
  26. data/lib/jasmine-core/spec/core/SpecSpec.js +124 -0
  27. data/lib/jasmine-core/spec/core/SpySpec.js +216 -0
  28. data/lib/jasmine-core/spec/core/SuiteSpec.js +120 -0
  29. data/lib/jasmine-core/spec/core/UtilSpec.js +39 -0
  30. data/lib/jasmine-core/spec/core/WaitsForBlockSpec.js +118 -0
  31. data/lib/jasmine-core/spec/html/HTMLReporterSpec.js +209 -0
  32. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +38 -0
  33. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +8 -0
  34. data/lib/jasmine-core/spec/html/TrivialReporterSpec.js +239 -0
  35. data/lib/jasmine-core/spec/node_suite.js +127 -0
  36. data/lib/jasmine-core/version.rb +6 -0
  37. metadata +288 -0
@@ -0,0 +1,39 @@
1
+ describe("jasmine.util", function() {
2
+ describe("extend", function () {
3
+ it("should add properies to a destination object ", function() {
4
+ var destination = {baz: 'baz'};
5
+ jasmine.util.extend(destination, {
6
+ foo: 'foo', bar: 'bar'
7
+ });
8
+ expect(destination).toEqual({foo: 'foo', bar: 'bar', baz: 'baz'});
9
+ });
10
+
11
+ it("should replace properies that already exist on a destination object", function() {
12
+ var destination = {foo: 'foo'};
13
+ jasmine.util.extend(destination, {
14
+ foo: 'bar'
15
+ });
16
+ expect(destination).toEqual({foo: 'bar'});
17
+ jasmine.util.extend(destination, {
18
+ foo: null
19
+ });
20
+ expect(destination).toEqual({foo: null});
21
+ });
22
+ });
23
+
24
+ describe("isArray_", function() {
25
+ it("should return true if the argument is an array", function() {
26
+ expect(jasmine.isArray_([])).toBe(true);
27
+ expect(jasmine.isArray_(['a'])).toBe(true);
28
+ });
29
+
30
+ it("should return false if the argument is not an array", function() {
31
+ expect(jasmine.isArray_(undefined)).toBe(false);
32
+ expect(jasmine.isArray_({})).toBe(false);
33
+ expect(jasmine.isArray_(function() {})).toBe(false);
34
+ expect(jasmine.isArray_('foo')).toBe(false);
35
+ expect(jasmine.isArray_(5)).toBe(false);
36
+ expect(jasmine.isArray_(null)).toBe(false);
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,118 @@
1
+ describe('WaitsForBlock', function () {
2
+ var env, suite, timeout, spec, message, onComplete, fakeTimer;
3
+ beforeEach(function() {
4
+ env = new jasmine.Env();
5
+ env.updateInterval = 0;
6
+ suite = new jasmine.Suite(env, 'suite 1');
7
+ timeout = 1000;
8
+ spec = new jasmine.Spec(env, suite);
9
+ message = "some error message";
10
+ onComplete = jasmine.createSpy("onComplete");
11
+ });
12
+
13
+ describe("jasmine.VERBOSE", function() {
14
+ var jasmineVerboseOriginal;
15
+ beforeEach(function() {
16
+ jasmineVerboseOriginal = jasmine.VERBOSE;
17
+ spyOn(env.reporter, 'log');
18
+
19
+ });
20
+ it('do not show information if jasmine.VERBOSE is set to false', function () {
21
+ jasmine.VERBOSE = false;
22
+ var latchFunction = function() {
23
+ return true;
24
+ };
25
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
26
+ expect(env.reporter.log).not.toHaveBeenCalled();
27
+ block.execute(onComplete);
28
+ expect(env.reporter.log).not.toHaveBeenCalled();
29
+ jasmine.VERBOSE = jasmineVerboseOriginal;
30
+ });
31
+ it('show information if jasmine.VERBOSE is set to true', function () {
32
+ jasmine.VERBOSE = true;
33
+ var latchFunction = function() {
34
+ return true;
35
+ };
36
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
37
+ expect(env.reporter.log).not.toHaveBeenCalled();
38
+ block.execute(onComplete);
39
+ expect(env.reporter.log).toHaveBeenCalled();
40
+ jasmine.VERBOSE = jasmineVerboseOriginal;
41
+ });
42
+ });
43
+
44
+ it('onComplete should be called if the latchFunction returns true', function () {
45
+ var latchFunction = function() {
46
+ return true;
47
+ };
48
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
49
+ expect(onComplete).not.toHaveBeenCalled();
50
+ block.execute(onComplete);
51
+ expect(onComplete).toHaveBeenCalled();
52
+ });
53
+
54
+ it('latchFunction should run in same scope as spec', function () {
55
+ var result;
56
+ var latchFunction = function() {
57
+ result = this.scopedValue;
58
+ };
59
+ spec.scopedValue = 'foo';
60
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
61
+ block.execute(onComplete);
62
+ expect(result).toEqual('foo');
63
+ });
64
+
65
+ it('should fail spec and call onComplete if there is an error in the latchFunction', function() {
66
+ var latchFunction = jasmine.createSpy('latchFunction').andThrow('some error');
67
+ spyOn(spec, 'fail');
68
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
69
+ block.execute(onComplete);
70
+ expect(spec.fail).toHaveBeenCalledWith('some error');
71
+ expect(onComplete).toHaveBeenCalled();
72
+ });
73
+
74
+ describe("if latchFunction returns false", function() {
75
+ var latchFunction, fakeTimer;
76
+ beforeEach(function() {
77
+ latchFunction = jasmine.createSpy('latchFunction').andReturn(false);
78
+ fakeTimer = new jasmine.FakeTimer();
79
+ env.setTimeout = fakeTimer.setTimeout;
80
+ env.clearTimeout = fakeTimer.clearTimeout;
81
+ env.setInterval = fakeTimer.setInterval;
82
+ env.clearInterval = fakeTimer.clearInterval;
83
+ });
84
+
85
+ it('latchFunction should be retried after 10 ms', function () {
86
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
87
+ expect(latchFunction).not.toHaveBeenCalled();
88
+ block.execute(onComplete);
89
+ expect(latchFunction.callCount).toEqual(1);
90
+ fakeTimer.tick(5);
91
+ expect(latchFunction.callCount).toEqual(1);
92
+ fakeTimer.tick(5);
93
+ expect(latchFunction.callCount).toEqual(2);
94
+ });
95
+
96
+ it('onComplete should be called if latchFunction returns true before timeout', function () {
97
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
98
+ expect(onComplete).not.toHaveBeenCalled();
99
+ block.execute(onComplete);
100
+ expect(onComplete).not.toHaveBeenCalled();
101
+ latchFunction.andReturn(true);
102
+ fakeTimer.tick(100);
103
+ expect(onComplete).toHaveBeenCalled();
104
+ });
105
+
106
+ it('spec should fail with the passed message if the timeout is reached (and not call onComplete)', function () {
107
+ spyOn(spec, 'fail');
108
+ var block = new jasmine.WaitsForBlock(env, timeout, latchFunction, message, spec);
109
+ block.execute(onComplete);
110
+ expect(spec.fail).not.toHaveBeenCalled();
111
+ fakeTimer.tick(timeout);
112
+ expect(spec.fail).toHaveBeenCalled();
113
+ var failMessage = spec.fail.mostRecentCall.args[0].message;
114
+ expect(failMessage).toMatch(message);
115
+ expect(onComplete).toHaveBeenCalled();
116
+ });
117
+ });
118
+ });
@@ -0,0 +1,209 @@
1
+ describe("HtmlReporter", function() {
2
+ var env;
3
+ var htmlReporter;
4
+ var body;
5
+ var fakeDocument;
6
+
7
+ beforeEach(function() {
8
+ env = new jasmine.Env();
9
+ env.updateInterval = 0;
10
+
11
+ body = document.createElement("body");
12
+ fakeDocument = { body: body, location: { search: "" } };
13
+ htmlReporter = new jasmine.HtmlReporter(fakeDocument);
14
+ });
15
+
16
+ function fakeSpec(name) {
17
+ return {
18
+ getFullName: function() {
19
+ return name;
20
+ }
21
+ };
22
+ }
23
+
24
+ function findElements(divs, withClass) {
25
+ var els = [];
26
+ for (var i = 0; i < divs.length; i++) {
27
+ if (divs[i].className == withClass) els.push(divs[i]);
28
+ }
29
+ return els;
30
+ }
31
+
32
+ function findElement(divs, withClass) {
33
+ var els = findElements(divs, withClass);
34
+ if (els.length > 0) {
35
+ return els[0];
36
+ }
37
+ throw new Error("couldn't find div with class " + withClass);
38
+ }
39
+
40
+ it("should run only specs beginning with spec parameter", function() {
41
+ fakeDocument.location.search = "?spec=run%20this";
42
+ expect(htmlReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
43
+ expect(htmlReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy();
44
+ expect(htmlReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
45
+ });
46
+
47
+ describe("running without any specs", function() {
48
+ var runner;
49
+ beforeEach(function() {
50
+ runner = env.currentRunner();
51
+ env.addReporter(htmlReporter);
52
+ });
53
+
54
+ it("should not error", function() {
55
+ var exec = function() {
56
+ runner.execute();
57
+ };
58
+ expect(exec).not.toThrow();
59
+ });
60
+ });
61
+
62
+ describe('Matcher reporting', function() {
63
+ var getResultMessageDiv = function(body) {
64
+ var divs = body.getElementsByTagName("div");
65
+ for (var i = 0; i < divs.length; i++) {
66
+ if (divs[i].className.match(/resultMessage/)) {
67
+ return divs[i];
68
+ }
69
+ }
70
+ };
71
+
72
+ var runner, spec, fakeTimer;
73
+ beforeEach(function() {
74
+ fakeTimer = new jasmine.FakeTimer();
75
+ env.setTimeout = fakeTimer.setTimeout;
76
+ env.clearTimeout = fakeTimer.clearTimeout;
77
+ env.setInterval = fakeTimer.setInterval;
78
+ env.clearInterval = fakeTimer.clearInterval;
79
+ runner = env.currentRunner();
80
+ var suite = new jasmine.Suite(env, 'some suite');
81
+ runner.add(suite);
82
+ spec = new jasmine.Spec(env, suite, 'some spec');
83
+ suite.add(spec);
84
+ fakeDocument.location.search = "?";
85
+ env.addReporter(htmlReporter);
86
+ });
87
+
88
+ describe('toContain', function() {
89
+ it('should show actual and expected', function() {
90
+ spec.runs(function() {
91
+ this.expect('foo').toContain('bar');
92
+ });
93
+ runner.execute();
94
+ fakeTimer.tick(0);
95
+
96
+ var resultEl = getResultMessageDiv(body);
97
+ expect(resultEl.innerHTML).toMatch(/foo/);
98
+ expect(resultEl.innerHTML).toMatch(/bar/);
99
+ });
100
+ });
101
+ });
102
+
103
+ describe("failure messages (integration)", function() {
104
+ var spec, results, expectationResult;
105
+
106
+ it("should add the failure message to the DOM (non-toEquals matchers)", function() {
107
+ env.describe("suite", function() {
108
+ env.it("will have log messages", function() {
109
+ this.expect('a').toBeNull();
110
+ });
111
+ });
112
+
113
+ env.addReporter(htmlReporter);
114
+ env.execute();
115
+
116
+ var divs = body.getElementsByTagName("div");
117
+ var errorDiv = findElement(divs, 'resultMessage fail');
118
+ expect(errorDiv.innerHTML).toMatch(/Expected 'a' to be null/);
119
+ });
120
+
121
+ it("should add the failure message to the DOM (non-toEquals matchers) html escaping", function() {
122
+ env.describe("suite", function() {
123
+ env.it("will have log messages", function() {
124
+ this.expect('1 < 2').toBeNull();
125
+ });
126
+ });
127
+
128
+ env.addReporter(htmlReporter);
129
+ env.execute();
130
+
131
+ var divs = body.getElementsByTagName("div");
132
+ var errorDiv = findElement(divs, 'resultMessage fail');
133
+ expect(errorDiv.innerHTML).toMatch(/Expected '1 &lt; 2' to be null/);
134
+ });
135
+ });
136
+
137
+ describe("log messages", function() {
138
+ it("should appear in the report of a failed spec", function() {
139
+ env.describe("suite", function() {
140
+ env.it("will have log messages", function() {
141
+ this.log("this is a", "multipart log message");
142
+ this.expect(true).toBeFalsy();
143
+ });
144
+ });
145
+
146
+ env.addReporter(htmlReporter);
147
+ env.execute();
148
+
149
+ var divs = body.getElementsByTagName("div");
150
+ var errorDiv = findElement(divs, 'specDetail failed');
151
+ expect(errorDiv.innerHTML).toMatch("this is a multipart log message");
152
+ });
153
+
154
+ xit("should work on IE without console.log.apply", function() {
155
+ });
156
+ });
157
+
158
+ describe("duplicate example names", function() {
159
+ it("should report failures correctly", function() {
160
+ var suite1 = env.describe("suite", function() {
161
+ env.it("will have log messages", function() {
162
+ this.log("this one fails!");
163
+ this.expect(true).toBeFalsy();
164
+ });
165
+ });
166
+
167
+ var suite2 = env.describe("suite", function() {
168
+ env.it("will have log messages", function() {
169
+ this.log("this one passes!");
170
+ this.expect(true).toBeTruthy();
171
+ });
172
+ });
173
+
174
+ env.addReporter(htmlReporter);
175
+ env.execute();
176
+
177
+ var divs = body.getElementsByTagName("div");
178
+ var failedSpecDiv = findElement(divs, 'specDetail failed');
179
+ expect(failedSpecDiv.className).toEqual('specDetail failed');
180
+ expect(failedSpecDiv.innerHTML).toContain("this one fails!");
181
+ expect(failedSpecDiv.innerHTML).not.toContain("this one passes!");
182
+ });
183
+ });
184
+
185
+ describe('#reportSpecStarting', function() {
186
+ beforeEach(function() {
187
+ env.describe("suite 1", function() {
188
+ env.it("spec 1", function() {
189
+ });
190
+ });
191
+ spyOn(htmlReporter, 'log').andCallThrough();
192
+ });
193
+
194
+ it('DOES NOT log running specs by default', function() {
195
+ env.addReporter(htmlReporter);
196
+ env.execute();
197
+
198
+ expect(htmlReporter.log).not.toHaveBeenCalled();
199
+ });
200
+
201
+ it('logs running specs when log_running_specs is true', function() {
202
+ htmlReporter.logRunningSpecs = true;
203
+ env.addReporter(htmlReporter);
204
+ env.execute();
205
+
206
+ expect(htmlReporter.log).toHaveBeenCalledWith('>> Jasmine Running suite 1 spec 1...');
207
+ });
208
+ });
209
+ });
@@ -0,0 +1,38 @@
1
+ describe("MatchersSpec - HTML Dependent", function () {
2
+ var env, spec;
3
+
4
+ beforeEach(function() {
5
+ env = new jasmine.Env();
6
+ env.updateInterval = 0;
7
+
8
+ var suite = env.describe("suite", function() {
9
+ spec = env.it("spec", function() {
10
+ });
11
+ });
12
+ spyOn(spec, 'addMatcherResult');
13
+
14
+ this.addMatchers({
15
+ toPass: function() {
16
+ return lastResult().passed();
17
+ },
18
+ toFail: function() {
19
+ return !lastResult().passed();
20
+ }
21
+ });
22
+ });
23
+
24
+ function match(value) {
25
+ return spec.expect(value);
26
+ }
27
+
28
+ function lastResult() {
29
+ return spec.addMatcherResult.mostRecentCall.args[0];
30
+ }
31
+
32
+ it("toEqual with DOM nodes", function() {
33
+ var nodeA = document.createElement('div');
34
+ var nodeB = document.createElement('div');
35
+ expect((match(nodeA).toEqual(nodeA))).toPass();
36
+ expect((match(nodeA).toEqual(nodeB))).toFail();
37
+ });
38
+ });
@@ -0,0 +1,8 @@
1
+ describe("jasmine.pp (HTML Dependent)", function () {
2
+ it("should stringify HTML nodes properly", function() {
3
+ var sampleNode = document.createElement('div');
4
+ sampleNode.innerHTML = 'foo<b>bar</b>';
5
+ expect(jasmine.pp(sampleNode)).toEqual("HTMLNode");
6
+ expect(jasmine.pp({foo: sampleNode})).toEqual("{ foo : HTMLNode }");
7
+ });
8
+ });
@@ -0,0 +1,239 @@
1
+ describe("TrivialReporter", function() {
2
+ var env;
3
+ var trivialReporter;
4
+ var body;
5
+ var fakeDocument;
6
+
7
+ beforeEach(function() {
8
+ env = new jasmine.Env();
9
+ env.updateInterval = 0;
10
+
11
+ body = document.createElement("body");
12
+ fakeDocument = { body: body, location: { search: "" } };
13
+ trivialReporter = new jasmine.TrivialReporter(fakeDocument);
14
+ });
15
+
16
+ function fakeSpec(name) {
17
+ return {
18
+ getFullName: function() {
19
+ return name;
20
+ }
21
+ };
22
+ }
23
+
24
+ function findElements(divs, withClass) {
25
+ var els = [];
26
+ for (var i = 0; i < divs.length; i++) {
27
+ if (divs[i].className == withClass) els.push(divs[i]);
28
+ }
29
+ return els;
30
+ }
31
+
32
+ function findElement(divs, withClass) {
33
+ var els = findElements(divs, withClass);
34
+ if (els.length > 0) {
35
+ return els[0];
36
+ }
37
+ throw new Error("couldn't find div with class " + withClass);
38
+ }
39
+
40
+ it("should run only specs beginning with spec parameter", function() {
41
+ fakeDocument.location.search = "?spec=run%20this";
42
+ expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
43
+ expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy();
44
+ expect(trivialReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
45
+ });
46
+
47
+ it("should display empty divs for every suite when the runner is starting", function() {
48
+ trivialReporter.reportRunnerStarting({
49
+ env: env,
50
+ suites: function() {
51
+ return [ new jasmine.Suite({}, "suite 1", null, null) ];
52
+ }
53
+ });
54
+
55
+ var divs = findElements(body.getElementsByTagName("div"), "suite");
56
+ expect(divs.length).toEqual(1);
57
+ expect(divs[0].innerHTML).toContain("suite 1");
58
+ });
59
+
60
+ describe('Matcher reporting', function () {
61
+ var getResultMessageDiv = function (body) {
62
+ var divs = body.getElementsByTagName("div");
63
+ for (var i = 0; i < divs.length; i++) {
64
+ if (divs[i].className.match(/resultMessage/)) {
65
+ return divs[i];
66
+ }
67
+ }
68
+ };
69
+
70
+ var runner, spec, fakeTimer;
71
+ beforeEach(function () {
72
+ fakeTimer = new jasmine.FakeTimer();
73
+ env.setTimeout = fakeTimer.setTimeout;
74
+ env.clearTimeout = fakeTimer.clearTimeout;
75
+ env.setInterval = fakeTimer.setInterval;
76
+ env.clearInterval = fakeTimer.clearInterval;
77
+ runner = env.currentRunner();
78
+ var suite = new jasmine.Suite(env, 'some suite');
79
+ runner.add(suite);
80
+ spec = new jasmine.Spec(env, suite, 'some spec');
81
+ suite.add(spec);
82
+ fakeDocument.location.search = "?";
83
+ env.addReporter(trivialReporter);
84
+ });
85
+
86
+ describe('toContain', function () {
87
+ it('should show actual and expected', function () {
88
+ spec.runs(function () {
89
+ this.expect('foo').toContain('bar');
90
+ });
91
+ runner.execute();
92
+ fakeTimer.tick(0);
93
+
94
+ var resultEl = getResultMessageDiv(body);
95
+ expect(resultEl.innerHTML).toMatch(/foo/);
96
+ expect(resultEl.innerHTML).toMatch(/bar/);
97
+ });
98
+ });
99
+ });
100
+
101
+ describe("failure messages (integration)", function () {
102
+ var spec, results, expectationResult;
103
+
104
+ beforeEach(function() {
105
+ results = {
106
+ passed: function() {
107
+ return false;
108
+ },
109
+ getItems: function() {
110
+ }};
111
+
112
+ var suite1 = new jasmine.Suite(env, "suite 1", null, null);
113
+
114
+ spec = {
115
+ suite: suite1,
116
+ getFullName: function() {
117
+ return "foo";
118
+ },
119
+ results: function() {
120
+ return results;
121
+ }
122
+ };
123
+
124
+ trivialReporter.reportRunnerStarting({
125
+ env: env,
126
+ suites: function() {
127
+ return [ suite1 ];
128
+ }
129
+ });
130
+ });
131
+
132
+ it("should add the failure message to the DOM (non-toEquals matchers)", function() {
133
+ expectationResult = new jasmine.ExpectationResult({
134
+ matcherName: "toBeNull", passed: false, message: "Expected 'a' to be null, but it was not"
135
+ });
136
+
137
+ spyOn(results, 'getItems').andReturn([expectationResult]);
138
+
139
+ trivialReporter.reportSpecResults(spec);
140
+
141
+ var divs = body.getElementsByTagName("div");
142
+ var errorDiv = findElement(divs, 'resultMessage fail');
143
+ expect(errorDiv.innerHTML).toEqual("Expected 'a' to be null, but it was not");
144
+ });
145
+
146
+ it("should add the failure message to the DOM (non-toEquals matchers) html escaping", function() {
147
+ expectationResult = new jasmine.ExpectationResult({
148
+ matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
149
+ });
150
+
151
+ spyOn(results, 'getItems').andReturn([expectationResult]);
152
+
153
+ trivialReporter.reportSpecResults(spec);
154
+
155
+ var divs = body.getElementsByTagName("div");
156
+ var errorDiv = findElement(divs, 'resultMessage fail');
157
+ expect(errorDiv.innerHTML).toEqual("Expected '1 &lt; 2' to &lt;b&gt;e null, &amp; it was not");
158
+ });
159
+ });
160
+
161
+ describe("log messages", function() {
162
+ it("should appear in the report", function() {
163
+ env.describe("suite", function() {
164
+ env.it("will have log messages", function() {
165
+ this.log("this is a", "multipart log message");
166
+ });
167
+ });
168
+
169
+ env.addReporter(trivialReporter);
170
+ env.execute();
171
+
172
+ var divs = body.getElementsByTagName("div");
173
+ var errorDiv = findElement(divs, 'resultMessage log');
174
+ expect(errorDiv.innerHTML).toEqual("this is a multipart log message");
175
+ });
176
+
177
+ xit("should work on IE without console.log.apply", function() {
178
+ });
179
+ });
180
+
181
+ describe("duplicate example names", function() {
182
+ it("should report failures correctly", function() {
183
+ var suite1 = env.describe("suite", function() {
184
+ env.it("will have log messages", function() {
185
+ this.log("this one fails!");
186
+ this.expect(true).toBeFalsy();
187
+ });
188
+ });
189
+
190
+ var suite2 = env.describe("suite", function() {
191
+ env.it("will have log messages", function() {
192
+ this.log("this one passes!");
193
+ this.expect(true).toBeTruthy();
194
+ });
195
+ });
196
+
197
+ env.addReporter(trivialReporter);
198
+ env.execute();
199
+
200
+ var divs = body.getElementsByTagName("div");
201
+ var passedSpecDiv = findElement(divs, 'suite passed');
202
+ expect(passedSpecDiv.className).toEqual('suite passed');
203
+ expect(passedSpecDiv.innerHTML).toContain("this one passes!");
204
+ expect(passedSpecDiv.innerHTML).not.toContain("this one fails!");
205
+
206
+ var failedSpecDiv = findElement(divs, 'suite failed');
207
+ expect(failedSpecDiv.className).toEqual('suite failed');
208
+ expect(failedSpecDiv.innerHTML).toContain("this one fails!");
209
+ expect(failedSpecDiv.innerHTML).not.toContain("this one passes!");
210
+ });
211
+ });
212
+
213
+ describe('#reportSpecStarting', function() {
214
+ var spec1;
215
+ beforeEach(function () {
216
+ env.describe("suite 1", function() {
217
+ spec1 = env.it("spec 1", function() {
218
+ });
219
+ });
220
+ });
221
+
222
+ it('DOES NOT log running specs by default', function() {
223
+ spyOn(trivialReporter, 'log');
224
+
225
+ trivialReporter.reportSpecStarting(spec1);
226
+
227
+ expect(trivialReporter.log).not.toHaveBeenCalled();
228
+ });
229
+
230
+ it('logs running specs when log_running_specs is true', function() {
231
+ trivialReporter.logRunningSpecs = true;
232
+ spyOn(trivialReporter, 'log');
233
+
234
+ trivialReporter.reportSpecStarting(spec1);
235
+
236
+ expect(trivialReporter.log).toHaveBeenCalledWith('>> Jasmine Running suite 1 spec 1...');
237
+ });
238
+ });
239
+ });