jasmine-core 1.3.1 → 2.0.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/jasmine-core.rb
CHANGED
@@ -6,7 +6,7 @@ module Jasmine
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def js_files
|
9
|
-
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq
|
9
|
+
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq - boot_files
|
10
10
|
end
|
11
11
|
|
12
12
|
SPEC_TYPES = ["core", "html", "node"]
|
@@ -23,6 +23,14 @@ module Jasmine
|
|
23
23
|
spec_files("node")
|
24
24
|
end
|
25
25
|
|
26
|
+
def boot_files
|
27
|
+
["boot.js"]
|
28
|
+
end
|
29
|
+
|
30
|
+
def boot_dir
|
31
|
+
File.join(path, 'boot')
|
32
|
+
end
|
33
|
+
|
26
34
|
def spec_files(type)
|
27
35
|
raise ArgumentError.new("Unrecognized spec type") unless SPEC_TYPES.include?(type)
|
28
36
|
(Dir.glob(File.join(path, "spec", type, "*.js"))).map { |f| File.join("spec", type, File.basename(f)) }.uniq
|
@@ -31,6 +39,11 @@ module Jasmine
|
|
31
39
|
def css_files
|
32
40
|
Dir.glob(File.join(path, "*.css")).map { |f| File.basename(f) }
|
33
41
|
end
|
42
|
+
|
43
|
+
def images_dir
|
44
|
+
File.join(File.dirname(__FILE__), '../images')
|
45
|
+
end
|
46
|
+
|
34
47
|
end
|
35
48
|
end
|
36
49
|
end
|
@@ -0,0 +1,131 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008-2013 Pivotal Labs
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
// Jasmine boot.js for browser runners - exposes external/global interface, builds the Jasmine environment and executes it.
|
24
|
+
(function() {
|
25
|
+
window.jasmine = jasmineRequire.core(jasmineRequire);
|
26
|
+
jasmineRequire.html(jasmine);
|
27
|
+
|
28
|
+
var env = jasmine.getEnv();
|
29
|
+
|
30
|
+
var jasmineInterface = {
|
31
|
+
describe: function(description, specDefinitions) {
|
32
|
+
return env.describe(description, specDefinitions);
|
33
|
+
},
|
34
|
+
|
35
|
+
xdescribe: function(description, specDefinitions) {
|
36
|
+
return env.xdescribe(description, specDefinitions);
|
37
|
+
},
|
38
|
+
|
39
|
+
it: function(desc, func) {
|
40
|
+
return env.it(desc, func);
|
41
|
+
},
|
42
|
+
|
43
|
+
xit: function(desc, func) {
|
44
|
+
return env.xit(desc, func);
|
45
|
+
},
|
46
|
+
|
47
|
+
beforeEach: function(beforeEachFunction) {
|
48
|
+
return env.beforeEach(beforeEachFunction);
|
49
|
+
},
|
50
|
+
|
51
|
+
afterEach: function(afterEachFunction) {
|
52
|
+
return env.afterEach(afterEachFunction);
|
53
|
+
},
|
54
|
+
|
55
|
+
expect: function(actual) {
|
56
|
+
return env.expect(actual);
|
57
|
+
},
|
58
|
+
|
59
|
+
pending: function() {
|
60
|
+
return env.pending();
|
61
|
+
},
|
62
|
+
|
63
|
+
addMatchers: function(matchers) {
|
64
|
+
return env.addMatchers(matchers);
|
65
|
+
},
|
66
|
+
|
67
|
+
spyOn: function(obj, methodName) {
|
68
|
+
return env.spyOn(obj, methodName);
|
69
|
+
},
|
70
|
+
|
71
|
+
clock: env.clock,
|
72
|
+
setTimeout: env.clock.setTimeout,
|
73
|
+
clearTimeout: env.clock.clearTimeout,
|
74
|
+
setInterval: env.clock.setInterval,
|
75
|
+
clearInterval: env.clock.clearInterval,
|
76
|
+
jsApiReporter: new jasmine.JsApiReporter({
|
77
|
+
timer: new jasmine.Timer()
|
78
|
+
})
|
79
|
+
};
|
80
|
+
|
81
|
+
if (typeof window == "undefined" && typeof exports == "object") {
|
82
|
+
extend(exports, jasmineInterface);
|
83
|
+
} else {
|
84
|
+
extend(window, jasmineInterface);
|
85
|
+
}
|
86
|
+
|
87
|
+
var queryString = new jasmine.QueryString({
|
88
|
+
getWindowLocation: function() { return window.location; }
|
89
|
+
});
|
90
|
+
|
91
|
+
// TODO: move all of catching to raise so we don't break our brains
|
92
|
+
var catchingExceptions = queryString.getParam("catch");
|
93
|
+
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
|
94
|
+
|
95
|
+
var htmlReporter = new jasmine.HtmlReporter({
|
96
|
+
env: env,
|
97
|
+
queryString: queryString,
|
98
|
+
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
99
|
+
getContainer: function() { return document.body; },
|
100
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
101
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
102
|
+
timer: new jasmine.Timer()
|
103
|
+
});
|
104
|
+
|
105
|
+
env.addReporter(jasmineInterface.jsApiReporter);
|
106
|
+
env.addReporter(htmlReporter);
|
107
|
+
|
108
|
+
var specFilter = new jasmine.HtmlSpecFilter({
|
109
|
+
filterString: function() { return queryString.getParam("spec"); }
|
110
|
+
});
|
111
|
+
|
112
|
+
env.specFilter = function(spec) {
|
113
|
+
return specFilter.matches(spec.getFullName());
|
114
|
+
};
|
115
|
+
|
116
|
+
var currentWindowOnload = window.onload;
|
117
|
+
|
118
|
+
window.onload = function() {
|
119
|
+
if (currentWindowOnload) {
|
120
|
+
currentWindowOnload();
|
121
|
+
}
|
122
|
+
htmlReporter.initialize();
|
123
|
+
env.execute();
|
124
|
+
};
|
125
|
+
|
126
|
+
function extend(destination, source) {
|
127
|
+
for (var property in source) destination[property] = source[property];
|
128
|
+
return destination;
|
129
|
+
}
|
130
|
+
|
131
|
+
}());
|
@@ -0,0 +1,109 @@
|
|
1
|
+
// Jasmine boot.js for browser runners - exposes external/global interface, builds the Jasmine environment and executes it.
|
2
|
+
(function() {
|
3
|
+
window.jasmine = jasmineRequire.core(jasmineRequire);
|
4
|
+
jasmineRequire.html(jasmine);
|
5
|
+
|
6
|
+
var env = jasmine.getEnv();
|
7
|
+
|
8
|
+
var jasmineInterface = {
|
9
|
+
describe: function(description, specDefinitions) {
|
10
|
+
return env.describe(description, specDefinitions);
|
11
|
+
},
|
12
|
+
|
13
|
+
xdescribe: function(description, specDefinitions) {
|
14
|
+
return env.xdescribe(description, specDefinitions);
|
15
|
+
},
|
16
|
+
|
17
|
+
it: function(desc, func) {
|
18
|
+
return env.it(desc, func);
|
19
|
+
},
|
20
|
+
|
21
|
+
xit: function(desc, func) {
|
22
|
+
return env.xit(desc, func);
|
23
|
+
},
|
24
|
+
|
25
|
+
beforeEach: function(beforeEachFunction) {
|
26
|
+
return env.beforeEach(beforeEachFunction);
|
27
|
+
},
|
28
|
+
|
29
|
+
afterEach: function(afterEachFunction) {
|
30
|
+
return env.afterEach(afterEachFunction);
|
31
|
+
},
|
32
|
+
|
33
|
+
expect: function(actual) {
|
34
|
+
return env.expect(actual);
|
35
|
+
},
|
36
|
+
|
37
|
+
pending: function() {
|
38
|
+
return env.pending();
|
39
|
+
},
|
40
|
+
|
41
|
+
addMatchers: function(matchers) {
|
42
|
+
return env.addMatchers(matchers);
|
43
|
+
},
|
44
|
+
|
45
|
+
spyOn: function(obj, methodName) {
|
46
|
+
return env.spyOn(obj, methodName);
|
47
|
+
},
|
48
|
+
|
49
|
+
clock: env.clock,
|
50
|
+
setTimeout: env.clock.setTimeout,
|
51
|
+
clearTimeout: env.clock.clearTimeout,
|
52
|
+
setInterval: env.clock.setInterval,
|
53
|
+
clearInterval: env.clock.clearInterval,
|
54
|
+
jsApiReporter: new jasmine.JsApiReporter({
|
55
|
+
timer: new jasmine.Timer()
|
56
|
+
})
|
57
|
+
};
|
58
|
+
|
59
|
+
if (typeof window == "undefined" && typeof exports == "object") {
|
60
|
+
extend(exports, jasmineInterface);
|
61
|
+
} else {
|
62
|
+
extend(window, jasmineInterface);
|
63
|
+
}
|
64
|
+
|
65
|
+
var queryString = new jasmine.QueryString({
|
66
|
+
getWindowLocation: function() { return window.location; }
|
67
|
+
});
|
68
|
+
|
69
|
+
// TODO: move all of catching to raise so we don't break our brains
|
70
|
+
var catchingExceptions = queryString.getParam("catch");
|
71
|
+
env.catchExceptions(typeof catchingExceptions === "undefined" ? true : catchingExceptions);
|
72
|
+
|
73
|
+
var htmlReporter = new jasmine.HtmlReporter({
|
74
|
+
env: env,
|
75
|
+
queryString: queryString,
|
76
|
+
onRaiseExceptionsClick: function() { queryString.setParam("catch", !env.catchingExceptions()); },
|
77
|
+
getContainer: function() { return document.body; },
|
78
|
+
createElement: function() { return document.createElement.apply(document, arguments); },
|
79
|
+
createTextNode: function() { return document.createTextNode.apply(document, arguments); },
|
80
|
+
timer: new jasmine.Timer()
|
81
|
+
});
|
82
|
+
|
83
|
+
env.addReporter(jasmineInterface.jsApiReporter);
|
84
|
+
env.addReporter(htmlReporter);
|
85
|
+
|
86
|
+
var specFilter = new jasmine.HtmlSpecFilter({
|
87
|
+
filterString: function() { return queryString.getParam("spec"); }
|
88
|
+
});
|
89
|
+
|
90
|
+
env.specFilter = function(spec) {
|
91
|
+
return specFilter.matches(spec.getFullName());
|
92
|
+
};
|
93
|
+
|
94
|
+
var currentWindowOnload = window.onload;
|
95
|
+
|
96
|
+
window.onload = function() {
|
97
|
+
if (currentWindowOnload) {
|
98
|
+
currentWindowOnload();
|
99
|
+
}
|
100
|
+
htmlReporter.initialize();
|
101
|
+
env.execute();
|
102
|
+
};
|
103
|
+
|
104
|
+
function extend(destination, source) {
|
105
|
+
for (var property in source) destination[property] = source[property];
|
106
|
+
return destination;
|
107
|
+
}
|
108
|
+
|
109
|
+
}());
|
@@ -1,9 +1,15 @@
|
|
1
|
-
beforeEach(function() {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
beforeEach(function () {
|
2
|
+
jasmine.Expectation.addMatchers({
|
3
|
+
toBePlaying: function () {
|
4
|
+
return {
|
5
|
+
compare: function (actual, expected) {
|
6
|
+
var player = actual;
|
7
|
+
|
8
|
+
return {
|
9
|
+
pass: player.currentlyPlayingSong === expected && player.isPlaying
|
10
|
+
}
|
11
|
+
}
|
12
|
+
};
|
13
|
+
}
|
14
|
+
});
|
9
15
|
});
|
@@ -1,681 +1,354 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
1
|
+
/*
|
2
|
+
Copyright (c) 2008-2013 Pivotal Labs
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
*/
|
23
|
+
jasmineRequire.html = function(j$) {
|
24
|
+
j$.ResultsNode = jasmineRequire.ResultsNode();
|
25
|
+
j$.HtmlReporter = jasmineRequire.HtmlReporter(j$);
|
26
|
+
j$.QueryString = jasmineRequire.QueryString();
|
27
|
+
j$.HtmlSpecFilter = jasmineRequire.HtmlSpecFilter();
|
27
28
|
};
|
29
|
+
jasmineRequire.HtmlReporter = function(j$) {
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
if (results.skipped) {
|
33
|
-
status = 'skipped';
|
34
|
-
}
|
35
|
-
|
36
|
-
return status;
|
37
|
-
};
|
38
|
-
|
39
|
-
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
40
|
-
var parentDiv = this.dom.summary;
|
41
|
-
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
42
|
-
var parent = child[parentSuite];
|
43
|
-
|
44
|
-
if (parent) {
|
45
|
-
if (typeof this.views.suites[parent.id] == 'undefined') {
|
46
|
-
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
47
|
-
}
|
48
|
-
parentDiv = this.views.suites[parent.id].element;
|
49
|
-
}
|
50
|
-
|
51
|
-
parentDiv.appendChild(childElement);
|
52
|
-
};
|
53
|
-
|
54
|
-
|
55
|
-
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
56
|
-
for(var fn in jasmine.HtmlReporterHelpers) {
|
57
|
-
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
58
|
-
}
|
59
|
-
};
|
60
|
-
|
61
|
-
jasmine.HtmlReporter = function(_doc) {
|
62
|
-
var self = this;
|
63
|
-
var doc = _doc || window.document;
|
64
|
-
|
65
|
-
var reporterView;
|
66
|
-
|
67
|
-
var dom = {};
|
68
|
-
|
69
|
-
// Jasmine Reporter Public Interface
|
70
|
-
self.logRunningSpecs = false;
|
71
|
-
|
72
|
-
self.reportRunnerStarting = function(runner) {
|
73
|
-
var specs = runner.specs() || [];
|
74
|
-
|
75
|
-
if (specs.length == 0) {
|
76
|
-
return;
|
77
|
-
}
|
78
|
-
|
79
|
-
createReporterDom(runner.env.versionString());
|
80
|
-
doc.body.appendChild(dom.reporter);
|
81
|
-
setExceptionHandling();
|
82
|
-
|
83
|
-
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
84
|
-
reporterView.addSpecs(specs, self.specFilter);
|
85
|
-
};
|
86
|
-
|
87
|
-
self.reportRunnerResults = function(runner) {
|
88
|
-
reporterView && reporterView.complete();
|
89
|
-
};
|
90
|
-
|
91
|
-
self.reportSuiteResults = function(suite) {
|
92
|
-
reporterView.suiteComplete(suite);
|
93
|
-
};
|
94
|
-
|
95
|
-
self.reportSpecStarting = function(spec) {
|
96
|
-
if (self.logRunningSpecs) {
|
97
|
-
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
98
|
-
}
|
31
|
+
var noopTimer = {
|
32
|
+
start: function(){},
|
33
|
+
elapsed: function(){ return 0; }
|
99
34
|
};
|
100
35
|
|
101
|
-
|
102
|
-
|
103
|
-
|
36
|
+
function HtmlReporter(options) {
|
37
|
+
var env = options.env || {},
|
38
|
+
getContainer = options.getContainer,
|
39
|
+
createElement = options.createElement,
|
40
|
+
createTextNode = options.createTextNode,
|
41
|
+
onRaiseExceptionsClick = options.onRaiseExceptionsClick || function() {},
|
42
|
+
timer = options.timer || noopTimer,
|
43
|
+
results = [],
|
44
|
+
specsExecuted = 0,
|
45
|
+
failureCount = 0,
|
46
|
+
pendingSpecCount = 0,
|
47
|
+
htmlReporterMain,
|
48
|
+
symbols;
|
49
|
+
|
50
|
+
this.initialize = function() {
|
51
|
+
htmlReporterMain = createDom("div", {className: "html-reporter"},
|
52
|
+
createDom("div", {className: "banner"},
|
53
|
+
createDom("span", {className: "title"}, "Jasmine"),
|
54
|
+
createDom("span", {className: "version"}, j$.version)
|
55
|
+
),
|
56
|
+
createDom("ul", {className: "symbol-summary"}),
|
57
|
+
createDom("div", {className: "alert"}),
|
58
|
+
createDom("div", {className: "results"},
|
59
|
+
createDom("div", {className: "failures"})
|
60
|
+
)
|
61
|
+
);
|
62
|
+
getContainer().appendChild(htmlReporterMain);
|
104
63
|
|
105
|
-
|
106
|
-
|
107
|
-
if (console && console.log) {
|
108
|
-
if (console.log.apply) {
|
109
|
-
console.log.apply(console, arguments);
|
110
|
-
} else {
|
111
|
-
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
112
|
-
}
|
113
|
-
}
|
114
|
-
};
|
64
|
+
symbols = find(".symbol-summary");
|
65
|
+
};
|
115
66
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
67
|
+
var totalSpecsDefined;
|
68
|
+
this.jasmineStarted = function(options) {
|
69
|
+
totalSpecsDefined = options.totalSpecsDefined || 0;
|
70
|
+
timer.start();
|
71
|
+
};
|
120
72
|
|
121
|
-
|
122
|
-
};
|
73
|
+
var summary = createDom("div", {className: "summary"});
|
123
74
|
|
124
|
-
|
75
|
+
var topResults = new j$.ResultsNode({}, "", null),
|
76
|
+
currentParent = topResults;
|
125
77
|
|
126
|
-
|
127
|
-
|
78
|
+
this.suiteStarted = function(result) {
|
79
|
+
currentParent.addChild(result, "suite");
|
80
|
+
currentParent = currentParent.last();
|
81
|
+
};
|
128
82
|
|
129
|
-
|
130
|
-
if (
|
83
|
+
this.suiteDone = function(result) {
|
84
|
+
if (currentParent == topResults) {
|
131
85
|
return;
|
132
86
|
}
|
133
87
|
|
134
|
-
|
135
|
-
var params = jasmine.HtmlReporter.parameters(doc);
|
136
|
-
|
137
|
-
for (var i = 0; i < params.length; i++) {
|
138
|
-
var p = params[i].split('=');
|
139
|
-
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
140
|
-
}
|
141
|
-
|
142
|
-
specName = paramMap.spec;
|
143
|
-
})();
|
144
|
-
|
145
|
-
return specName;
|
146
|
-
}
|
147
|
-
|
148
|
-
function createReporterDom(version) {
|
149
|
-
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
150
|
-
dom.banner = self.createDom('div', { className: 'banner' },
|
151
|
-
self.createDom('span', { className: 'title' }, "Jasmine "),
|
152
|
-
self.createDom('span', { className: 'version' }, version)),
|
153
|
-
|
154
|
-
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
155
|
-
dom.alert = self.createDom('div', {className: 'alert'},
|
156
|
-
self.createDom('span', { className: 'exceptions' },
|
157
|
-
self.createDom('label', { className: 'label', 'for': 'no_try_catch' }, 'No try/catch'),
|
158
|
-
self.createDom('input', { id: 'no_try_catch', type: 'checkbox' }))),
|
159
|
-
dom.results = self.createDom('div', {className: 'results'},
|
160
|
-
dom.summary = self.createDom('div', { className: 'summary' }),
|
161
|
-
dom.details = self.createDom('div', { id: 'details' }))
|
162
|
-
);
|
163
|
-
}
|
164
|
-
|
165
|
-
function noTryCatch() {
|
166
|
-
return window.location.search.match(/catch=false/);
|
167
|
-
}
|
168
|
-
|
169
|
-
function searchWithCatch() {
|
170
|
-
var params = jasmine.HtmlReporter.parameters(window.document);
|
171
|
-
var removed = false;
|
172
|
-
var i = 0;
|
173
|
-
|
174
|
-
while (!removed && i < params.length) {
|
175
|
-
if (params[i].match(/catch=/)) {
|
176
|
-
params.splice(i, 1);
|
177
|
-
removed = true;
|
178
|
-
}
|
179
|
-
i++;
|
180
|
-
}
|
181
|
-
if (jasmine.CATCH_EXCEPTIONS) {
|
182
|
-
params.push("catch=false");
|
183
|
-
}
|
184
|
-
|
185
|
-
return params.join("&");
|
186
|
-
}
|
187
|
-
|
188
|
-
function setExceptionHandling() {
|
189
|
-
var chxCatch = document.getElementById('no_try_catch');
|
190
|
-
|
191
|
-
if (noTryCatch()) {
|
192
|
-
chxCatch.setAttribute('checked', true);
|
193
|
-
jasmine.CATCH_EXCEPTIONS = false;
|
194
|
-
}
|
195
|
-
chxCatch.onclick = function() {
|
196
|
-
window.location.search = searchWithCatch();
|
88
|
+
currentParent = currentParent.parent;
|
197
89
|
};
|
198
|
-
}
|
199
|
-
};
|
200
|
-
jasmine.HtmlReporter.parameters = function(doc) {
|
201
|
-
var paramStr = doc.location.search.substring(1);
|
202
|
-
var params = [];
|
203
|
-
|
204
|
-
if (paramStr.length > 0) {
|
205
|
-
params = paramStr.split('&');
|
206
|
-
}
|
207
|
-
return params;
|
208
|
-
}
|
209
|
-
jasmine.HtmlReporter.sectionLink = function(sectionName) {
|
210
|
-
var link = '?';
|
211
|
-
var params = [];
|
212
|
-
|
213
|
-
if (sectionName) {
|
214
|
-
params.push('spec=' + encodeURIComponent(sectionName));
|
215
|
-
}
|
216
|
-
if (!jasmine.CATCH_EXCEPTIONS) {
|
217
|
-
params.push("catch=false");
|
218
|
-
}
|
219
|
-
if (params.length > 0) {
|
220
|
-
link += params.join("&");
|
221
|
-
}
|
222
90
|
|
223
|
-
|
224
|
-
|
225
|
-
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);
|
226
|
-
jasmine.HtmlReporter.ReporterView = function(dom) {
|
227
|
-
this.startedAt = new Date();
|
228
|
-
this.runningSpecCount = 0;
|
229
|
-
this.completeSpecCount = 0;
|
230
|
-
this.passedCount = 0;
|
231
|
-
this.failedCount = 0;
|
232
|
-
this.skippedCount = 0;
|
233
|
-
|
234
|
-
this.createResultsMenu = function() {
|
235
|
-
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
236
|
-
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
237
|
-
' | ',
|
238
|
-
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
239
|
-
|
240
|
-
this.summaryMenuItem.onclick = function() {
|
241
|
-
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
91
|
+
this.specStarted = function(result) {
|
92
|
+
currentParent.addChild(result, "spec");
|
242
93
|
};
|
243
94
|
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
95
|
+
var failures = [];
|
96
|
+
this.specDone = function(result) {
|
97
|
+
if (result.status != "disabled") {
|
98
|
+
specsExecuted++;
|
99
|
+
}
|
248
100
|
|
249
|
-
|
250
|
-
|
101
|
+
symbols.appendChild(createDom("li", {
|
102
|
+
className: result.status,
|
103
|
+
id: "spec_" + result.id,
|
104
|
+
title: result.fullName}
|
105
|
+
));
|
106
|
+
|
107
|
+
if (result.status == "failed") {
|
108
|
+
failureCount++;
|
109
|
+
|
110
|
+
var failure =
|
111
|
+
createDom("div", {className: "spec-detail failed"},
|
112
|
+
createDom("a", {className: "description", title: result.fullName, href: specHref(result)}, result.fullName),
|
113
|
+
createDom("div", {className: "messages"})
|
114
|
+
);
|
115
|
+
var messages = failure.childNodes[1];
|
116
|
+
|
117
|
+
for (var i = 0; i < result.failedExpectations.length; i++) {
|
118
|
+
var expectation = result.failedExpectations[i];
|
119
|
+
messages.appendChild(createDom("div", {className: "result-message"}, expectation.message));
|
120
|
+
messages.appendChild(createDom("div", {className: "stack-trace"}, expectation.stack));
|
121
|
+
}
|
122
|
+
|
123
|
+
failures.push(failure);
|
124
|
+
}
|
251
125
|
|
252
|
-
|
253
|
-
|
254
|
-
|
126
|
+
if (result.status == "pending") {
|
127
|
+
pendingSpecCount++;
|
128
|
+
}
|
255
129
|
};
|
256
130
|
|
257
|
-
|
258
|
-
var
|
259
|
-
|
260
|
-
|
261
|
-
|
131
|
+
this.jasmineDone = function() {
|
132
|
+
var banner = find(".banner");
|
133
|
+
banner.appendChild(createDom("span", {className: "duration"}, "finished in " + timer.elapsed() / 1000 + "s"));
|
134
|
+
|
135
|
+
var alert = find(".alert");
|
136
|
+
|
137
|
+
alert.appendChild(createDom("span", { className: "exceptions" },
|
138
|
+
createDom("label", { className: "label", 'for': "raise-exceptions" }, "raise exceptions"),
|
139
|
+
createDom("input", {
|
140
|
+
className: "raise",
|
141
|
+
id: "raise-exceptions",
|
142
|
+
type: "checkbox"
|
143
|
+
})
|
144
|
+
));
|
145
|
+
var checkbox = find("input");
|
146
|
+
|
147
|
+
checkbox.checked = !env.catchingExceptions();
|
148
|
+
checkbox.onclick = onRaiseExceptionsClick;
|
149
|
+
|
150
|
+
if (specsExecuted < totalSpecsDefined) {
|
151
|
+
var skippedMessage = "Ran " + specsExecuted + " of " + totalSpecsDefined + " specs - run all";
|
152
|
+
alert.appendChild(
|
153
|
+
createDom("span", {className: "bar skipped"},
|
154
|
+
createDom("a", {href: "?", title: "Run all specs"}, skippedMessage)
|
155
|
+
)
|
156
|
+
);
|
157
|
+
}
|
158
|
+
var statusBarMessage = "" + pluralize("spec", specsExecuted) + ", " + pluralize("failure", failureCount);
|
159
|
+
if (pendingSpecCount) { statusBarMessage += ", " + pluralize("pending spec", pendingSpecCount); }
|
160
|
+
|
161
|
+
var statusBarClassName = "bar " + ((failureCount > 0) ? "failed" : "passed");
|
162
|
+
alert.appendChild(createDom("span", {className: statusBarClassName}, statusBarMessage));
|
163
|
+
|
164
|
+
var results = find(".results");
|
165
|
+
results.appendChild(summary);
|
166
|
+
|
167
|
+
summaryList(topResults, summary);
|
168
|
+
|
169
|
+
function summaryList(resultsTree, domParent) {
|
170
|
+
var specListNode;
|
171
|
+
for (var i = 0; i < resultsTree.children.length; i++) {
|
172
|
+
var resultNode = resultsTree.children[i];
|
173
|
+
if (resultNode.type == "suite") {
|
174
|
+
var suiteListNode = createDom("ul", {className: "suite", id: "suite-" + resultNode.result.id},
|
175
|
+
createDom("li", {className: "suite-detail"},
|
176
|
+
createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description)
|
177
|
+
)
|
178
|
+
);
|
179
|
+
|
180
|
+
summaryList(resultNode, suiteListNode);
|
181
|
+
domParent.appendChild(suiteListNode);
|
182
|
+
}
|
183
|
+
if (resultNode.type == "spec") {
|
184
|
+
if (domParent.getAttribute("class") != "specs") {
|
185
|
+
specListNode = createDom("ul", {className: "specs"});
|
186
|
+
domParent.appendChild(specListNode);
|
187
|
+
}
|
188
|
+
specListNode.appendChild(
|
189
|
+
createDom("li", {
|
190
|
+
className: resultNode.result.status,
|
191
|
+
id: "spec-" + resultNode.result.id
|
192
|
+
},
|
193
|
+
createDom("a", {href: specHref(resultNode.result)}, resultNode.result.description)
|
194
|
+
)
|
195
|
+
);
|
196
|
+
}
|
197
|
+
}
|
262
198
|
}
|
263
|
-
}
|
264
|
-
};
|
265
|
-
|
266
|
-
this.specComplete = function(spec) {
|
267
|
-
this.completeSpecCount++;
|
268
|
-
|
269
|
-
if (isUndefined(this.views.specs[spec.id])) {
|
270
|
-
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
271
|
-
}
|
272
|
-
|
273
|
-
var specView = this.views.specs[spec.id];
|
274
|
-
|
275
|
-
switch (specView.status()) {
|
276
|
-
case 'passed':
|
277
|
-
this.passedCount++;
|
278
|
-
break;
|
279
|
-
|
280
|
-
case 'failed':
|
281
|
-
this.failedCount++;
|
282
|
-
break;
|
283
|
-
|
284
|
-
case 'skipped':
|
285
|
-
this.skippedCount++;
|
286
|
-
break;
|
287
|
-
}
|
288
|
-
|
289
|
-
specView.refresh();
|
290
|
-
this.refresh();
|
291
|
-
};
|
292
|
-
|
293
|
-
this.suiteComplete = function(suite) {
|
294
|
-
var suiteView = this.views.suites[suite.id];
|
295
|
-
if (isUndefined(suiteView)) {
|
296
|
-
return;
|
297
|
-
}
|
298
|
-
suiteView.refresh();
|
299
|
-
};
|
300
|
-
|
301
|
-
this.refresh = function() {
|
302
199
|
|
303
|
-
|
304
|
-
|
305
|
-
|
200
|
+
if (failures.length) {
|
201
|
+
alert.appendChild(
|
202
|
+
createDom('span', {className: "menu bar spec-list"},
|
203
|
+
createDom("span", {}, "Spec List | "),
|
204
|
+
createDom('a', {className: "failures-menu", href: "#"}, "Failures")));
|
205
|
+
alert.appendChild(
|
206
|
+
createDom('span', {className: "menu bar failure-list"},
|
207
|
+
createDom('a', {className: "spec-list-menu", href: "#"}, "Spec List"),
|
208
|
+
createDom("span", {}, " | Failures ")));
|
209
|
+
|
210
|
+
find(".failures-menu").onclick = function() {
|
211
|
+
setMenuModeTo('failure-list');
|
212
|
+
};
|
213
|
+
find(".spec-list-menu").onclick = function() {
|
214
|
+
setMenuModeTo('spec-list');
|
215
|
+
};
|
216
|
+
|
217
|
+
setMenuModeTo('failure-list');
|
218
|
+
|
219
|
+
var failureNode = find(".failures");
|
220
|
+
for (var i = 0; i < failures.length; i++) {
|
221
|
+
failureNode.appendChild(failures[i]);
|
222
|
+
}
|
223
|
+
}
|
224
|
+
};
|
306
225
|
|
307
|
-
|
308
|
-
if (isUndefined(this.runningAlert)) {
|
309
|
-
this.runningAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "runningAlert bar" });
|
310
|
-
dom.alert.appendChild(this.runningAlert);
|
311
|
-
}
|
312
|
-
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
226
|
+
return this;
|
313
227
|
|
314
|
-
|
315
|
-
|
316
|
-
this.skippedAlert = this.createDom('a', { href: jasmine.HtmlReporter.sectionLink(), className: "skippedAlert bar" });
|
228
|
+
function find(selector) {
|
229
|
+
return getContainer().querySelector(selector);
|
317
230
|
}
|
318
231
|
|
319
|
-
|
232
|
+
function createDom(type, attrs, childrenVarArgs) {
|
233
|
+
var el = createElement(type);
|
320
234
|
|
321
|
-
|
322
|
-
|
323
|
-
}
|
235
|
+
for (var i = 2; i < arguments.length; i++) {
|
236
|
+
var child = arguments[i];
|
324
237
|
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
238
|
+
if (typeof child === 'string') {
|
239
|
+
el.appendChild(createTextNode(child));
|
240
|
+
} else {
|
241
|
+
if (child) {
|
242
|
+
el.appendChild(child);
|
243
|
+
}
|
244
|
+
}
|
245
|
+
}
|
330
246
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
247
|
+
for (var attr in attrs) {
|
248
|
+
if (attr == "className") {
|
249
|
+
el[attr] = attrs[attr];
|
250
|
+
} else {
|
251
|
+
el.setAttribute(attr, attrs[attr]);
|
252
|
+
}
|
253
|
+
}
|
336
254
|
|
337
|
-
|
338
|
-
dom.alert.appendChild(this.failedAlert);
|
339
|
-
dom.alert.appendChild(this.resultsMenu);
|
255
|
+
return el;
|
340
256
|
}
|
341
257
|
|
342
|
-
|
343
|
-
|
344
|
-
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
345
|
-
};
|
346
|
-
|
347
|
-
this.complete = function() {
|
348
|
-
dom.alert.removeChild(this.runningAlert);
|
349
|
-
|
350
|
-
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
258
|
+
function pluralize(singular, count) {
|
259
|
+
var word = (count == 1 ? singular : singular + "s");
|
351
260
|
|
352
|
-
|
353
|
-
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
354
|
-
} else {
|
355
|
-
showDetails();
|
261
|
+
return "" + count + " " + word;
|
356
262
|
}
|
357
263
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
return this;
|
362
|
-
|
363
|
-
function showDetails() {
|
364
|
-
if (dom.reporter.className.search(/showDetails/) === -1) {
|
365
|
-
dom.reporter.className += " showDetails";
|
264
|
+
function specHref(result) {
|
265
|
+
return "?spec=" + encodeURIComponent(result.fullName);
|
366
266
|
}
|
367
|
-
}
|
368
|
-
|
369
|
-
function isUndefined(obj) {
|
370
|
-
return typeof obj === 'undefined';
|
371
|
-
}
|
372
267
|
|
373
|
-
|
374
|
-
|
375
|
-
}
|
376
|
-
|
377
|
-
function specPluralizedFor(count) {
|
378
|
-
var str = count + " spec";
|
379
|
-
if (count > 1) {
|
380
|
-
str += "s"
|
268
|
+
function setMenuModeTo(mode) {
|
269
|
+
htmlReporterMain.setAttribute("class", "html-reporter " + mode);
|
381
270
|
}
|
382
|
-
return str;
|
383
271
|
}
|
384
272
|
|
273
|
+
return HtmlReporter;
|
385
274
|
};
|
386
275
|
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
this.spec = spec;
|
392
|
-
this.dom = dom;
|
393
|
-
this.views = views;
|
394
|
-
|
395
|
-
this.symbol = this.createDom('li', { className: 'pending' });
|
396
|
-
this.dom.symbolSummary.appendChild(this.symbol);
|
397
|
-
|
398
|
-
this.summary = this.createDom('div', { className: 'specSummary' },
|
399
|
-
this.createDom('a', {
|
400
|
-
className: 'description',
|
401
|
-
href: jasmine.HtmlReporter.sectionLink(this.spec.getFullName()),
|
402
|
-
title: this.spec.getFullName()
|
403
|
-
}, this.spec.description)
|
404
|
-
);
|
276
|
+
jasmineRequire.HtmlSpecFilter = function() {
|
277
|
+
function HtmlSpecFilter(options) {
|
278
|
+
var filterString = options && options.filterString() && options.filterString().replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
|
279
|
+
var filterPattern = new RegExp(filterString);
|
405
280
|
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
410
|
-
title: this.spec.getFullName()
|
411
|
-
}, this.spec.getFullName())
|
412
|
-
);
|
413
|
-
};
|
414
|
-
|
415
|
-
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
416
|
-
return this.getSpecStatus(this.spec);
|
417
|
-
};
|
418
|
-
|
419
|
-
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
420
|
-
this.symbol.className = this.status();
|
421
|
-
|
422
|
-
switch (this.status()) {
|
423
|
-
case 'skipped':
|
424
|
-
break;
|
425
|
-
|
426
|
-
case 'passed':
|
427
|
-
this.appendSummaryToSuiteDiv();
|
428
|
-
break;
|
429
|
-
|
430
|
-
case 'failed':
|
431
|
-
this.appendSummaryToSuiteDiv();
|
432
|
-
this.appendFailureDetail();
|
433
|
-
break;
|
434
|
-
}
|
435
|
-
};
|
436
|
-
|
437
|
-
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
438
|
-
this.summary.className += ' ' + this.status();
|
439
|
-
this.appendToSummary(this.spec, this.summary);
|
440
|
-
};
|
441
|
-
|
442
|
-
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
443
|
-
this.detail.className += ' ' + this.status();
|
444
|
-
|
445
|
-
var resultItems = this.spec.results().getItems();
|
446
|
-
var messagesDiv = this.createDom('div', { className: 'messages' });
|
447
|
-
|
448
|
-
for (var i = 0; i < resultItems.length; i++) {
|
449
|
-
var result = resultItems[i];
|
450
|
-
|
451
|
-
if (result.type == 'log') {
|
452
|
-
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
453
|
-
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
454
|
-
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
455
|
-
|
456
|
-
if (result.trace.stack) {
|
457
|
-
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
458
|
-
}
|
459
|
-
}
|
281
|
+
this.matches = function(specName) {
|
282
|
+
return filterPattern.test(specName);
|
283
|
+
};
|
460
284
|
}
|
461
285
|
|
462
|
-
|
463
|
-
this.detail.appendChild(messagesDiv);
|
464
|
-
this.dom.details.appendChild(this.detail);
|
465
|
-
}
|
286
|
+
return HtmlSpecFilter;
|
466
287
|
};
|
467
288
|
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
this.element = this.createDom('div', { className: 'suite' },
|
474
|
-
this.createDom('a', { className: 'description', href: jasmine.HtmlReporter.sectionLink(this.suite.getFullName()) }, this.suite.description)
|
475
|
-
);
|
289
|
+
jasmineRequire.ResultsNode = function() {
|
290
|
+
function ResultsNode(result, type, parent) {
|
291
|
+
this.result = result;
|
292
|
+
this.type = type;
|
293
|
+
this.parent = parent;
|
476
294
|
|
477
|
-
|
478
|
-
};
|
479
|
-
|
480
|
-
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
481
|
-
return this.getSpecStatus(this.suite);
|
482
|
-
};
|
295
|
+
this.children = [];
|
483
296
|
|
484
|
-
|
485
|
-
|
486
|
-
};
|
487
|
-
|
488
|
-
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
489
|
-
|
490
|
-
/* @deprecated Use jasmine.HtmlReporter instead
|
491
|
-
*/
|
492
|
-
jasmine.TrivialReporter = function(doc) {
|
493
|
-
this.document = doc || document;
|
494
|
-
this.suiteDivs = {};
|
495
|
-
this.logRunningSpecs = false;
|
496
|
-
};
|
497
|
-
|
498
|
-
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
499
|
-
var el = document.createElement(type);
|
500
|
-
|
501
|
-
for (var i = 2; i < arguments.length; i++) {
|
502
|
-
var child = arguments[i];
|
503
|
-
|
504
|
-
if (typeof child === 'string') {
|
505
|
-
el.appendChild(document.createTextNode(child));
|
506
|
-
} else {
|
507
|
-
if (child) { el.appendChild(child); }
|
508
|
-
}
|
509
|
-
}
|
510
|
-
|
511
|
-
for (var attr in attrs) {
|
512
|
-
if (attr == "className") {
|
513
|
-
el[attr] = attrs[attr];
|
514
|
-
} else {
|
515
|
-
el.setAttribute(attr, attrs[attr]);
|
516
|
-
}
|
517
|
-
}
|
518
|
-
|
519
|
-
return el;
|
520
|
-
};
|
521
|
-
|
522
|
-
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
523
|
-
var showPassed, showSkipped;
|
524
|
-
|
525
|
-
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
526
|
-
this.createDom('div', { className: 'banner' },
|
527
|
-
this.createDom('div', { className: 'logo' },
|
528
|
-
this.createDom('span', { className: 'title' }, "Jasmine"),
|
529
|
-
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
530
|
-
this.createDom('div', { className: 'options' },
|
531
|
-
"Show ",
|
532
|
-
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
533
|
-
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
534
|
-
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
535
|
-
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
536
|
-
)
|
537
|
-
),
|
538
|
-
|
539
|
-
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
540
|
-
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
541
|
-
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
542
|
-
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
543
|
-
);
|
297
|
+
this.addChild = function(result, type) {
|
298
|
+
this.children.push(new ResultsNode(result, type, this));
|
299
|
+
};
|
544
300
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
for (var i = 0; i < suites.length; i++) {
|
549
|
-
var suite = suites[i];
|
550
|
-
var suiteDiv = this.createDom('div', { className: 'suite' },
|
551
|
-
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
552
|
-
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
553
|
-
this.suiteDivs[suite.id] = suiteDiv;
|
554
|
-
var parentDiv = this.outerDiv;
|
555
|
-
if (suite.parentSuite) {
|
556
|
-
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
557
|
-
}
|
558
|
-
parentDiv.appendChild(suiteDiv);
|
301
|
+
this.last = function() {
|
302
|
+
return this.children[this.children.length - 1];
|
303
|
+
};
|
559
304
|
}
|
560
305
|
|
561
|
-
|
562
|
-
|
563
|
-
var self = this;
|
564
|
-
showPassed.onclick = function(evt) {
|
565
|
-
if (showPassed.checked) {
|
566
|
-
self.outerDiv.className += ' show-passed';
|
567
|
-
} else {
|
568
|
-
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
569
|
-
}
|
570
|
-
};
|
571
|
-
|
572
|
-
showSkipped.onclick = function(evt) {
|
573
|
-
if (showSkipped.checked) {
|
574
|
-
self.outerDiv.className += ' show-skipped';
|
575
|
-
} else {
|
576
|
-
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
577
|
-
}
|
578
|
-
};
|
306
|
+
return ResultsNode;
|
579
307
|
};
|
308
|
+
jasmineRequire.QueryString = function() {
|
309
|
+
function QueryString(options) {
|
580
310
|
|
581
|
-
|
582
|
-
|
583
|
-
|
584
|
-
|
585
|
-
|
586
|
-
this.runnerDiv.setAttribute("className", className);
|
587
|
-
var specs = runner.specs();
|
588
|
-
var specCount = 0;
|
589
|
-
for (var i = 0; i < specs.length; i++) {
|
590
|
-
if (this.specFilter(specs[i])) {
|
591
|
-
specCount++;
|
592
|
-
}
|
593
|
-
}
|
594
|
-
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
595
|
-
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
596
|
-
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
597
|
-
|
598
|
-
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
599
|
-
};
|
311
|
+
this.setParam = function(key, value) {
|
312
|
+
var paramMap = queryStringToParamMap();
|
313
|
+
paramMap[key] = value;
|
314
|
+
options.getWindowLocation().search = toQueryString(paramMap);
|
315
|
+
};
|
600
316
|
|
601
|
-
|
602
|
-
|
603
|
-
|
604
|
-
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
605
|
-
status = 'skipped';
|
606
|
-
}
|
607
|
-
this.suiteDivs[suite.id].className += " " + status;
|
608
|
-
};
|
317
|
+
this.getParam = function(key) {
|
318
|
+
return queryStringToParamMap()[key];
|
319
|
+
};
|
609
320
|
|
610
|
-
|
611
|
-
if (this.logRunningSpecs) {
|
612
|
-
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
613
|
-
}
|
614
|
-
};
|
321
|
+
return this;
|
615
322
|
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
625
|
-
|
626
|
-
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
638
|
-
|
639
|
-
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
640
|
-
|
641
|
-
if (result.trace.stack) {
|
642
|
-
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
323
|
+
function toQueryString(paramMap) {
|
324
|
+
var qStrPairs = [];
|
325
|
+
for (var prop in paramMap) {
|
326
|
+
qStrPairs.push(encodeURIComponent(prop) + "=" + encodeURIComponent(paramMap[prop]));
|
327
|
+
}
|
328
|
+
return "?" + qStrPairs.join('&');
|
329
|
+
}
|
330
|
+
|
331
|
+
function queryStringToParamMap() {
|
332
|
+
var paramStr = options.getWindowLocation().search.substring(1),
|
333
|
+
params = [],
|
334
|
+
paramMap = {};
|
335
|
+
|
336
|
+
if (paramStr.length > 0) {
|
337
|
+
params = paramStr.split('&');
|
338
|
+
for (var i = 0; i < params.length; i++) {
|
339
|
+
var p = params[i].split('=');
|
340
|
+
var value = decodeURIComponent(p[1]);
|
341
|
+
if (value === "true" || value === "false") {
|
342
|
+
value = JSON.parse(value);
|
343
|
+
}
|
344
|
+
paramMap[decodeURIComponent(p[0])] = value;
|
345
|
+
}
|
643
346
|
}
|
644
|
-
}
|
645
|
-
}
|
646
|
-
|
647
|
-
if (messagesDiv.childNodes.length > 0) {
|
648
|
-
specDiv.appendChild(messagesDiv);
|
649
|
-
}
|
650
|
-
|
651
|
-
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
652
|
-
};
|
653
347
|
|
654
|
-
|
655
|
-
var console = jasmine.getGlobal().console;
|
656
|
-
if (console && console.log) {
|
657
|
-
if (console.log.apply) {
|
658
|
-
console.log.apply(console, arguments);
|
659
|
-
} else {
|
660
|
-
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
348
|
+
return paramMap;
|
661
349
|
}
|
662
|
-
}
|
663
|
-
};
|
664
350
|
|
665
|
-
jasmine.TrivialReporter.prototype.getLocation = function() {
|
666
|
-
return this.document.location;
|
667
|
-
};
|
668
|
-
|
669
|
-
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
670
|
-
var paramMap = {};
|
671
|
-
var params = this.getLocation().search.substring(1).split('&');
|
672
|
-
for (var i = 0; i < params.length; i++) {
|
673
|
-
var p = params[i].split('=');
|
674
|
-
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
675
351
|
}
|
676
352
|
|
677
|
-
|
678
|
-
return true;
|
679
|
-
}
|
680
|
-
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
353
|
+
return QueryString;
|
681
354
|
};
|