jasmine-core 1.1.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/jasmine-core.rb +17 -0
- data/lib/jasmine-core/example/SpecRunner.html +54 -0
- data/lib/jasmine-core/example/spec/PlayerSpec.js +58 -0
- data/lib/jasmine-core/example/spec/SpecHelper.js +9 -0
- data/lib/jasmine-core/example/src/Player.js +22 -0
- data/lib/jasmine-core/example/src/Song.js +7 -0
- data/lib/jasmine-core/jasmine-html.js +190 -0
- data/lib/jasmine-core/jasmine.css +166 -0
- data/lib/jasmine-core/jasmine.js +2476 -0
- data/lib/jasmine-core/json2.js +478 -0
- data/lib/jasmine-core/version.rb +8 -0
- data/spec/console/ConsoleReporterSpec.js +451 -0
- data/spec/core/BaseSpec.js +27 -0
- data/spec/core/CustomMatchersSpec.js +97 -0
- data/spec/core/EnvSpec.js +159 -0
- data/spec/core/ExceptionsSpec.js +149 -0
- data/spec/core/JsApiReporterSpec.js +103 -0
- data/spec/core/MatchersSpec.js +838 -0
- data/spec/core/MockClockSpec.js +38 -0
- data/spec/core/MultiReporterSpec.js +45 -0
- data/spec/core/NestedResultsSpec.js +54 -0
- data/spec/core/PrettyPrintSpec.js +87 -0
- data/spec/core/QueueSpec.js +23 -0
- data/spec/core/ReporterSpec.js +56 -0
- data/spec/core/RunnerSpec.js +267 -0
- data/spec/core/SpecRunningSpec.js +1258 -0
- data/spec/core/SpecSpec.js +124 -0
- data/spec/core/SpySpec.js +201 -0
- data/spec/core/SuiteSpec.js +120 -0
- data/spec/core/UtilSpec.js +39 -0
- data/spec/core/WaitsForBlockSpec.js +118 -0
- data/spec/html/MatchersHtmlSpec.js +38 -0
- data/spec/html/PrettyPrintHtmlSpec.js +8 -0
- data/spec/html/TrivialReporterSpec.js +239 -0
- data/spec/node_suite.js +127 -0
- data/spec/runner.html +79 -0
- data/spec/templates/runner.html.erb +49 -0
- data/spec/templates/script_tag.html.erb +1 -0
- metadata +164 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
describe("MockClock", function () {
|
2
|
+
|
3
|
+
beforeEach(function() {
|
4
|
+
jasmine.Clock.useMock();
|
5
|
+
});
|
6
|
+
|
7
|
+
describe("setTimeout", function () {
|
8
|
+
it("should mock the clock when useMock is in a beforeEach", function() {
|
9
|
+
var expected = false;
|
10
|
+
setTimeout(function() {
|
11
|
+
expected = true;
|
12
|
+
}, 30000);
|
13
|
+
expect(expected).toBe(false);
|
14
|
+
jasmine.Clock.tick(30001);
|
15
|
+
expect(expected).toBe(true);
|
16
|
+
});
|
17
|
+
});
|
18
|
+
|
19
|
+
describe("setInterval", function () {
|
20
|
+
it("should mock the clock when useMock is in a beforeEach", function() {
|
21
|
+
var interval = 0;
|
22
|
+
setInterval(function() {
|
23
|
+
interval++;
|
24
|
+
}, 30000);
|
25
|
+
expect(interval).toEqual(0);
|
26
|
+
jasmine.Clock.tick(30001);
|
27
|
+
expect(interval).toEqual(1);
|
28
|
+
jasmine.Clock.tick(30001);
|
29
|
+
expect(interval).toEqual(2);
|
30
|
+
jasmine.Clock.tick(1);
|
31
|
+
expect(interval).toEqual(2);
|
32
|
+
});
|
33
|
+
});
|
34
|
+
|
35
|
+
it("shouldn't complain if you call jasmine.Clock.useMock() more than once", function() {
|
36
|
+
jasmine.Clock.useMock();
|
37
|
+
});
|
38
|
+
});
|
@@ -0,0 +1,45 @@
|
|
1
|
+
describe("jasmine.MultiReporter", function() {
|
2
|
+
var multiReporter, fakeReporter1, fakeReporter2;
|
3
|
+
|
4
|
+
beforeEach(function() {
|
5
|
+
multiReporter = new jasmine.MultiReporter();
|
6
|
+
fakeReporter1 = jasmine.createSpyObj("fakeReporter1", ["reportSpecResults"]);
|
7
|
+
fakeReporter2 = jasmine.createSpyObj("fakeReporter2", ["reportSpecResults", "reportRunnerStarting"]);
|
8
|
+
multiReporter.addReporter(fakeReporter1);
|
9
|
+
multiReporter.addReporter(fakeReporter2);
|
10
|
+
});
|
11
|
+
|
12
|
+
it("should support all the method calls that jasmine.Reporter supports", function() {
|
13
|
+
var delegate = {};
|
14
|
+
multiReporter.addReporter(delegate);
|
15
|
+
|
16
|
+
this.addMatchers({
|
17
|
+
toDelegateMethod: function(methodName) {
|
18
|
+
delegate[methodName] = jasmine.createSpy(methodName);
|
19
|
+
this.actual[methodName]("whatever argument");
|
20
|
+
|
21
|
+
return delegate[methodName].wasCalled &&
|
22
|
+
delegate[methodName].mostRecentCall.args.length == 1 &&
|
23
|
+
delegate[methodName].mostRecentCall.args[0] == "whatever argument";
|
24
|
+
}
|
25
|
+
});
|
26
|
+
|
27
|
+
expect(multiReporter).toDelegateMethod('reportRunnerStarting');
|
28
|
+
expect(multiReporter).toDelegateMethod('reportRunnerResults');
|
29
|
+
expect(multiReporter).toDelegateMethod('reportSuiteResults');
|
30
|
+
expect(multiReporter).toDelegateMethod('reportSpecStarting');
|
31
|
+
expect(multiReporter).toDelegateMethod('reportSpecResults');
|
32
|
+
expect(multiReporter).toDelegateMethod('log');
|
33
|
+
});
|
34
|
+
|
35
|
+
it("should delegate to any and all subreporters", function() {
|
36
|
+
multiReporter.reportSpecResults('blah', 'foo');
|
37
|
+
expect(fakeReporter1.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
|
38
|
+
expect(fakeReporter2.reportSpecResults).toHaveBeenCalledWith('blah', 'foo');
|
39
|
+
});
|
40
|
+
|
41
|
+
it("should quietly skip delegating to any subreporters which lack the given method", function() {
|
42
|
+
multiReporter.reportRunnerStarting('blah', 'foo');
|
43
|
+
expect(fakeReporter2.reportRunnerStarting).toHaveBeenCalledWith('blah', 'foo');
|
44
|
+
});
|
45
|
+
});
|
@@ -0,0 +1,54 @@
|
|
1
|
+
describe('jasmine.NestedResults', function() {
|
2
|
+
it('#addResult increments counters', function() {
|
3
|
+
// Leaf case
|
4
|
+
var results = new jasmine.NestedResults();
|
5
|
+
|
6
|
+
results.addResult(new jasmine.ExpectationResult({
|
7
|
+
matcherName: "foo", passed: true, message: 'Passed.', actual: 'bar', expected: 'bar'}
|
8
|
+
));
|
9
|
+
|
10
|
+
expect(results.getItems().length).toEqual(1);
|
11
|
+
expect(results.totalCount).toEqual(1);
|
12
|
+
expect(results.passedCount).toEqual(1);
|
13
|
+
expect(results.failedCount).toEqual(0);
|
14
|
+
|
15
|
+
results.addResult(new jasmine.ExpectationResult({
|
16
|
+
matcherName: "baz", passed: false, message: 'FAIL.', actual: "corge", expected: "quux"
|
17
|
+
}));
|
18
|
+
|
19
|
+
expect(results.getItems().length).toEqual(2);
|
20
|
+
expect(results.totalCount).toEqual(2);
|
21
|
+
expect(results.passedCount).toEqual(1);
|
22
|
+
expect(results.failedCount).toEqual(1);
|
23
|
+
});
|
24
|
+
|
25
|
+
it('should roll up counts for nested results', function() {
|
26
|
+
// Branch case
|
27
|
+
var leafResultsOne = new jasmine.NestedResults();
|
28
|
+
leafResultsOne.addResult(new jasmine.ExpectationResult({
|
29
|
+
matcherName: "toSomething", passed: true, message: 'message', actual: '', expected:''
|
30
|
+
}));
|
31
|
+
|
32
|
+
leafResultsOne.addResult(new jasmine.ExpectationResult({
|
33
|
+
matcherName: "toSomethingElse", passed: false, message: 'message', actual: 'a', expected: 'b'
|
34
|
+
}));
|
35
|
+
|
36
|
+
var leafResultsTwo = new jasmine.NestedResults();
|
37
|
+
leafResultsTwo.addResult(new jasmine.ExpectationResult({
|
38
|
+
matcherName: "toSomething", passed: true, message: 'message', actual: '', expected: ''
|
39
|
+
}));
|
40
|
+
leafResultsTwo.addResult(new jasmine.ExpectationResult({
|
41
|
+
matcherName: "toSomethineElse", passed: false, message: 'message', actual: 'c', expected: 'd'
|
42
|
+
}));
|
43
|
+
|
44
|
+
var branchResults = new jasmine.NestedResults();
|
45
|
+
branchResults.addResult(leafResultsOne);
|
46
|
+
branchResults.addResult(leafResultsTwo);
|
47
|
+
|
48
|
+
expect(branchResults.getItems().length).toEqual(2);
|
49
|
+
expect(branchResults.totalCount).toEqual(4);
|
50
|
+
expect(branchResults.passedCount).toEqual(2);
|
51
|
+
expect(branchResults.failedCount).toEqual(2);
|
52
|
+
});
|
53
|
+
|
54
|
+
});
|
@@ -0,0 +1,87 @@
|
|
1
|
+
describe("jasmine.pp", function () {
|
2
|
+
it("should wrap strings in single quotes", function() {
|
3
|
+
expect(jasmine.pp("some string")).toEqual("'some string'");
|
4
|
+
expect(jasmine.pp("som' string")).toEqual("'som' string'");
|
5
|
+
});
|
6
|
+
|
7
|
+
it("should stringify primitives properly", function() {
|
8
|
+
expect(jasmine.pp(true)).toEqual("true");
|
9
|
+
expect(jasmine.pp(false)).toEqual("false");
|
10
|
+
expect(jasmine.pp(null)).toEqual("null");
|
11
|
+
expect(jasmine.pp(jasmine.undefined)).toEqual("undefined");
|
12
|
+
expect(jasmine.pp(3)).toEqual("3");
|
13
|
+
expect(jasmine.pp(-3.14)).toEqual("-3.14");
|
14
|
+
});
|
15
|
+
|
16
|
+
it("should stringify arrays properly", function() {
|
17
|
+
expect(jasmine.pp([1, 2])).toEqual("[ 1, 2 ]");
|
18
|
+
expect(jasmine.pp([1, 'foo', {}, jasmine.undefined, null])).toEqual("[ 1, 'foo', { }, undefined, null ]");
|
19
|
+
});
|
20
|
+
|
21
|
+
it("should indicate circular array references", function() {
|
22
|
+
var array1 = [1, 2];
|
23
|
+
var array2 = [array1];
|
24
|
+
array1.push(array2);
|
25
|
+
expect(jasmine.pp(array1)).toEqual("[ 1, 2, [ <circular reference: Array> ] ]");
|
26
|
+
});
|
27
|
+
|
28
|
+
it("should stringify objects properly", function() {
|
29
|
+
expect(jasmine.pp({foo: 'bar'})).toEqual("{ foo : 'bar' }");
|
30
|
+
expect(jasmine.pp({foo:'bar', baz:3, nullValue: null, undefinedValue: jasmine.undefined})).toEqual("{ foo : 'bar', baz : 3, nullValue : null, undefinedValue : undefined }");
|
31
|
+
expect(jasmine.pp({foo: function () {
|
32
|
+
}, bar: [1, 2, 3]})).toEqual("{ foo : Function, bar : [ 1, 2, 3 ] }");
|
33
|
+
});
|
34
|
+
|
35
|
+
it("should stringify RegExp objects properly", function() {
|
36
|
+
expect(jasmine.pp(/x|y|z/)).toEqual("/x|y|z/");
|
37
|
+
});
|
38
|
+
|
39
|
+
it("should indicate circular object references", function() {
|
40
|
+
var sampleValue = {foo: 'hello'};
|
41
|
+
sampleValue.nested = sampleValue;
|
42
|
+
expect(jasmine.pp(sampleValue)).toEqual("{ foo : 'hello', nested : <circular reference: Object> }");
|
43
|
+
});
|
44
|
+
|
45
|
+
it("should indicate getters on objects as such", function() {
|
46
|
+
var sampleValue = {id: 1};
|
47
|
+
if (sampleValue.__defineGetter__) {
|
48
|
+
//not supported in IE!
|
49
|
+
sampleValue.__defineGetter__('calculatedValue', function() {
|
50
|
+
throw new Error("don't call me!");
|
51
|
+
});
|
52
|
+
}
|
53
|
+
if (sampleValue.__defineGetter__) {
|
54
|
+
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1, calculatedValue : <getter> }");
|
55
|
+
}
|
56
|
+
else {
|
57
|
+
expect(jasmine.pp(sampleValue)).toEqual("{ id : 1 }");
|
58
|
+
}
|
59
|
+
});
|
60
|
+
|
61
|
+
|
62
|
+
it('should not do HTML escaping of strings', function() {
|
63
|
+
expect(jasmine.pp('some <b>html string</b> &', false)).toEqual('\'some <b>html string</b> &\'');
|
64
|
+
});
|
65
|
+
|
66
|
+
it("should abbreviate the global (usually window) object", function() {
|
67
|
+
expect(jasmine.pp(jasmine.getGlobal())).toEqual("<global>");
|
68
|
+
});
|
69
|
+
|
70
|
+
it("should stringify Date objects properly", function() {
|
71
|
+
var now = new Date();
|
72
|
+
expect(jasmine.pp(now)).toEqual("Date(" + now.toString() + ")");
|
73
|
+
});
|
74
|
+
|
75
|
+
it("should stringify spy objects properly", function() {
|
76
|
+
var TestObject = {
|
77
|
+
someFunction: function() {
|
78
|
+
}
|
79
|
+
};
|
80
|
+
spyOn(TestObject, 'someFunction');
|
81
|
+
expect(jasmine.pp(TestObject.someFunction)).toEqual("spy on someFunction");
|
82
|
+
|
83
|
+
expect(jasmine.pp(jasmine.createSpy("something"))).toEqual("spy on something");
|
84
|
+
});
|
85
|
+
|
86
|
+
});
|
87
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
describe("jasmine.Queue", function() {
|
2
|
+
it("should not call itself recursively, so we don't get stack overflow errors", function() {
|
3
|
+
var queue = new jasmine.Queue(new jasmine.Env());
|
4
|
+
queue.add(new jasmine.Block(null, function() {}));
|
5
|
+
queue.add(new jasmine.Block(null, function() {}));
|
6
|
+
queue.add(new jasmine.Block(null, function() {}));
|
7
|
+
queue.add(new jasmine.Block(null, function() {}));
|
8
|
+
|
9
|
+
var nestCount = 0;
|
10
|
+
var maxNestCount = 0;
|
11
|
+
var nextCallCount = 0;
|
12
|
+
queue.next_ = function() {
|
13
|
+
nestCount++;
|
14
|
+
if (nestCount > maxNestCount) maxNestCount = nestCount;
|
15
|
+
|
16
|
+
jasmine.Queue.prototype.next_.apply(queue, arguments);
|
17
|
+
nestCount--;
|
18
|
+
};
|
19
|
+
|
20
|
+
queue.start();
|
21
|
+
expect(maxNestCount).toEqual(1);
|
22
|
+
});
|
23
|
+
});
|
@@ -0,0 +1,56 @@
|
|
1
|
+
describe('jasmine.Reporter', function() {
|
2
|
+
var env;
|
3
|
+
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
env = new jasmine.Env();
|
7
|
+
env.updateInterval = 0;
|
8
|
+
});
|
9
|
+
|
10
|
+
it('should get called from the test runner', function() {
|
11
|
+
env.describe('Suite for JSON Reporter with Callbacks', function () {
|
12
|
+
env.it('should be a test', function() {
|
13
|
+
this.runs(function () {
|
14
|
+
this.expect(true).toEqual(true);
|
15
|
+
});
|
16
|
+
});
|
17
|
+
env.it('should be a failing test', function() {
|
18
|
+
this.runs(function () {
|
19
|
+
this.expect(false).toEqual(true);
|
20
|
+
});
|
21
|
+
});
|
22
|
+
});
|
23
|
+
env.describe('Suite for JSON Reporter with Callbacks 2', function () {
|
24
|
+
env.it('should be a test', function() {
|
25
|
+
this.runs(function () {
|
26
|
+
this.expect(true).toEqual(true);
|
27
|
+
});
|
28
|
+
});
|
29
|
+
|
30
|
+
});
|
31
|
+
|
32
|
+
var foo = 0;
|
33
|
+
var bar = 0;
|
34
|
+
var baz = 0;
|
35
|
+
|
36
|
+
env.addReporter({
|
37
|
+
reportSpecResults: function() {
|
38
|
+
foo++;
|
39
|
+
},
|
40
|
+
reportSuiteResults: function() {
|
41
|
+
bar++;
|
42
|
+
},
|
43
|
+
reportRunnerResults: function() {
|
44
|
+
baz++;
|
45
|
+
}
|
46
|
+
});
|
47
|
+
|
48
|
+
var runner = env.currentRunner();
|
49
|
+
runner.execute();
|
50
|
+
|
51
|
+
expect(foo).toEqual(3); // 'foo was expected to be 3, was ' + foo);
|
52
|
+
expect(bar).toEqual(2); // 'bar was expected to be 2, was ' + bar);
|
53
|
+
expect(baz).toEqual(1); // 'baz was expected to be 1, was ' + baz);
|
54
|
+
});
|
55
|
+
|
56
|
+
});
|
@@ -0,0 +1,267 @@
|
|
1
|
+
describe('RunnerTest', function() {
|
2
|
+
var fakeTimer;
|
3
|
+
var env;
|
4
|
+
|
5
|
+
beforeEach(function() {
|
6
|
+
env = new jasmine.Env();
|
7
|
+
env.updateInterval = 0;
|
8
|
+
|
9
|
+
fakeTimer = new jasmine.FakeTimer();
|
10
|
+
env.setTimeout = fakeTimer.setTimeout;
|
11
|
+
env.clearTimeout = fakeTimer.clearTimeout;
|
12
|
+
env.setInterval = fakeTimer.setInterval;
|
13
|
+
env.clearInterval = fakeTimer.clearInterval;
|
14
|
+
});
|
15
|
+
|
16
|
+
describe('beforeEach', function() {
|
17
|
+
it('should run before each spec for all suites', function () {
|
18
|
+
var foo;
|
19
|
+
env.beforeEach(function () {
|
20
|
+
foo = 0;
|
21
|
+
});
|
22
|
+
|
23
|
+
env.describe('suite 1', function () {
|
24
|
+
env.it('test 1-1', function() {
|
25
|
+
foo++;
|
26
|
+
this.expect(foo).toEqual(1);
|
27
|
+
});
|
28
|
+
env.it('test 1-2', function() {
|
29
|
+
foo++;
|
30
|
+
this.expect(foo).toEqual(1);
|
31
|
+
});
|
32
|
+
});
|
33
|
+
|
34
|
+
env.describe('suite 2', function () {
|
35
|
+
env.it('test 2-1', function() {
|
36
|
+
foo++;
|
37
|
+
this.expect(foo).toEqual(1);
|
38
|
+
});
|
39
|
+
});
|
40
|
+
|
41
|
+
env.currentRunner().execute();
|
42
|
+
|
43
|
+
var runnerResults = env.currentRunner().results();
|
44
|
+
expect(runnerResults.totalCount).toEqual(3);
|
45
|
+
expect(runnerResults.passedCount).toEqual(3);
|
46
|
+
});
|
47
|
+
|
48
|
+
|
49
|
+
it('should provide all specs', function () {
|
50
|
+
var foo;
|
51
|
+
env.beforeEach(function () {
|
52
|
+
foo = 0;
|
53
|
+
});
|
54
|
+
|
55
|
+
env.describe('suite 1', function () {
|
56
|
+
env.it('test 1-1', function() {
|
57
|
+
foo++;
|
58
|
+
this.expect(foo).toEqual(1);
|
59
|
+
});
|
60
|
+
env.it('test 1-2', function() {
|
61
|
+
foo++;
|
62
|
+
this.expect(foo).toEqual(1);
|
63
|
+
});
|
64
|
+
});
|
65
|
+
|
66
|
+
env.describe('suite 2', function () {
|
67
|
+
env.it('test 2-1', function() {
|
68
|
+
foo++;
|
69
|
+
this.expect(foo).toEqual(1);
|
70
|
+
});
|
71
|
+
});
|
72
|
+
|
73
|
+
env.currentRunner().execute();
|
74
|
+
|
75
|
+
|
76
|
+
expect(env.currentRunner().specs().length).toEqual(3);
|
77
|
+
});
|
78
|
+
});
|
79
|
+
|
80
|
+
describe('afterEach', function() {
|
81
|
+
it('should run after each spec for all suites', function () {
|
82
|
+
var foo = 3;
|
83
|
+
env.afterEach(function () {
|
84
|
+
foo = foo - 1;
|
85
|
+
});
|
86
|
+
|
87
|
+
env.describe('suite 1', function () {
|
88
|
+
env.it('test 1-1', function() {
|
89
|
+
this.expect(foo).toEqual(3);
|
90
|
+
});
|
91
|
+
env.it('test 1-2', function() {
|
92
|
+
this.expect(foo).toEqual(2);
|
93
|
+
});
|
94
|
+
});
|
95
|
+
|
96
|
+
env.describe('suite 2', function () {
|
97
|
+
env.it('test 2-1', function() {
|
98
|
+
this.expect(foo).toEqual(1);
|
99
|
+
});
|
100
|
+
});
|
101
|
+
|
102
|
+
env.currentRunner().execute();
|
103
|
+
|
104
|
+
var runnerResults = env.currentRunner().results();
|
105
|
+
expect(runnerResults.totalCount).toEqual(3);
|
106
|
+
expect(runnerResults.passedCount).toEqual(3);
|
107
|
+
});
|
108
|
+
});
|
109
|
+
|
110
|
+
|
111
|
+
it('should run child suites and specs and generate results when execute is called', function() {
|
112
|
+
env.describe('one suite description', function () {
|
113
|
+
env.it('should be a test', function() {
|
114
|
+
this.runs(function () {
|
115
|
+
this.expect(true).toEqual(true);
|
116
|
+
});
|
117
|
+
});
|
118
|
+
});
|
119
|
+
|
120
|
+
env.describe('another suite description', function () {
|
121
|
+
env.it('should be another test', function() {
|
122
|
+
this.runs(function () {
|
123
|
+
this.expect(true).toEqual(false);
|
124
|
+
});
|
125
|
+
});
|
126
|
+
});
|
127
|
+
|
128
|
+
env.currentRunner().execute();
|
129
|
+
|
130
|
+
var runnerResults = env.currentRunner().results();
|
131
|
+
expect(runnerResults.totalCount).toEqual(2);
|
132
|
+
expect(runnerResults.passedCount).toEqual(1);
|
133
|
+
expect(runnerResults.failedCount).toEqual(1);
|
134
|
+
});
|
135
|
+
|
136
|
+
|
137
|
+
it('should ignore suites that have been x\'d', function() {
|
138
|
+
env.xdescribe('one suite description', function () {
|
139
|
+
env.it('should be a test', function() {
|
140
|
+
this.runs(function () {
|
141
|
+
this.expect(true).toEqual(true);
|
142
|
+
});
|
143
|
+
});
|
144
|
+
});
|
145
|
+
|
146
|
+
env.describe('another suite description', function () {
|
147
|
+
env.it('should be another test', function() {
|
148
|
+
this.runs(function () {
|
149
|
+
this.expect(true).toEqual(false);
|
150
|
+
});
|
151
|
+
});
|
152
|
+
});
|
153
|
+
|
154
|
+
env.currentRunner().execute();
|
155
|
+
|
156
|
+
var runnerResults = env.currentRunner().results();
|
157
|
+
expect(runnerResults.totalCount).toEqual(1);
|
158
|
+
expect(runnerResults.passedCount).toEqual(0);
|
159
|
+
expect(runnerResults.failedCount).toEqual(1);
|
160
|
+
});
|
161
|
+
|
162
|
+
it('should roll up results from all specs', function() {
|
163
|
+
env.describe('one suite description', function () {
|
164
|
+
env.it('should be a test', function() {
|
165
|
+
this.runs(function () {
|
166
|
+
this.expect(true).toEqual(true);
|
167
|
+
});
|
168
|
+
});
|
169
|
+
});
|
170
|
+
|
171
|
+
env.describe('another suite description', function () {
|
172
|
+
env.it('should be another test', function() {
|
173
|
+
this.runs(function () {
|
174
|
+
this.expect(true).toEqual(false);
|
175
|
+
});
|
176
|
+
});
|
177
|
+
});
|
178
|
+
|
179
|
+
env.currentRunner().execute();
|
180
|
+
|
181
|
+
var results = env.currentRunner().results();
|
182
|
+
expect(results.totalCount).toEqual(2);
|
183
|
+
expect(results.passedCount).toEqual(1);
|
184
|
+
expect(results.failedCount).toEqual(1);
|
185
|
+
});
|
186
|
+
|
187
|
+
describe('reporting', function () {
|
188
|
+
var fakeReporter;
|
189
|
+
beforeEach(function () {
|
190
|
+
fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting", "reportRunnerResults"]);
|
191
|
+
env.addReporter(fakeReporter);
|
192
|
+
});
|
193
|
+
|
194
|
+
it('should report runner results when the runner has completed running', function() {
|
195
|
+
env.describe('one suite description', function () {
|
196
|
+
env.it('should be a test', function() {
|
197
|
+
this.runs(function () {
|
198
|
+
this.expect(true).toEqual(true);
|
199
|
+
});
|
200
|
+
});
|
201
|
+
});
|
202
|
+
|
203
|
+
env.describe('another suite description', function () {
|
204
|
+
env.it('should be another test', function() {
|
205
|
+
this.waits(200);
|
206
|
+
this.runs(function () {
|
207
|
+
this.expect(true).toEqual(false);
|
208
|
+
});
|
209
|
+
});
|
210
|
+
});
|
211
|
+
|
212
|
+
env.currentRunner().execute();
|
213
|
+
expect(fakeReporter.reportRunnerResults).not.toHaveBeenCalled();
|
214
|
+
fakeTimer.tick(200);
|
215
|
+
//This blows up the JSApiReporter.
|
216
|
+
//expect(fakeReporter.reportRunnerResults).toHaveBeenCalledWith(env.currentRunner);
|
217
|
+
expect(fakeReporter.reportRunnerResults).toHaveBeenCalled();
|
218
|
+
expect(fakeReporter.reportRunnerResults.mostRecentCall.args[0].results()).toEqual(env.currentRunner().results());
|
219
|
+
});
|
220
|
+
});
|
221
|
+
|
222
|
+
it("should report when the tests start running", function() {
|
223
|
+
var fakeReporter = jasmine.createSpyObj("fakeReporter", ["log", "reportRunnerStarting"]);
|
224
|
+
env.addReporter(fakeReporter);
|
225
|
+
|
226
|
+
|
227
|
+
var runner = new jasmine.Runner(env);
|
228
|
+
runner.arbitraryVariable = 'foo';
|
229
|
+
spyOn(runner.queue, 'start');
|
230
|
+
expect(fakeReporter.reportRunnerStarting).not.toHaveBeenCalled();
|
231
|
+
runner.execute();
|
232
|
+
expect(fakeReporter.reportRunnerStarting).toHaveBeenCalled();
|
233
|
+
var reportedRunner = fakeReporter.reportRunnerStarting.mostRecentCall.args[0];
|
234
|
+
expect(reportedRunner.arbitraryVariable).toEqual('foo');
|
235
|
+
expect(runner.queue.start).toHaveBeenCalled();
|
236
|
+
});
|
237
|
+
|
238
|
+
describe("when suites are nested", function() {
|
239
|
+
var suite1, suite2, suite3;
|
240
|
+
|
241
|
+
function suiteNames(suites) {
|
242
|
+
var suiteDescriptions = [];
|
243
|
+
for (var i = 0; i < suites.length; i++) {
|
244
|
+
suiteDescriptions.push(suites[i].getFullName());
|
245
|
+
}
|
246
|
+
return suiteDescriptions;
|
247
|
+
}
|
248
|
+
|
249
|
+
beforeEach(function() {
|
250
|
+
suite1 = env.describe("suite 1", function() {
|
251
|
+
suite2 = env.describe("suite 2", function() {
|
252
|
+
});
|
253
|
+
});
|
254
|
+
suite3 = env.describe("suite 3", function() {});
|
255
|
+
});
|
256
|
+
|
257
|
+
it("#suites should return a flat array of all suites, including nested suites", function() {
|
258
|
+
var suites = env.currentRunner().suites();
|
259
|
+
expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite2.getFullName(), suite3.getFullName()]);
|
260
|
+
});
|
261
|
+
|
262
|
+
it("#topLevelSuites should return a flat array of all top-level suites only", function() {
|
263
|
+
var suites = env.currentRunner().topLevelSuites();
|
264
|
+
expect(suiteNames(suites)).toEqual([suite1.getFullName(), suite3.getFullName()]);
|
265
|
+
});
|
266
|
+
});
|
267
|
+
});
|