js-test-driver-rails 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.gitmodules +6 -0
- data/Gemfile +2 -5
- data/Gemfile.lock +8 -9
- data/Rakefile +3 -28
- data/js-test-driver-rails.gemspec +25 -0
- data/lib/js_test_driver/version.rb +3 -0
- metadata +17 -183
- data/VERSION +0 -1
- data/vendor/jasmine-jstd-adapter/MIT.LICENSE +0 -22
- data/vendor/jasmine-jstd-adapter/README.md +0 -25
- data/vendor/jasmine-jstd-adapter/jsTestDriver.conf +0 -6
- data/vendor/jasmine-jstd-adapter/jsTestDriverIit.conf +0 -6
- data/vendor/jasmine-jstd-adapter/lib/jasmine/jasmine-0.11.1.js +0 -2343
- data/vendor/jasmine-jstd-adapter/lib/jstestdriver/JsTestDriver.jar +0 -0
- data/vendor/jasmine-jstd-adapter/server.sh +0 -1
- data/vendor/jasmine-jstd-adapter/src-test/iit/iitSpec.js +0 -46
- data/vendor/jasmine-jstd-adapter/src-test/tests.js +0 -89
- data/vendor/jasmine-jstd-adapter/src/JasmineAdapter.js +0 -186
- data/vendor/jasmine-jstd-adapter/test-iit.sh +0 -1
- data/vendor/jasmine-jstd-adapter/test-regular.sh +0 -2
- data/vendor/jasmine-jstd-adapter/test.sh +0 -2
- data/vendor/jasmine/Gemfile +0 -6
- data/vendor/jasmine/MIT.LICENSE +0 -20
- data/vendor/jasmine/README.markdown +0 -28
- data/vendor/jasmine/Rakefile +0 -182
- data/vendor/jasmine/cruise_config.rb +0 -21
- data/vendor/jasmine/example/SpecRunner.html +0 -27
- data/vendor/jasmine/example/spec/PlayerSpec.js +0 -58
- data/vendor/jasmine/example/spec/SpecHelper.js +0 -9
- data/vendor/jasmine/example/src/Player.js +0 -22
- data/vendor/jasmine/example/src/Song.js +0 -7
- data/vendor/jasmine/images/fail-16.png +0 -0
- data/vendor/jasmine/images/fail.png +0 -0
- data/vendor/jasmine/images/go-16.png +0 -0
- data/vendor/jasmine/images/go.png +0 -0
- data/vendor/jasmine/images/pending-16.png +0 -0
- data/vendor/jasmine/images/pending.png +0 -0
- data/vendor/jasmine/images/question-bk.png +0 -0
- data/vendor/jasmine/images/questionbk-16.png +0 -0
- data/vendor/jasmine/images/spinner.gif +0 -0
- data/vendor/jasmine/jsdoc-template/allclasses.tmpl +0 -17
- data/vendor/jasmine/jsdoc-template/allfiles.tmpl +0 -56
- data/vendor/jasmine/jsdoc-template/class.tmpl +0 -646
- data/vendor/jasmine/jsdoc-template/index.tmpl +0 -39
- data/vendor/jasmine/jsdoc-template/publish.js +0 -184
- data/vendor/jasmine/jsdoc-template/static/default.css +0 -162
- data/vendor/jasmine/jsdoc-template/static/header.html +0 -2
- data/vendor/jasmine/jsdoc-template/static/index.html +0 -19
- data/vendor/jasmine/jsdoc-template/symbol.tmpl +0 -35
- data/vendor/jasmine/lib/jasmine-html.js +0 -188
- data/vendor/jasmine/lib/jasmine.css +0 -166
- data/vendor/jasmine/lib/jasmine.js +0 -2421
- data/vendor/jasmine/lib/json2.js +0 -478
- data/vendor/jasmine/spec/runner.html +0 -80
- data/vendor/jasmine/spec/suites/BaseSpec.js +0 -27
- data/vendor/jasmine/spec/suites/CustomMatchersSpec.js +0 -97
- data/vendor/jasmine/spec/suites/EnvSpec.js +0 -158
- data/vendor/jasmine/spec/suites/ExceptionsSpec.js +0 -107
- data/vendor/jasmine/spec/suites/JsApiReporterSpec.js +0 -103
- data/vendor/jasmine/spec/suites/MatchersSpec.js +0 -795
- data/vendor/jasmine/spec/suites/MockClockSpec.js +0 -38
- data/vendor/jasmine/spec/suites/MultiReporterSpec.js +0 -45
- data/vendor/jasmine/spec/suites/NestedResultsSpec.js +0 -54
- data/vendor/jasmine/spec/suites/PrettyPrintSpec.js +0 -93
- data/vendor/jasmine/spec/suites/QueueSpec.js +0 -23
- data/vendor/jasmine/spec/suites/ReporterSpec.js +0 -56
- data/vendor/jasmine/spec/suites/RunnerSpec.js +0 -267
- data/vendor/jasmine/spec/suites/SpecRunningSpec.js +0 -1253
- data/vendor/jasmine/spec/suites/SpecSpec.js +0 -124
- data/vendor/jasmine/spec/suites/SpySpec.js +0 -201
- data/vendor/jasmine/spec/suites/SuiteSpec.js +0 -120
- data/vendor/jasmine/spec/suites/TrivialReporterSpec.js +0 -238
- data/vendor/jasmine/spec/suites/UtilSpec.js +0 -40
- data/vendor/jasmine/spec/suites/WaitsForBlockSpec.js +0 -87
- data/vendor/jasmine/src/Block.js +0 -22
- data/vendor/jasmine/src/Env.js +0 -264
- data/vendor/jasmine/src/JsApiReporter.js +0 -102
- data/vendor/jasmine/src/Matchers.js +0 -354
- data/vendor/jasmine/src/MultiReporter.js +0 -35
- data/vendor/jasmine/src/NestedResults.js +0 -80
- data/vendor/jasmine/src/PrettyPrinter.js +0 -122
- data/vendor/jasmine/src/Queue.js +0 -99
- data/vendor/jasmine/src/Reporter.js +0 -31
- data/vendor/jasmine/src/Runner.js +0 -77
- data/vendor/jasmine/src/Spec.js +0 -242
- data/vendor/jasmine/src/Suite.js +0 -82
- data/vendor/jasmine/src/WaitsBlock.js +0 -13
- data/vendor/jasmine/src/WaitsForBlock.js +0 -52
- data/vendor/jasmine/src/base.js +0 -589
- data/vendor/jasmine/src/html/TrivialReporter.js +0 -188
- data/vendor/jasmine/src/html/jasmine.css +0 -166
- data/vendor/jasmine/src/mock-timeout.js +0 -183
- data/vendor/jasmine/src/util.js +0 -67
- data/vendor/jasmine/src/version.json +0 -5
@@ -1,124 +0,0 @@
|
|
1
|
-
describe('Spec', function () {
|
2
|
-
var env, suite;
|
3
|
-
beforeEach(function() {
|
4
|
-
env = new jasmine.Env();
|
5
|
-
env.updateInterval = 0;
|
6
|
-
suite = new jasmine.Suite(env, 'suite 1');
|
7
|
-
});
|
8
|
-
|
9
|
-
describe('initialization', function () {
|
10
|
-
|
11
|
-
it('should raise an error if an env is not passed', function () {
|
12
|
-
try {
|
13
|
-
new jasmine.Spec();
|
14
|
-
}
|
15
|
-
catch (e) {
|
16
|
-
expect(e.message).toEqual('jasmine.Env() required');
|
17
|
-
}
|
18
|
-
});
|
19
|
-
|
20
|
-
it('should raise an error if a suite is not passed', function () {
|
21
|
-
try {
|
22
|
-
new jasmine.Spec(env);
|
23
|
-
}
|
24
|
-
catch (e) {
|
25
|
-
expect(e.message).toEqual('jasmine.Suite() required');
|
26
|
-
}
|
27
|
-
});
|
28
|
-
|
29
|
-
it('should assign sequential ids for specs belonging to the same env', function () {
|
30
|
-
var spec1 = new jasmine.Spec(env, suite);
|
31
|
-
var spec2 = new jasmine.Spec(env, suite);
|
32
|
-
var spec3 = new jasmine.Spec(env, suite);
|
33
|
-
expect(spec1.id).toEqual(0);
|
34
|
-
expect(spec2.id).toEqual(1);
|
35
|
-
expect(spec3.id).toEqual(2);
|
36
|
-
});
|
37
|
-
});
|
38
|
-
|
39
|
-
it('getFullName returns suite & spec description', function () {
|
40
|
-
var spec = new jasmine.Spec(env, suite, 'spec 1');
|
41
|
-
expect(spec.getFullName()).toEqual('suite 1 spec 1.')
|
42
|
-
});
|
43
|
-
|
44
|
-
describe('results', function () {
|
45
|
-
var spec, results;
|
46
|
-
beforeEach(function () {
|
47
|
-
spec = new jasmine.Spec(env, suite);
|
48
|
-
results = spec.results();
|
49
|
-
expect(results.totalCount).toEqual(0);
|
50
|
-
spec.runs(function () {
|
51
|
-
this.expect(true).toEqual(true);
|
52
|
-
this.expect(true).toEqual(true);
|
53
|
-
});
|
54
|
-
});
|
55
|
-
|
56
|
-
|
57
|
-
it('results shows the total number of expectations for each spec after execution', function () {
|
58
|
-
expect(results.totalCount).toEqual(0);
|
59
|
-
spec.execute();
|
60
|
-
expect(results.totalCount).toEqual(2);
|
61
|
-
});
|
62
|
-
|
63
|
-
it('results shows the number of passed expectations for each spec after execution', function () {
|
64
|
-
expect(results.passedCount).toEqual(0);
|
65
|
-
spec.execute();
|
66
|
-
expect(results.passedCount).toEqual(2);
|
67
|
-
});
|
68
|
-
|
69
|
-
it('results shows the number of failed expectations for each spec after execution', function () {
|
70
|
-
spec.runs(function () {
|
71
|
-
this.expect(true).toEqual(false);
|
72
|
-
});
|
73
|
-
expect(results.failedCount).toEqual(0);
|
74
|
-
spec.execute();
|
75
|
-
expect(results.failedCount).toEqual(1);
|
76
|
-
});
|
77
|
-
|
78
|
-
describe('results.passed', function () {
|
79
|
-
it('is true if all spec expectations pass', function () {
|
80
|
-
spec.runs(function () {
|
81
|
-
this.expect(true).toEqual(true);
|
82
|
-
});
|
83
|
-
spec.execute();
|
84
|
-
expect(results.passed()).toEqual(true);
|
85
|
-
});
|
86
|
-
|
87
|
-
it('is false if one spec expectation fails', function () {
|
88
|
-
spec.runs(function () {
|
89
|
-
this.expect(true).toEqual(false);
|
90
|
-
});
|
91
|
-
spec.execute();
|
92
|
-
expect(results.passed()).toEqual(false);
|
93
|
-
});
|
94
|
-
|
95
|
-
it('a spec with no expectations will return true', function () {
|
96
|
-
var specWithoutExpectations = new jasmine.Spec(env, suite);
|
97
|
-
specWithoutExpectations.runs(function() {
|
98
|
-
|
99
|
-
});
|
100
|
-
specWithoutExpectations.execute();
|
101
|
-
expect(results.passed()).toEqual(true);
|
102
|
-
});
|
103
|
-
|
104
|
-
it('an unexecuted spec will return true', function () {
|
105
|
-
expect(results.passed()).toEqual(true);
|
106
|
-
});
|
107
|
-
});
|
108
|
-
|
109
|
-
it("includes log messages, which may contain arbitary objects", function() {
|
110
|
-
spec.runs(function() {
|
111
|
-
this.log("here's some log message", {key: 'value'}, 123);
|
112
|
-
});
|
113
|
-
spec.execute();
|
114
|
-
var items = results.getItems();
|
115
|
-
expect(items).toEqual([
|
116
|
-
jasmine.any(jasmine.ExpectationResult),
|
117
|
-
jasmine.any(jasmine.ExpectationResult),
|
118
|
-
jasmine.any(jasmine.MessageResult)
|
119
|
-
]);
|
120
|
-
var logResult = items[2];
|
121
|
-
expect(logResult.values).toEqual(["here's some log message", {key: 'value'}, 123]);
|
122
|
-
});
|
123
|
-
});
|
124
|
-
});
|
@@ -1,201 +0,0 @@
|
|
1
|
-
describe('Spies', function () {
|
2
|
-
it('should replace the specified function with a spy object', function() {
|
3
|
-
var originalFunctionWasCalled = false;
|
4
|
-
var TestClass = {
|
5
|
-
someFunction: function() {
|
6
|
-
originalFunctionWasCalled = true;
|
7
|
-
}
|
8
|
-
};
|
9
|
-
this.spyOn(TestClass, 'someFunction');
|
10
|
-
|
11
|
-
expect(TestClass.someFunction.wasCalled).toEqual(false);
|
12
|
-
expect(TestClass.someFunction.callCount).toEqual(0);
|
13
|
-
TestClass.someFunction('foo');
|
14
|
-
expect(TestClass.someFunction.wasCalled).toEqual(true);
|
15
|
-
expect(TestClass.someFunction.callCount).toEqual(1);
|
16
|
-
expect(TestClass.someFunction.mostRecentCall.args).toEqual(['foo']);
|
17
|
-
expect(TestClass.someFunction.mostRecentCall.object).toEqual(TestClass);
|
18
|
-
expect(originalFunctionWasCalled).toEqual(false);
|
19
|
-
|
20
|
-
TestClass.someFunction('bar');
|
21
|
-
expect(TestClass.someFunction.callCount).toEqual(2);
|
22
|
-
expect(TestClass.someFunction.mostRecentCall.args).toEqual(['bar']);
|
23
|
-
});
|
24
|
-
|
25
|
-
it('should allow you to view args for a particular call', function() {
|
26
|
-
var originalFunctionWasCalled = false;
|
27
|
-
var TestClass = {
|
28
|
-
someFunction: function() {
|
29
|
-
originalFunctionWasCalled = true;
|
30
|
-
}
|
31
|
-
};
|
32
|
-
this.spyOn(TestClass, 'someFunction');
|
33
|
-
|
34
|
-
TestClass.someFunction('foo');
|
35
|
-
TestClass.someFunction('bar');
|
36
|
-
expect(TestClass.someFunction.calls[0].args).toEqual(['foo']);
|
37
|
-
expect(TestClass.someFunction.calls[1].args).toEqual(['bar']);
|
38
|
-
expect(TestClass.someFunction.mostRecentCall.args).toEqual(['bar']);
|
39
|
-
});
|
40
|
-
|
41
|
-
it('should be possible to call through to the original method, or return a specific result', function() {
|
42
|
-
var originalFunctionWasCalled = false;
|
43
|
-
var passedArgs;
|
44
|
-
var passedObj;
|
45
|
-
var TestClass = {
|
46
|
-
someFunction: function() {
|
47
|
-
originalFunctionWasCalled = true;
|
48
|
-
passedArgs = arguments;
|
49
|
-
passedObj = this;
|
50
|
-
return "return value from original function";
|
51
|
-
}
|
52
|
-
};
|
53
|
-
|
54
|
-
this.spyOn(TestClass, 'someFunction').andCallThrough();
|
55
|
-
var result = TestClass.someFunction('arg1', 'arg2');
|
56
|
-
expect(result).toEqual("return value from original function");
|
57
|
-
expect(originalFunctionWasCalled).toEqual(true);
|
58
|
-
expect(passedArgs).toEqual(['arg1', 'arg2']);
|
59
|
-
expect(passedObj).toEqual(TestClass);
|
60
|
-
expect(TestClass.someFunction.wasCalled).toEqual(true);
|
61
|
-
});
|
62
|
-
|
63
|
-
it('should be possible to return a specific value', function() {
|
64
|
-
var originalFunctionWasCalled = false;
|
65
|
-
var TestClass = {
|
66
|
-
someFunction: function() {
|
67
|
-
originalFunctionWasCalled = true;
|
68
|
-
return "return value from original function";
|
69
|
-
}
|
70
|
-
};
|
71
|
-
|
72
|
-
this.spyOn(TestClass, 'someFunction').andReturn("some value");
|
73
|
-
originalFunctionWasCalled = false;
|
74
|
-
var result = TestClass.someFunction('arg1', 'arg2');
|
75
|
-
expect(result).toEqual("some value");
|
76
|
-
expect(originalFunctionWasCalled).toEqual(false);
|
77
|
-
});
|
78
|
-
|
79
|
-
it('should be possible to throw a specific error', function() {
|
80
|
-
var originalFunctionWasCalled = false;
|
81
|
-
var TestClass = {
|
82
|
-
someFunction: function() {
|
83
|
-
originalFunctionWasCalled = true;
|
84
|
-
return "return value from original function";
|
85
|
-
}
|
86
|
-
};
|
87
|
-
|
88
|
-
this.spyOn(TestClass, 'someFunction').andThrow(new Error('fake error'));
|
89
|
-
var exception;
|
90
|
-
try {
|
91
|
-
TestClass.someFunction('arg1', 'arg2');
|
92
|
-
} catch (e) {
|
93
|
-
exception = e;
|
94
|
-
}
|
95
|
-
expect(exception.message).toEqual('fake error');
|
96
|
-
expect(originalFunctionWasCalled).toEqual(false);
|
97
|
-
});
|
98
|
-
|
99
|
-
it('should be possible to call a specified function', function() {
|
100
|
-
var originalFunctionWasCalled = false;
|
101
|
-
var fakeFunctionWasCalled = false;
|
102
|
-
var passedArgs;
|
103
|
-
var passedObj;
|
104
|
-
var TestClass = {
|
105
|
-
someFunction: function() {
|
106
|
-
originalFunctionWasCalled = true;
|
107
|
-
return "return value from original function";
|
108
|
-
}
|
109
|
-
};
|
110
|
-
|
111
|
-
this.spyOn(TestClass, 'someFunction').andCallFake(function() {
|
112
|
-
fakeFunctionWasCalled = true;
|
113
|
-
passedArgs = arguments;
|
114
|
-
passedObj = this;
|
115
|
-
return "return value from fake function";
|
116
|
-
});
|
117
|
-
|
118
|
-
var result = TestClass.someFunction('arg1', 'arg2');
|
119
|
-
expect(result).toEqual("return value from fake function");
|
120
|
-
expect(originalFunctionWasCalled).toEqual(false);
|
121
|
-
expect(fakeFunctionWasCalled).toEqual(true);
|
122
|
-
expect(passedArgs).toEqual(['arg1', 'arg2']);
|
123
|
-
expect(passedObj).toEqual(TestClass);
|
124
|
-
expect(TestClass.someFunction.wasCalled).toEqual(true);
|
125
|
-
});
|
126
|
-
|
127
|
-
it('is torn down when this.removeAllSpies is called', function() {
|
128
|
-
var originalFunctionWasCalled = false;
|
129
|
-
var TestClass = {
|
130
|
-
someFunction: function() {
|
131
|
-
originalFunctionWasCalled = true;
|
132
|
-
}
|
133
|
-
};
|
134
|
-
this.spyOn(TestClass, 'someFunction');
|
135
|
-
|
136
|
-
TestClass.someFunction('foo');
|
137
|
-
expect(originalFunctionWasCalled).toEqual(false);
|
138
|
-
|
139
|
-
this.removeAllSpies();
|
140
|
-
|
141
|
-
TestClass.someFunction('foo');
|
142
|
-
expect(originalFunctionWasCalled).toEqual(true);
|
143
|
-
});
|
144
|
-
|
145
|
-
it('calls removeAllSpies during spec finish', function() {
|
146
|
-
var test = new jasmine.Spec(new jasmine.Env(), {}, 'sample test');
|
147
|
-
|
148
|
-
this.spyOn(test, 'removeAllSpies');
|
149
|
-
|
150
|
-
test.finish();
|
151
|
-
|
152
|
-
expect(test.removeAllSpies).wasCalled();
|
153
|
-
});
|
154
|
-
|
155
|
-
it('throws an exception when some method is spied on twice', function() {
|
156
|
-
var TestClass = { someFunction: function() {
|
157
|
-
} };
|
158
|
-
this.spyOn(TestClass, 'someFunction');
|
159
|
-
var exception;
|
160
|
-
try {
|
161
|
-
this.spyOn(TestClass, 'someFunction');
|
162
|
-
} catch (e) {
|
163
|
-
exception = e;
|
164
|
-
}
|
165
|
-
expect(exception).toBeDefined();
|
166
|
-
});
|
167
|
-
|
168
|
-
it('should be able to reset a spy', function() {
|
169
|
-
var TestClass = { someFunction: function() {} };
|
170
|
-
this.spyOn(TestClass, 'someFunction');
|
171
|
-
|
172
|
-
expect(TestClass.someFunction).not.toHaveBeenCalled();
|
173
|
-
TestClass.someFunction();
|
174
|
-
expect(TestClass.someFunction).toHaveBeenCalled();
|
175
|
-
TestClass.someFunction.reset();
|
176
|
-
expect(TestClass.someFunction).not.toHaveBeenCalled();
|
177
|
-
expect(TestClass.someFunction.callCount).toEqual(0);
|
178
|
-
});
|
179
|
-
|
180
|
-
describe("createSpyObj", function() {
|
181
|
-
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
|
182
|
-
var spyObj = jasmine.createSpyObj('BaseName', ['method1', 'method2']);
|
183
|
-
expect(spyObj).toEqual({ method1: jasmine.any(Function), method2: jasmine.any(Function)});
|
184
|
-
expect(spyObj.method1.identity).toEqual('BaseName.method1');
|
185
|
-
expect(spyObj.method2.identity).toEqual('BaseName.method2');
|
186
|
-
});
|
187
|
-
|
188
|
-
it("should throw if you do not pass an array argument", function() {
|
189
|
-
expect(function() {
|
190
|
-
jasmine.createSpyObj('BaseName');
|
191
|
-
}).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
|
192
|
-
});
|
193
|
-
|
194
|
-
it("should throw if you pass an empty array argument", function() {
|
195
|
-
expect(function() {
|
196
|
-
jasmine.createSpyObj('BaseName');
|
197
|
-
}).toThrow('createSpyObj requires a non-empty array of method names to create spies for');
|
198
|
-
});
|
199
|
-
});
|
200
|
-
|
201
|
-
});
|
@@ -1,120 +0,0 @@
|
|
1
|
-
describe('Suite', 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('Specs', function () {
|
17
|
-
var suite;
|
18
|
-
|
19
|
-
beforeEach(function() {
|
20
|
-
suite = env.describe('Suite 1', function () {
|
21
|
-
env.it('Spec 1', function() {
|
22
|
-
this.runs(function () {
|
23
|
-
this.expect(true).toEqual(true);
|
24
|
-
});
|
25
|
-
});
|
26
|
-
env.it('Spec 2', function() {
|
27
|
-
this.runs(function () {
|
28
|
-
this.expect(true).toEqual(true);
|
29
|
-
});
|
30
|
-
});
|
31
|
-
env.describe('Suite 2', function () {
|
32
|
-
env.it('Spec 3', function() {
|
33
|
-
this.runs(function () {
|
34
|
-
this.expect(true).toEqual(true);
|
35
|
-
});
|
36
|
-
});
|
37
|
-
});
|
38
|
-
env.it('Spec 4', function() {
|
39
|
-
this.runs(function () {
|
40
|
-
this.expect(true).toEqual(true);
|
41
|
-
});
|
42
|
-
});
|
43
|
-
});
|
44
|
-
});
|
45
|
-
|
46
|
-
it('#specs should return all immediate children that are specs.', function () {
|
47
|
-
var suiteSpecs = suite.specs();
|
48
|
-
expect(suiteSpecs.length).toEqual(3);
|
49
|
-
expect(suiteSpecs[0].description).toEqual('Spec 1');
|
50
|
-
expect(suiteSpecs[1].description).toEqual('Spec 2');
|
51
|
-
expect(suiteSpecs[2].description).toEqual('Spec 4');
|
52
|
-
});
|
53
|
-
|
54
|
-
it("#suites should return all immediate children that are suites.", function() {
|
55
|
-
var nestedSuites = suite.suites();
|
56
|
-
expect(nestedSuites.length).toEqual(1);
|
57
|
-
expect(nestedSuites[0].description).toEqual('Suite 2');
|
58
|
-
});
|
59
|
-
|
60
|
-
it("#children should return all immediate children including suites and specs.", function() {
|
61
|
-
var children = suite.children();
|
62
|
-
expect(children.length).toEqual(4);
|
63
|
-
expect(children[0].description).toEqual('Spec 1');
|
64
|
-
expect(children[1].description).toEqual('Spec 2');
|
65
|
-
expect(children[2].description).toEqual('Suite 2');
|
66
|
-
expect(children[3].description).toEqual('Spec 4');
|
67
|
-
});
|
68
|
-
});
|
69
|
-
|
70
|
-
describe('SpecCount', function () {
|
71
|
-
|
72
|
-
it('should keep a count of the number of specs that are run', function() {
|
73
|
-
var suite = env.describe('one suite description', function () {
|
74
|
-
env.it('should be a test', function() {
|
75
|
-
this.runs(function () {
|
76
|
-
this.expect(true).toEqual(true);
|
77
|
-
});
|
78
|
-
});
|
79
|
-
env.it('should be another test', function() {
|
80
|
-
this.runs(function () {
|
81
|
-
this.expect(true).toEqual(true);
|
82
|
-
});
|
83
|
-
});
|
84
|
-
env.it('should be a third test', function() {
|
85
|
-
this.runs(function () {
|
86
|
-
this.expect(true).toEqual(true);
|
87
|
-
});
|
88
|
-
});
|
89
|
-
});
|
90
|
-
|
91
|
-
expect(suite.specs().length).toEqual(3);
|
92
|
-
});
|
93
|
-
|
94
|
-
it('specCount should be correct even with runs/waits blocks', function() {
|
95
|
-
var suite = env.describe('one suite description', function () {
|
96
|
-
env.it('should be a test', function() {
|
97
|
-
this.runs(function () {
|
98
|
-
this.expect(true).toEqual(true);
|
99
|
-
});
|
100
|
-
});
|
101
|
-
env.it('should be another test', function() {
|
102
|
-
this.runs(function () {
|
103
|
-
this.expect(true).toEqual(true);
|
104
|
-
});
|
105
|
-
this.waits(10);
|
106
|
-
this.runs(function () {
|
107
|
-
this.expect(true).toEqual(true);
|
108
|
-
});
|
109
|
-
});
|
110
|
-
env.it('should be a third test', function() {
|
111
|
-
this.runs(function () {
|
112
|
-
this.expect(true).toEqual(true);
|
113
|
-
});
|
114
|
-
});
|
115
|
-
});
|
116
|
-
|
117
|
-
expect(suite.specs().length).toEqual(3);
|
118
|
-
});
|
119
|
-
});
|
120
|
-
});
|
@@ -1,238 +0,0 @@
|
|
1
|
-
describe("TrivialReporter", function() {
|
2
|
-
var env;
|
3
|
-
var trivialReporter;
|
4
|
-
var body;
|
5
|
-
var fakeDocument;
|
6
|
-
|
7
|
-
beforeEach(function() {
|
8
|
-
env = new jasmine.Env();
|
9
|
-
env.updateInterval = 0;
|
10
|
-
|
11
|
-
body = document.createElement("body");
|
12
|
-
fakeDocument = { body: body, location: { search: "" } };
|
13
|
-
trivialReporter = new jasmine.TrivialReporter(fakeDocument);
|
14
|
-
});
|
15
|
-
|
16
|
-
function fakeSpec(name) {
|
17
|
-
return {
|
18
|
-
getFullName: function() {
|
19
|
-
return name;
|
20
|
-
}
|
21
|
-
};
|
22
|
-
}
|
23
|
-
|
24
|
-
function findElements(divs, withClass) {
|
25
|
-
var els = [];
|
26
|
-
for (var i = 0; i < divs.length; i++) {
|
27
|
-
if (divs[i].className == withClass) els.push(divs[i]);
|
28
|
-
}
|
29
|
-
return els;
|
30
|
-
}
|
31
|
-
|
32
|
-
function findElement(divs, withClass) {
|
33
|
-
var els = findElements(divs, withClass);
|
34
|
-
if (els.length > 0) return els[0];
|
35
|
-
throw new Error("couldn't find div with class " + withClass);
|
36
|
-
}
|
37
|
-
|
38
|
-
it("should run only specs beginning with spec parameter", function() {
|
39
|
-
fakeDocument.location.search = "?spec=run%20this";
|
40
|
-
expect(trivialReporter.specFilter(fakeSpec("run this"))).toBeTruthy();
|
41
|
-
expect(trivialReporter.specFilter(fakeSpec("not the right spec"))).toBeFalsy();
|
42
|
-
expect(trivialReporter.specFilter(fakeSpec("not run this"))).toBeFalsy();
|
43
|
-
});
|
44
|
-
|
45
|
-
it("should display empty divs for every suite when the runner is starting", function() {
|
46
|
-
trivialReporter.reportRunnerStarting({
|
47
|
-
env: env,
|
48
|
-
suites: function() {
|
49
|
-
return [ new jasmine.Suite({}, "suite 1", null, null) ];
|
50
|
-
}
|
51
|
-
});
|
52
|
-
|
53
|
-
var divs = findElements(body.getElementsByTagName("div"), "suite");
|
54
|
-
expect(divs.length).toEqual(1);
|
55
|
-
expect(divs[0].innerHTML).toContain("suite 1");
|
56
|
-
});
|
57
|
-
|
58
|
-
describe('Matcher reporting', function () {
|
59
|
-
var getResultMessageDiv = function (body) {
|
60
|
-
var divs = body.getElementsByTagName("div");
|
61
|
-
for (var i = 0; i < divs.length; i++) {
|
62
|
-
if (divs[i].className.match(/resultMessage/)) {
|
63
|
-
return divs[i];
|
64
|
-
}
|
65
|
-
}
|
66
|
-
};
|
67
|
-
|
68
|
-
var runner, spec, fakeTimer;
|
69
|
-
beforeEach(function () {
|
70
|
-
fakeTimer = new jasmine.FakeTimer();
|
71
|
-
env.setTimeout = fakeTimer.setTimeout;
|
72
|
-
env.clearTimeout = fakeTimer.clearTimeout;
|
73
|
-
env.setInterval = fakeTimer.setInterval;
|
74
|
-
env.clearInterval = fakeTimer.clearInterval;
|
75
|
-
runner = env.currentRunner();
|
76
|
-
var suite = new jasmine.Suite(env, 'some suite');
|
77
|
-
runner.add(suite);
|
78
|
-
spec = new jasmine.Spec(env, suite, 'some spec');
|
79
|
-
suite.add(spec);
|
80
|
-
fakeDocument.location.search = "?";
|
81
|
-
env.addReporter(trivialReporter);
|
82
|
-
});
|
83
|
-
|
84
|
-
describe('toContain', function () {
|
85
|
-
it('should show actual and expected', function () {
|
86
|
-
spec.runs(function () {
|
87
|
-
this.expect('foo').toContain('bar');
|
88
|
-
});
|
89
|
-
runner.execute();
|
90
|
-
fakeTimer.tick(0);
|
91
|
-
|
92
|
-
var resultEl = getResultMessageDiv(body);
|
93
|
-
expect(resultEl.innerHTML).toMatch(/foo/);
|
94
|
-
expect(resultEl.innerHTML).toMatch(/bar/);
|
95
|
-
});
|
96
|
-
});
|
97
|
-
});
|
98
|
-
|
99
|
-
|
100
|
-
describe("failure messages (integration)", function () {
|
101
|
-
var spec, results, expectationResult;
|
102
|
-
|
103
|
-
beforeEach(function() {
|
104
|
-
results = {
|
105
|
-
passed: function() {
|
106
|
-
return false;
|
107
|
-
},
|
108
|
-
getItems: function() {
|
109
|
-
}};
|
110
|
-
|
111
|
-
var suite1 = new jasmine.Suite(env, "suite 1", null, null);
|
112
|
-
|
113
|
-
spec = {
|
114
|
-
suite: suite1,
|
115
|
-
getFullName: function() {
|
116
|
-
return "foo";
|
117
|
-
},
|
118
|
-
results: function() {
|
119
|
-
return results;
|
120
|
-
}
|
121
|
-
};
|
122
|
-
|
123
|
-
trivialReporter.reportRunnerStarting({
|
124
|
-
env: env,
|
125
|
-
suites: function() {
|
126
|
-
return [ suite1 ];
|
127
|
-
}
|
128
|
-
});
|
129
|
-
});
|
130
|
-
|
131
|
-
it("should add the failure message to the DOM (non-toEquals matchers)", function() {
|
132
|
-
expectationResult = new jasmine.ExpectationResult({
|
133
|
-
matcherName: "toBeNull", passed: false, message: "Expected 'a' to be null, but it was not"
|
134
|
-
});
|
135
|
-
|
136
|
-
spyOn(results, 'getItems').andReturn([expectationResult]);
|
137
|
-
|
138
|
-
trivialReporter.reportSpecResults(spec);
|
139
|
-
|
140
|
-
var divs = body.getElementsByTagName("div");
|
141
|
-
var errorDiv = findElement(divs, 'resultMessage fail');
|
142
|
-
expect(errorDiv.innerHTML).toEqual("Expected 'a' to be null, but it was not");
|
143
|
-
});
|
144
|
-
|
145
|
-
it("should add the failure message to the DOM (non-toEquals matchers) html escaping", function() {
|
146
|
-
expectationResult = new jasmine.ExpectationResult({
|
147
|
-
matcherName: "toBeNull", passed: false, message: "Expected '1 < 2' to <b>e null, & it was not"
|
148
|
-
});
|
149
|
-
|
150
|
-
spyOn(results, 'getItems').andReturn([expectationResult]);
|
151
|
-
|
152
|
-
trivialReporter.reportSpecResults(spec);
|
153
|
-
|
154
|
-
var divs = body.getElementsByTagName("div");
|
155
|
-
var errorDiv = findElement(divs, 'resultMessage fail');
|
156
|
-
expect(errorDiv.innerHTML).toEqual("Expected '1 < 2' to <b>e null, & it was not");
|
157
|
-
});
|
158
|
-
});
|
159
|
-
|
160
|
-
describe("log messages", function() {
|
161
|
-
it("should appear in the report", function() {
|
162
|
-
env.describe("suite", function() {
|
163
|
-
env.it("will have log messages", function() {
|
164
|
-
this.log("this is a", "multipart log message");
|
165
|
-
});
|
166
|
-
});
|
167
|
-
|
168
|
-
env.addReporter(trivialReporter);
|
169
|
-
env.execute();
|
170
|
-
|
171
|
-
var divs = body.getElementsByTagName("div");
|
172
|
-
var errorDiv = findElement(divs, 'resultMessage log');
|
173
|
-
expect(errorDiv.innerHTML).toEqual("this is a multipart log message");
|
174
|
-
});
|
175
|
-
|
176
|
-
xit("should work on IE without console.log.apply", function() {
|
177
|
-
});
|
178
|
-
});
|
179
|
-
|
180
|
-
describe("duplicate example names", function() {
|
181
|
-
it("should report failures correctly", function() {
|
182
|
-
var suite1 = env.describe("suite", function() {
|
183
|
-
env.it("will have log messages", function() {
|
184
|
-
this.log("this one fails!");
|
185
|
-
this.expect(true).toBeFalsy();
|
186
|
-
});
|
187
|
-
});
|
188
|
-
|
189
|
-
var suite2 = env.describe("suite", function() {
|
190
|
-
env.it("will have log messages", function() {
|
191
|
-
this.log("this one passes!");
|
192
|
-
this.expect(true).toBeTruthy();
|
193
|
-
});
|
194
|
-
});
|
195
|
-
|
196
|
-
env.addReporter(trivialReporter);
|
197
|
-
env.execute();
|
198
|
-
|
199
|
-
var divs = body.getElementsByTagName("div");
|
200
|
-
var passedSpecDiv = findElement(divs, 'suite passed');
|
201
|
-
expect(passedSpecDiv.className).toEqual('suite passed');
|
202
|
-
expect(passedSpecDiv.innerHTML).toContain("this one passes!");
|
203
|
-
expect(passedSpecDiv.innerHTML).not.toContain("this one fails!");
|
204
|
-
|
205
|
-
var failedSpecDiv = findElement(divs, 'suite failed');
|
206
|
-
expect(failedSpecDiv.className).toEqual('suite failed');
|
207
|
-
expect(failedSpecDiv.innerHTML).toContain("this one fails!");
|
208
|
-
expect(failedSpecDiv.innerHTML).not.toContain("this one passes!");
|
209
|
-
});
|
210
|
-
});
|
211
|
-
|
212
|
-
describe('#reportSpecStarting', function() {
|
213
|
-
var spec1;
|
214
|
-
beforeEach(function () {
|
215
|
-
env.describe("suite 1", function() {
|
216
|
-
spec1 = env.it("spec 1", function() {
|
217
|
-
});
|
218
|
-
});
|
219
|
-
});
|
220
|
-
|
221
|
-
it('DOES NOT log running specs by default', function() {
|
222
|
-
spyOn(trivialReporter, 'log');
|
223
|
-
|
224
|
-
trivialReporter.reportSpecStarting(spec1);
|
225
|
-
|
226
|
-
expect(trivialReporter.log).not.toHaveBeenCalled();
|
227
|
-
});
|
228
|
-
|
229
|
-
it('logs running specs when log_running_specs is true', function() {
|
230
|
-
trivialReporter.logRunningSpecs = true;
|
231
|
-
spyOn(trivialReporter, 'log');
|
232
|
-
|
233
|
-
trivialReporter.reportSpecStarting(spec1);
|
234
|
-
|
235
|
-
expect(trivialReporter.log).toHaveBeenCalledWith('>> Jasmine Running suite 1 spec 1...');
|
236
|
-
});
|
237
|
-
});
|
238
|
-
});
|