josephholsten-jasmine 1.1.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +11 -0
- data/.gitmodules +3 -0
- data/Gemfile +5 -0
- data/HOW_TO_TEST.markdown +9 -0
- data/MIT.LICENSE +20 -0
- data/README.markdown +71 -0
- data/RELEASE.markdown +22 -0
- data/Rakefile +76 -0
- data/bin/jasmine +6 -0
- data/generators/jasmine/jasmine_generator.rb +32 -0
- data/generators/jasmine/templates/INSTALL +9 -0
- data/generators/jasmine/templates/jasmine-example/SpecRunner.html +27 -0
- data/generators/jasmine/templates/jasmine-example/spec/PlayerSpec.js +58 -0
- data/generators/jasmine/templates/jasmine-example/spec/SpecHelper.js +9 -0
- data/generators/jasmine/templates/jasmine-example/src/Player.js +22 -0
- data/generators/jasmine/templates/jasmine-example/src/Song.js +7 -0
- data/generators/jasmine/templates/lib/tasks/jasmine.rake +8 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/jasmine/Gemfile +6 -0
- data/jasmine/Gemfile.lock +33 -0
- data/jasmine/HowToRelease.markdown +29 -0
- data/jasmine/MIT.LICENSE +20 -0
- data/jasmine/README.markdown +50 -0
- data/jasmine/Rakefile +166 -0
- data/jasmine/cruise_config.rb +21 -0
- data/jasmine/example/SpecRunner.html +27 -0
- data/jasmine/example/spec/PlayerSpec.js +58 -0
- data/jasmine/example/spec/SpecHelper.js +9 -0
- data/jasmine/example/src/Player.js +22 -0
- data/jasmine/example/src/Song.js +7 -0
- data/jasmine/images/jasmine_favicon.png +0 -0
- data/jasmine/jsdoc-template/allclasses.tmpl +17 -0
- data/jasmine/jsdoc-template/allfiles.tmpl +56 -0
- data/jasmine/jsdoc-template/class.tmpl +646 -0
- data/jasmine/jsdoc-template/index.tmpl +39 -0
- data/jasmine/jsdoc-template/publish.js +184 -0
- data/jasmine/jsdoc-template/static/default.css +162 -0
- data/jasmine/jsdoc-template/static/header.html +2 -0
- data/jasmine/jsdoc-template/static/index.html +19 -0
- data/jasmine/jsdoc-template/symbol.tmpl +35 -0
- data/jasmine/jshint/jshint.js +5919 -0
- data/jasmine/jshint/run.js +98 -0
- data/jasmine/lib/jasmine-html.js +190 -0
- data/jasmine/lib/jasmine.css +166 -0
- data/jasmine/lib/jasmine.js +2445 -0
- data/jasmine/lib/json2.js +478 -0
- data/jasmine/spec/node_suite.js +233 -0
- data/jasmine/spec/runner.html +82 -0
- data/jasmine/spec/suites/BaseSpec.js +27 -0
- data/jasmine/spec/suites/CustomMatchersSpec.js +97 -0
- data/jasmine/spec/suites/EnvSpec.js +158 -0
- data/jasmine/spec/suites/ExceptionsSpec.js +107 -0
- data/jasmine/spec/suites/JsApiReporterSpec.js +103 -0
- data/jasmine/spec/suites/MatchersSpec.js +795 -0
- data/jasmine/spec/suites/MockClockSpec.js +38 -0
- data/jasmine/spec/suites/MultiReporterSpec.js +45 -0
- data/jasmine/spec/suites/NestedResultsSpec.js +54 -0
- data/jasmine/spec/suites/PrettyPrintSpec.js +93 -0
- data/jasmine/spec/suites/QueueSpec.js +23 -0
- data/jasmine/spec/suites/ReporterSpec.js +56 -0
- data/jasmine/spec/suites/RunnerSpec.js +267 -0
- data/jasmine/spec/suites/SpecRunningSpec.js +1253 -0
- data/jasmine/spec/suites/SpecSpec.js +124 -0
- data/jasmine/spec/suites/SpySpec.js +201 -0
- data/jasmine/spec/suites/SuiteSpec.js +120 -0
- data/jasmine/spec/suites/TrivialConsoleReporterSpec.js +431 -0
- data/jasmine/spec/suites/TrivialReporterSpec.js +238 -0
- data/jasmine/spec/suites/UtilSpec.js +39 -0
- data/jasmine/spec/suites/WaitsForBlockSpec.js +118 -0
- data/jasmine/src/Block.js +22 -0
- data/jasmine/src/Env.js +264 -0
- data/jasmine/src/JsApiReporter.js +102 -0
- data/jasmine/src/Matchers.js +354 -0
- data/jasmine/src/MultiReporter.js +35 -0
- data/jasmine/src/NestedResults.js +80 -0
- data/jasmine/src/PrettyPrinter.js +123 -0
- data/jasmine/src/Queue.js +99 -0
- data/jasmine/src/Reporter.js +31 -0
- data/jasmine/src/Runner.js +77 -0
- data/jasmine/src/Spec.js +242 -0
- data/jasmine/src/Suite.js +82 -0
- data/jasmine/src/WaitsBlock.js +15 -0
- data/jasmine/src/WaitsForBlock.js +54 -0
- data/jasmine/src/base.js +608 -0
- data/jasmine/src/console/TrivialConsoleReporter.js +144 -0
- data/jasmine/src/html/TrivialReporter.js +190 -0
- data/jasmine/src/html/jasmine.css +166 -0
- data/jasmine/src/mock-timeout.js +183 -0
- data/jasmine/src/util.js +67 -0
- data/jasmine/src/version.json +5 -0
- data/jasmine.gemspec +52 -0
- data/lib/generators/jasmine/examples/USAGE +11 -0
- data/lib/generators/jasmine/examples/examples_generator.rb +19 -0
- data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Player.js +22 -0
- data/lib/generators/jasmine/examples/templates/public/javascripts/jasmine_examples/Song.js +7 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/helpers/SpecHelper.js +9 -0
- data/lib/generators/jasmine/examples/templates/spec/javascripts/jasmine_examples/PlayerSpec.js +58 -0
- data/lib/generators/jasmine/install/USAGE +11 -0
- data/lib/generators/jasmine/install/install_generator.rb +18 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/helpers/.gitkeep +0 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine.yml +81 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/lib/generators/jasmine/install/templates/spec/javascripts/support/jasmine_runner.rb +20 -0
- data/lib/generators/jasmine/jasmine_generator.rb +32 -0
- data/lib/generators/jasmine/templates/INSTALL +9 -0
- data/lib/generators/jasmine/templates/lib/tasks/jasmine.rake +2 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine-rails.yml +81 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine.yml +73 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_config.rb +23 -0
- data/lib/generators/jasmine/templates/spec/javascripts/support/jasmine_runner.rb +32 -0
- data/lib/jasmine/base.rb +66 -0
- data/lib/jasmine/command_line_tool.rb +72 -0
- data/lib/jasmine/config.rb +190 -0
- data/lib/jasmine/railtie.rb +20 -0
- data/lib/jasmine/run.html.erb +44 -0
- data/lib/jasmine/selenium_driver.rb +49 -0
- data/lib/jasmine/server.rb +106 -0
- data/lib/jasmine/spec_builder.rb +162 -0
- data/lib/jasmine/tasks/jasmine.rake +44 -0
- data/lib/jasmine/version.rb +3 -0
- data/lib/jasmine.rb +14 -0
- data/spec/config_spec.rb +308 -0
- data/spec/fixture/jasmine.erb.yml +4 -0
- data/spec/jasmine_command_line_tool_spec.rb +29 -0
- data/spec/jasmine_pojs_spec.rb +51 -0
- data/spec/jasmine_rails2_spec.rb +93 -0
- data/spec/jasmine_rails3_spec.rb +71 -0
- data/spec/jasmine_self_test_config.rb +15 -0
- data/spec/jasmine_self_test_spec.rb +24 -0
- data/spec/server_spec.rb +80 -0
- data/spec/spec_helper.rb +65 -0
- metadata +386 -0
@@ -0,0 +1,82 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/html4/loose.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title>Jasmine Test Runner</title>
|
6
|
+
|
7
|
+
<script type="text/javascript">
|
8
|
+
// yes, really keep this here to keep us honest, but only for jasmine's own runner! [xw]
|
9
|
+
undefined = "diz be undefined yo";
|
10
|
+
</script>
|
11
|
+
<link rel="shortcut icon" type="image/png" href="../images/jasmine_favicon.png">
|
12
|
+
<script type="text/javascript" src="../src/base.js"></script>
|
13
|
+
<script type="text/javascript" src="../src/util.js"></script>
|
14
|
+
<script type="text/javascript" src="../src/Env.js"></script>
|
15
|
+
<script type="text/javascript" src="../src/Reporter.js"></script>
|
16
|
+
<script type="text/javascript" src="../src/Block.js"></script>
|
17
|
+
|
18
|
+
<script type="text/javascript" src="../src/JsApiReporter.js"></script>
|
19
|
+
<script type="text/javascript" src="../src/Matchers.js"></script>
|
20
|
+
<script type="text/javascript" src="../src/mock-timeout.js"></script>
|
21
|
+
<script type="text/javascript" src="../src/MultiReporter.js"></script>
|
22
|
+
<script type="text/javascript" src="../src/NestedResults.js"></script>
|
23
|
+
<script type="text/javascript" src="../src/PrettyPrinter.js"></script>
|
24
|
+
<script type="text/javascript" src="../src/Queue.js"></script>
|
25
|
+
<script type="text/javascript" src="../src/Runner.js"></script>
|
26
|
+
<script type="text/javascript" src="../src/Spec.js"></script>
|
27
|
+
<script type="text/javascript" src="../src/Suite.js"></script>
|
28
|
+
<script type="text/javascript" src="../src/WaitsBlock.js"></script>
|
29
|
+
<script type="text/javascript" src="../src/WaitsForBlock.js"></script>
|
30
|
+
|
31
|
+
<script type="text/javascript" src="../src/html/TrivialReporter.js"></script>
|
32
|
+
<script type="text/javascript" src="../src/console/TrivialConsoleReporter.js"></script>
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
<script type="text/javascript" src="suites/BaseSpec.js"></script>
|
37
|
+
<script type="text/javascript" src="suites/CustomMatchersSpec.js"></script>
|
38
|
+
<script type="text/javascript" src="suites/EnvSpec.js"></script>
|
39
|
+
<script type="text/javascript" src="suites/ExceptionsSpec.js"></script>
|
40
|
+
<script type="text/javascript" src="suites/JsApiReporterSpec.js"></script>
|
41
|
+
<script type="text/javascript" src="suites/MatchersSpec.js"></script>
|
42
|
+
<script type="text/javascript" src="suites/MockClockSpec.js"></script>
|
43
|
+
<script type="text/javascript" src="suites/MultiReporterSpec.js"></script>
|
44
|
+
<script type="text/javascript" src="suites/NestedResultsSpec.js"></script>
|
45
|
+
<script type="text/javascript" src="suites/PrettyPrintSpec.js"></script>
|
46
|
+
<script type="text/javascript" src="suites/ReporterSpec.js"></script>
|
47
|
+
<script type="text/javascript" src="suites/RunnerSpec.js"></script>
|
48
|
+
<script type="text/javascript" src="suites/QueueSpec.js"></script>
|
49
|
+
<script type="text/javascript" src="suites/SpecSpec.js"></script>
|
50
|
+
<script type="text/javascript" src="suites/SpecRunningSpec.js"></script>
|
51
|
+
<script type="text/javascript" src="suites/SpySpec.js"></script>
|
52
|
+
<script type="text/javascript" src="suites/SuiteSpec.js"></script>
|
53
|
+
<script type="text/javascript" src="suites/TrivialReporterSpec.js"></script>
|
54
|
+
<script type="text/javascript" src="suites/TrivialConsoleReporterSpec.js"></script>
|
55
|
+
<script type="text/javascript" src="suites/WaitsForBlockSpec.js"></script>
|
56
|
+
|
57
|
+
|
58
|
+
<script type="text/javascript">
|
59
|
+
(function() {
|
60
|
+
var jasmineEnv = jasmine.getEnv();
|
61
|
+
jasmineEnv.updateInterval = 1000;
|
62
|
+
|
63
|
+
var trivialReporter = new jasmine.TrivialReporter();
|
64
|
+
|
65
|
+
jasmineEnv.addReporter(trivialReporter);
|
66
|
+
|
67
|
+
jasmineEnv.specFilter = function(spec) {
|
68
|
+
return trivialReporter.specFilter(spec);
|
69
|
+
};
|
70
|
+
|
71
|
+
window.onload = function() {
|
72
|
+
jasmineEnv.execute();
|
73
|
+
};
|
74
|
+
})();
|
75
|
+
</script>
|
76
|
+
|
77
|
+
<link href="../src/html/jasmine.css" rel="stylesheet"/>
|
78
|
+
</head>
|
79
|
+
|
80
|
+
<body>
|
81
|
+
</body>
|
82
|
+
</html>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
describe("base.js", function() {
|
2
|
+
describe("jasmine.MessageResult", function() {
|
3
|
+
it("#toString should pretty-print and concatenate each part of the message", function() {
|
4
|
+
var values = ["log", "message", 123, {key: "value"}, "FTW!"];
|
5
|
+
var messageResult = new jasmine.MessageResult(values);
|
6
|
+
expect(messageResult.toString()).toEqual("log message 123 { key : 'value' } FTW!");
|
7
|
+
});
|
8
|
+
});
|
9
|
+
|
10
|
+
describe("jasmine.log", function() {
|
11
|
+
it("should accept n arguments", function() {
|
12
|
+
spyOn(jasmine.getEnv().currentSpec, 'log');
|
13
|
+
jasmine.log(1, 2, 3);
|
14
|
+
expect(jasmine.getEnv().currentSpec.log).toHaveBeenCalledWith(1, 2, 3);
|
15
|
+
});
|
16
|
+
});
|
17
|
+
|
18
|
+
describe("jasmine.getGlobal", function() {
|
19
|
+
it("should return the global object", function() {
|
20
|
+
var globalObject = (function() {
|
21
|
+
return this;
|
22
|
+
})();
|
23
|
+
|
24
|
+
expect(jasmine.getGlobal()).toBe(globalObject);
|
25
|
+
});
|
26
|
+
});
|
27
|
+
});
|
@@ -0,0 +1,97 @@
|
|
1
|
+
describe("Custom Matchers", function() {
|
2
|
+
var env;
|
3
|
+
var fakeTimer;
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
env = new jasmine.Env();
|
7
|
+
env.updateInterval = 0;
|
8
|
+
});
|
9
|
+
|
10
|
+
it("should be easy to add more matchers local to a spec, suite, etc.", function() {
|
11
|
+
var spec1, spec2, spec1Matcher, spec2Matcher;
|
12
|
+
var suite = env.describe('some suite', function() {
|
13
|
+
env.beforeEach(function() {
|
14
|
+
this.addMatchers({
|
15
|
+
matcherForSuite: function(expected) {
|
16
|
+
this.message = "matcherForSuite: actual: " + this.actual + "; expected: " + expected;
|
17
|
+
return true;
|
18
|
+
}
|
19
|
+
});
|
20
|
+
});
|
21
|
+
|
22
|
+
spec1 = env.it('spec with an expectation').runs(function () {
|
23
|
+
this.addMatchers({
|
24
|
+
matcherForSpec: function(expected) {
|
25
|
+
this.message = "matcherForSpec: actual: " + this.actual + "; expected: " + expected;
|
26
|
+
return true;
|
27
|
+
}
|
28
|
+
});
|
29
|
+
spec1Matcher = this.expect("xxx");
|
30
|
+
});
|
31
|
+
|
32
|
+
spec2 = env.it('spec with failing expectation').runs(function () {
|
33
|
+
spec2Matcher = this.expect("yyy");
|
34
|
+
});
|
35
|
+
});
|
36
|
+
|
37
|
+
suite.execute();
|
38
|
+
|
39
|
+
spec1Matcher.matcherForSuite("expected");
|
40
|
+
expect(spec1Matcher.message).toEqual("matcherForSuite: actual: xxx; expected: expected");
|
41
|
+
spec1Matcher.matcherForSpec("expected");
|
42
|
+
expect(spec1Matcher.message).toEqual("matcherForSpec: actual: xxx; expected: expected");
|
43
|
+
|
44
|
+
spec2Matcher.matcherForSuite("expected");
|
45
|
+
expect(spec2Matcher.message).toEqual("matcherForSuite: actual: yyy; expected: expected");
|
46
|
+
expect(spec2Matcher.matcherForSpec).toBe(jasmine.undefined);
|
47
|
+
});
|
48
|
+
|
49
|
+
it("should generate messages with the same rules as for regular matchers when this.report() is not called", function() {
|
50
|
+
var spec;
|
51
|
+
var suite = env.describe('some suite', function() {
|
52
|
+
spec = env.it('spec with an expectation').runs(function () {
|
53
|
+
this.addMatchers({
|
54
|
+
toBeTrue: function() {
|
55
|
+
return this.actual === true;
|
56
|
+
}
|
57
|
+
});
|
58
|
+
this.expect(true).toBeTrue();
|
59
|
+
this.expect(false).toBeTrue();
|
60
|
+
});
|
61
|
+
});
|
62
|
+
|
63
|
+
suite.execute();
|
64
|
+
var passResult = new jasmine.ExpectationResult({passed: true, matcherName: 'toBeTrue',
|
65
|
+
actual: true, expected: jasmine.undefined, message: "Passed." });
|
66
|
+
var failResult = new jasmine.ExpectationResult({passed: false, matcherName: 'toBeTrue',
|
67
|
+
actual: false, expected: jasmine.undefined, message: "Expected false to be true." });
|
68
|
+
failResult.trace = jasmine.any(Object);
|
69
|
+
expect(spec.results().getItems()).toEqual([passResult, failResult]);
|
70
|
+
});
|
71
|
+
|
72
|
+
it("should pass args", function() {
|
73
|
+
var matcherCallArgs = [];
|
74
|
+
var spec;
|
75
|
+
var suite = env.describe('some suite', function() {
|
76
|
+
spec = env.it('spec with an expectation').runs(function () {
|
77
|
+
this.addMatchers({
|
78
|
+
toBeTrue: function() {
|
79
|
+
matcherCallArgs.push(jasmine.util.argsToArray(arguments));
|
80
|
+
return this.actual === true;
|
81
|
+
}
|
82
|
+
});
|
83
|
+
this.expect(true).toBeTrue();
|
84
|
+
this.expect(false).toBeTrue('arg');
|
85
|
+
this.expect(true).toBeTrue('arg1', 'arg2');
|
86
|
+
});
|
87
|
+
});
|
88
|
+
|
89
|
+
suite.execute();
|
90
|
+
var results = spec.results().getItems();
|
91
|
+
expect(results[0].expected).toEqual(jasmine.undefined);
|
92
|
+
expect(results[1].expected).toEqual('arg');
|
93
|
+
expect(results[2].expected).toEqual(['arg1', 'arg2']);
|
94
|
+
|
95
|
+
expect(matcherCallArgs).toEqual([[], ['arg'], ['arg1', 'arg2']]);
|
96
|
+
});
|
97
|
+
});
|
@@ -0,0 +1,158 @@
|
|
1
|
+
describe("jasmine.Env", function() {
|
2
|
+
var env;
|
3
|
+
beforeEach(function() {
|
4
|
+
env = new jasmine.Env();
|
5
|
+
env.updateInterval = 0;
|
6
|
+
});
|
7
|
+
|
8
|
+
describe('ids', function () {
|
9
|
+
it('nextSpecId should return consecutive integers, starting at 0', function () {
|
10
|
+
expect(env.nextSpecId()).toEqual(0);
|
11
|
+
expect(env.nextSpecId()).toEqual(1);
|
12
|
+
expect(env.nextSpecId()).toEqual(2);
|
13
|
+
});
|
14
|
+
});
|
15
|
+
|
16
|
+
describe("reporting", function() {
|
17
|
+
var fakeReporter;
|
18
|
+
|
19
|
+
beforeEach(function() {
|
20
|
+
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log"]);
|
21
|
+
});
|
22
|
+
|
23
|
+
describe('version', function () {
|
24
|
+
var oldVersion;
|
25
|
+
|
26
|
+
beforeEach(function () {
|
27
|
+
oldVersion = jasmine.version_;
|
28
|
+
});
|
29
|
+
|
30
|
+
afterEach(function () {
|
31
|
+
jasmine.version_ = oldVersion;
|
32
|
+
});
|
33
|
+
|
34
|
+
it('should raise an error if version is not set', function () {
|
35
|
+
jasmine.version_ = null;
|
36
|
+
var exception;
|
37
|
+
try {
|
38
|
+
env.version();
|
39
|
+
}
|
40
|
+
catch (e) {
|
41
|
+
exception = e;
|
42
|
+
}
|
43
|
+
expect(exception.message).toEqual('Version not set');
|
44
|
+
});
|
45
|
+
|
46
|
+
it("version should return the current version as an int", function() {
|
47
|
+
jasmine.version_ = {
|
48
|
+
"major": 1,
|
49
|
+
"minor": 9,
|
50
|
+
"build": 7,
|
51
|
+
"revision": 8
|
52
|
+
};
|
53
|
+
expect(env.version()).toEqual({
|
54
|
+
"major": 1,
|
55
|
+
"minor": 9,
|
56
|
+
"build": 7,
|
57
|
+
"revision": 8
|
58
|
+
});
|
59
|
+
});
|
60
|
+
|
61
|
+
describe("versionString", function() {
|
62
|
+
it("should return a stringified version number", function() {
|
63
|
+
jasmine.version_ = {
|
64
|
+
"major": 1,
|
65
|
+
"minor": 9,
|
66
|
+
"build": 7,
|
67
|
+
"revision": 8
|
68
|
+
};
|
69
|
+
expect(env.versionString()).toEqual("1.9.7 revision 8");
|
70
|
+
});
|
71
|
+
|
72
|
+
it("should return a nice string when version is unknown", function() {
|
73
|
+
jasmine.version_ = null;
|
74
|
+
expect(env.versionString()).toEqual("version unknown");
|
75
|
+
});
|
76
|
+
});
|
77
|
+
});
|
78
|
+
|
79
|
+
it("should allow reporters to be registered", function() {
|
80
|
+
env.addReporter(fakeReporter);
|
81
|
+
env.reporter.log("message");
|
82
|
+
expect(fakeReporter.log).toHaveBeenCalledWith("message");
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
describe("equality testing", function() {
|
87
|
+
describe("with custom equality testers", function() {
|
88
|
+
var aObj, bObj, isEqual;
|
89
|
+
|
90
|
+
beforeEach(function() {
|
91
|
+
env.addEqualityTester(function(a, b) {
|
92
|
+
aObj = a;
|
93
|
+
bObj = b;
|
94
|
+
return isEqual;
|
95
|
+
});
|
96
|
+
});
|
97
|
+
|
98
|
+
it("should call the custom equality tester with two objects for comparison", function() {
|
99
|
+
env.equals_("1", "2");
|
100
|
+
expect(aObj).toEqual("1");
|
101
|
+
expect(bObj).toEqual("2");
|
102
|
+
});
|
103
|
+
|
104
|
+
describe("when the custom equality tester returns false", function() {
|
105
|
+
beforeEach(function() {
|
106
|
+
isEqual = false;
|
107
|
+
});
|
108
|
+
|
109
|
+
it("should give custom equality testers precedence", function() {
|
110
|
+
expect(env.equals_('abc', 'abc')).toBeFalsy();
|
111
|
+
var o = {};
|
112
|
+
expect(env.equals_(o, o)).toBeFalsy();
|
113
|
+
});
|
114
|
+
});
|
115
|
+
|
116
|
+
|
117
|
+
describe("when the custom equality tester returns true", function() {
|
118
|
+
beforeEach(function() {
|
119
|
+
isEqual = true;
|
120
|
+
});
|
121
|
+
|
122
|
+
it("should give custom equality testers precedence", function() {
|
123
|
+
expect(env.equals_('abc', 'def')).toBeTruthy();
|
124
|
+
expect(env.equals_(true, false)).toBeTruthy();
|
125
|
+
});
|
126
|
+
});
|
127
|
+
|
128
|
+
describe("when the custom equality tester returns undefined", function() {
|
129
|
+
beforeEach(function() {
|
130
|
+
isEqual = jasmine.undefined;
|
131
|
+
});
|
132
|
+
|
133
|
+
it("should use normal equality rules", function() {
|
134
|
+
expect(env.equals_('abc', 'abc')).toBeTruthy();
|
135
|
+
expect(env.equals_('abc', 'def')).toBeFalsy();
|
136
|
+
});
|
137
|
+
|
138
|
+
describe("even if there are several", function() {
|
139
|
+
beforeEach(function() {
|
140
|
+
env.addEqualityTester(function(a, b) { return jasmine.undefined; });
|
141
|
+
env.addEqualityTester(function(a, b) { return jasmine.undefined; });
|
142
|
+
});
|
143
|
+
|
144
|
+
it("should use normal equality rules", function() {
|
145
|
+
expect(env.equals_('abc', 'abc')).toBeTruthy();
|
146
|
+
expect(env.equals_('abc', 'def')).toBeFalsy();
|
147
|
+
});
|
148
|
+
});
|
149
|
+
});
|
150
|
+
|
151
|
+
it("should evaluate custom equality testers in the order they are declared", function() {
|
152
|
+
isEqual = false;
|
153
|
+
env.addEqualityTester(function(a, b) { return true; });
|
154
|
+
expect(env.equals_('abc', 'abc')).toBeFalsy();
|
155
|
+
});
|
156
|
+
});
|
157
|
+
});
|
158
|
+
});
|
@@ -0,0 +1,107 @@
|
|
1
|
+
describe('Exceptions:', function() {
|
2
|
+
var env;
|
3
|
+
|
4
|
+
beforeEach(function() {
|
5
|
+
env = new jasmine.Env();
|
6
|
+
env.updateInterval = 0;
|
7
|
+
});
|
8
|
+
|
9
|
+
it('jasmine.formatException formats Firefox exception messages as expected', function() {
|
10
|
+
var sampleFirefoxException = {
|
11
|
+
fileName: 'foo.js',
|
12
|
+
line: '1978',
|
13
|
+
message: 'you got your foo in my bar',
|
14
|
+
name: 'A Classic Mistake'
|
15
|
+
};
|
16
|
+
|
17
|
+
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
18
|
+
|
19
|
+
expect(jasmine.util.formatException(sampleFirefoxException)).toEqual(expected);
|
20
|
+
});
|
21
|
+
|
22
|
+
it('jasmine.formatException formats Webkit exception messages as expected', function() {
|
23
|
+
var sampleWebkitException = {
|
24
|
+
sourceURL: 'foo.js',
|
25
|
+
lineNumber: '1978',
|
26
|
+
message: 'you got your foo in my bar',
|
27
|
+
name: 'A Classic Mistake'
|
28
|
+
};
|
29
|
+
|
30
|
+
var expected = 'A Classic Mistake: you got your foo in my bar in foo.js (line 1978)';
|
31
|
+
|
32
|
+
expect(jasmine.util.formatException(sampleWebkitException)).toEqual(expected);
|
33
|
+
});
|
34
|
+
|
35
|
+
it('should handle exceptions thrown, but continue', function() {
|
36
|
+
var fakeTimer = new jasmine.FakeTimer();
|
37
|
+
env.setTimeout = fakeTimer.setTimeout;
|
38
|
+
env.clearTimeout = fakeTimer.clearTimeout;
|
39
|
+
env.setInterval = fakeTimer.setInterval;
|
40
|
+
env.clearInterval = fakeTimer.clearInterval;
|
41
|
+
|
42
|
+
//we run two exception tests to make sure we continue after throwing an exception
|
43
|
+
var suite = env.describe('Suite for handles exceptions', function () {
|
44
|
+
env.it('should be a test that fails because it throws an exception', function() {
|
45
|
+
throw new Error('fake error 1');
|
46
|
+
});
|
47
|
+
|
48
|
+
env.it('should be another test that fails because it throws an exception', function() {
|
49
|
+
this.runs(function () {
|
50
|
+
throw new Error('fake error 2');
|
51
|
+
});
|
52
|
+
this.runs(function () {
|
53
|
+
this.expect(true).toEqual(true);
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
env.it('should be a passing test that runs after exceptions are thrown', function() {
|
58
|
+
this.expect(true).toEqual(true);
|
59
|
+
});
|
60
|
+
|
61
|
+
env.it('should be another test that fails because it throws an exception after a wait', function() {
|
62
|
+
this.runs(function () {
|
63
|
+
var foo = 'foo';
|
64
|
+
});
|
65
|
+
this.waits(250);
|
66
|
+
this.runs(function () {
|
67
|
+
throw new Error('fake error 3');
|
68
|
+
});
|
69
|
+
});
|
70
|
+
|
71
|
+
env.it('should be a passing test that runs after exceptions are thrown from a async test', function() {
|
72
|
+
this.expect(true).toEqual(true);
|
73
|
+
});
|
74
|
+
});
|
75
|
+
|
76
|
+
var runner = env.currentRunner();
|
77
|
+
suite.execute();
|
78
|
+
fakeTimer.tick(2500);
|
79
|
+
|
80
|
+
var suiteResults = suite.results();
|
81
|
+
var specResults = suiteResults.getItems();
|
82
|
+
|
83
|
+
expect(suiteResults.passed()).toEqual(false);
|
84
|
+
//
|
85
|
+
expect(specResults.length).toEqual(5);
|
86
|
+
expect(specResults[0].passed()).toMatch(false);
|
87
|
+
var blockResults = specResults[0].getItems();
|
88
|
+
expect(blockResults[0].passed()).toEqual(false);
|
89
|
+
expect(blockResults[0].message).toMatch(/fake error 1/);
|
90
|
+
|
91
|
+
expect(specResults[1].passed()).toEqual(false);
|
92
|
+
blockResults = specResults[1].getItems();
|
93
|
+
expect(blockResults[0].passed()).toEqual(false);
|
94
|
+
expect(blockResults[0].message).toMatch(/fake error 2/);
|
95
|
+
expect(blockResults[1].passed()).toEqual(true);
|
96
|
+
|
97
|
+
expect(specResults[2].passed()).toEqual(true);
|
98
|
+
|
99
|
+
expect(specResults[3].passed()).toEqual(false);
|
100
|
+
blockResults = specResults[3].getItems();
|
101
|
+
expect(blockResults[0].message).toMatch(/fake error 3/);
|
102
|
+
|
103
|
+
expect(specResults[4].passed()).toEqual(true);
|
104
|
+
|
105
|
+
});
|
106
|
+
|
107
|
+
});
|
@@ -0,0 +1,103 @@
|
|
1
|
+
describe('jasmine.jsApiReporter', function() {
|
2
|
+
describe('results', function () {
|
3
|
+
var reporter, spec1, spec2, spec3, expectedSpec1Results, expectedSpec2Results;
|
4
|
+
var env;
|
5
|
+
var suite, nestedSuite, nestedSpec;
|
6
|
+
|
7
|
+
beforeEach(function() {
|
8
|
+
env = new jasmine.Env();
|
9
|
+
env.updateInterval = 0;
|
10
|
+
|
11
|
+
suite = env.describe("top-level suite", function() {
|
12
|
+
spec1 = env.it("spec 1", function() {
|
13
|
+
this.expect(true).toEqual(true);
|
14
|
+
|
15
|
+
});
|
16
|
+
|
17
|
+
spec2 = env.it("spec 2", function() {
|
18
|
+
this.expect(true).toEqual(false);
|
19
|
+
});
|
20
|
+
|
21
|
+
nestedSuite = env.describe("nested suite", function() {
|
22
|
+
nestedSpec = env.it("nested spec", function() {
|
23
|
+
expect(true).toEqual(true);
|
24
|
+
});
|
25
|
+
});
|
26
|
+
|
27
|
+
spec3 = env.it("spec 3", function() {
|
28
|
+
this.log('some debug message');
|
29
|
+
});
|
30
|
+
});
|
31
|
+
|
32
|
+
reporter = new jasmine.JsApiReporter();
|
33
|
+
env.addReporter(reporter);
|
34
|
+
|
35
|
+
env.execute();
|
36
|
+
|
37
|
+
expectedSpec1Results = {
|
38
|
+
messages: spec1.results().getItems(),
|
39
|
+
result: "passed"
|
40
|
+
};
|
41
|
+
expectedSpec2Results = {
|
42
|
+
messages: spec2.results().getItems(),
|
43
|
+
result: "failed"
|
44
|
+
};
|
45
|
+
});
|
46
|
+
|
47
|
+
it('resultForSpec() should return the result for the given spec', function () {
|
48
|
+
expect(reporter.resultsForSpec(spec1.id)).toEqual(expectedSpec1Results);
|
49
|
+
expect(reporter.resultsForSpec(spec2.id)).toEqual(expectedSpec2Results);
|
50
|
+
});
|
51
|
+
|
52
|
+
it('results() should return a hash of all results, indexed by spec id', function () {
|
53
|
+
expect(reporter.results()[spec1.id]).toEqual(expectedSpec1Results);
|
54
|
+
expect(reporter.results()[spec2.id]).toEqual(expectedSpec2Results);
|
55
|
+
});
|
56
|
+
|
57
|
+
it("should return nested suites as children of their parents", function() {
|
58
|
+
expect(reporter.suites()).toEqual([
|
59
|
+
{ id: 0, name: 'top-level suite', type: 'suite',
|
60
|
+
children: [
|
61
|
+
{ id: 0, name: 'spec 1', type: 'spec', children: [ ] },
|
62
|
+
{ id: 1, name: 'spec 2', type: 'spec', children: [ ] },
|
63
|
+
{ id: 1, name: 'nested suite', type: 'suite',
|
64
|
+
children: [
|
65
|
+
{ id: 2, name: 'nested spec', type: 'spec', children: [ ] }
|
66
|
+
]
|
67
|
+
},
|
68
|
+
{ id: 3, name: 'spec 3', type: 'spec', children: [ ] }
|
69
|
+
]
|
70
|
+
}
|
71
|
+
]);
|
72
|
+
});
|
73
|
+
|
74
|
+
describe("#summarizeResult_", function() {
|
75
|
+
it("should summarize a passing result", function() {
|
76
|
+
var result = reporter.results()[spec1.id];
|
77
|
+
var summarizedResult = reporter.summarizeResult_(result);
|
78
|
+
expect(summarizedResult.result).toEqual('passed');
|
79
|
+
expect(summarizedResult.messages.length).toEqual(1);
|
80
|
+
expect(summarizedResult.messages[0].message).toEqual(result.messages[0].message);
|
81
|
+
expect(summarizedResult.messages[0].passed).toBeTruthy();
|
82
|
+
expect(summarizedResult.messages[0].type).toEqual('expect');
|
83
|
+
expect(summarizedResult.messages[0].text).toBeUndefined();
|
84
|
+
expect(summarizedResult.messages[0].trace.stack).toBeUndefined();
|
85
|
+
});
|
86
|
+
|
87
|
+
it("should have a stack trace for failing specs", function() {
|
88
|
+
var result = reporter.results()[spec2.id];
|
89
|
+
var summarizedResult = reporter.summarizeResult_(result);
|
90
|
+
expect(summarizedResult.result).toEqual('failed');
|
91
|
+
expect(summarizedResult.messages[0].trace.stack).toEqual(result.messages[0].trace.stack);
|
92
|
+
});
|
93
|
+
|
94
|
+
it("should have messages for specs with messages", function() {
|
95
|
+
var result = reporter.results()[spec3.id];
|
96
|
+
var summarizedResult = reporter.summarizeResult_(result);
|
97
|
+
expect(summarizedResult.result).toEqual('passed');
|
98
|
+
expect(summarizedResult.messages[0].type).toEqual('log');
|
99
|
+
expect(summarizedResult.messages[0].text).toEqual('some debug message');
|
100
|
+
});
|
101
|
+
});
|
102
|
+
});
|
103
|
+
});
|