jasmine-core 2.0.2 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/console/console.js +26 -2
- data/lib/jasmine-core.js +31 -23
- data/lib/jasmine-core/boot.js +1 -1
- data/lib/jasmine-core/boot/boot.js +1 -1
- data/lib/jasmine-core/example/node_example/spec/PlayerSpec.js +2 -2
- data/lib/jasmine-core/jasmine-html.js +16 -2
- data/lib/jasmine-core/jasmine.css +11 -10
- data/lib/jasmine-core/jasmine.js +709 -395
- data/lib/jasmine-core/json2.js +73 -62
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +39 -8
- data/lib/jasmine-core/spec/core/ClockSpec.js +19 -1
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +13 -0
- data/lib/jasmine-core/spec/core/EnvSpec.js +0 -63
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +15 -53
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +37 -0
- data/lib/jasmine-core/spec/core/MockDateSpec.js +1 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +8 -2
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +91 -66
- data/lib/jasmine-core/spec/core/SpecSpec.js +25 -26
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +55 -0
- data/lib/jasmine-core/spec/core/SpySpec.js +10 -0
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +13 -0
- data/lib/jasmine-core/spec/core/SuiteSpec.js +108 -10
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +34 -32
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +950 -35
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +279 -3
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +10 -1
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +5 -5
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +30 -2
- data/lib/jasmine-core/spec/node_suite.js +195 -0
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +104 -0
- data/lib/jasmine-core/version.rb +1 -1
- metadata +6 -3
@@ -14,7 +14,7 @@ describe("Spec", function() {
|
|
14
14
|
expect(j$.Spec.isPendingSpecException(fakeError)).toBe(true);
|
15
15
|
});
|
16
16
|
|
17
|
-
it("#isPendingSpecException returns
|
17
|
+
it("#isPendingSpecException returns false for not a pending spec exception", function() {
|
18
18
|
var e = new Error("foo");
|
19
19
|
|
20
20
|
expect(j$.Spec.isPendingSpecException(e)).toBe(false);
|
@@ -29,7 +29,7 @@ describe("Spec", function() {
|
|
29
29
|
spec = new j$.Spec({
|
30
30
|
description: 'my test',
|
31
31
|
id: 'some-id',
|
32
|
-
fn: function() {},
|
32
|
+
queueableFn: { fn: function() {} },
|
33
33
|
queueRunnerFactory: fakeQueueRunner
|
34
34
|
});
|
35
35
|
|
@@ -44,7 +44,7 @@ describe("Spec", function() {
|
|
44
44
|
spec = new j$.Spec({
|
45
45
|
id: 123,
|
46
46
|
description: 'foo bar',
|
47
|
-
fn: function() {},
|
47
|
+
queueableFn: { fn: function() {} },
|
48
48
|
onStart: startCallback,
|
49
49
|
queueRunnerFactory: fakeQueueRunner
|
50
50
|
});
|
@@ -66,7 +66,7 @@ describe("Spec", function() {
|
|
66
66
|
expect(beforesWereCalled).toBe(false);
|
67
67
|
}),
|
68
68
|
spec = new j$.Spec({
|
69
|
-
fn: function() {},
|
69
|
+
queueableFn: { fn: function() {} },
|
70
70
|
beforeFns: function() {
|
71
71
|
return [function() {
|
72
72
|
beforesWereCalled = true
|
@@ -85,25 +85,22 @@ describe("Spec", function() {
|
|
85
85
|
var fakeQueueRunner = jasmine.createSpy('fakeQueueRunner'),
|
86
86
|
before = jasmine.createSpy('before'),
|
87
87
|
after = jasmine.createSpy('after'),
|
88
|
-
|
88
|
+
queueableFn = { fn: jasmine.createSpy('test body').and.callFake(function() {
|
89
89
|
expect(before).toHaveBeenCalled();
|
90
90
|
expect(after).not.toHaveBeenCalled();
|
91
|
-
}),
|
91
|
+
}) },
|
92
92
|
spec = new j$.Spec({
|
93
|
-
|
94
|
-
|
95
|
-
return [before]
|
96
|
-
},
|
97
|
-
afterFns: function() {
|
98
|
-
return [after]
|
93
|
+
queueableFn: queueableFn,
|
94
|
+
beforeAndAfterFns: function() {
|
95
|
+
return {befores: [before], afters: [after]}
|
99
96
|
},
|
100
97
|
queueRunnerFactory: fakeQueueRunner
|
101
98
|
});
|
102
99
|
|
103
100
|
spec.execute();
|
104
101
|
|
105
|
-
var allSpecFns = fakeQueueRunner.calls.mostRecent().args[0].
|
106
|
-
expect(allSpecFns).toEqual([before,
|
102
|
+
var allSpecFns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
|
103
|
+
expect(allSpecFns).toEqual([before, queueableFn, after]);
|
107
104
|
});
|
108
105
|
|
109
106
|
it("is marked pending if created without a function body", function() {
|
@@ -113,7 +110,7 @@ describe("Spec", function() {
|
|
113
110
|
resultCallback = jasmine.createSpy('resultCallback'),
|
114
111
|
spec = new j$.Spec({
|
115
112
|
onStart: startCallback,
|
116
|
-
fn: null,
|
113
|
+
queueableFn: { fn: null },
|
117
114
|
resultCallback: resultCallback,
|
118
115
|
queueRunnerFactory: fakeQueueRunner
|
119
116
|
});
|
@@ -129,7 +126,7 @@ describe("Spec", function() {
|
|
129
126
|
resultCallback = jasmine.createSpy('resultCallback'),
|
130
127
|
spec = new j$.Spec({
|
131
128
|
onStart:startCallback,
|
132
|
-
fn: specBody,
|
129
|
+
queueableFn: { fn: specBody },
|
133
130
|
resultCallback: resultCallback,
|
134
131
|
queueRunnerFactory: fakeQueueRunner
|
135
132
|
});
|
@@ -158,7 +155,8 @@ describe("Spec", function() {
|
|
158
155
|
getSpecName: function() {
|
159
156
|
return "a suite with a spec"
|
160
157
|
},
|
161
|
-
queueRunnerFactory: fakeQueueRunner
|
158
|
+
queueRunnerFactory: fakeQueueRunner,
|
159
|
+
queueableFn: { fn: null }
|
162
160
|
});
|
163
161
|
|
164
162
|
spec.pend();
|
@@ -183,7 +181,7 @@ describe("Spec", function() {
|
|
183
181
|
it("should call the done callback on execution complete", function() {
|
184
182
|
var done = jasmine.createSpy('done callback'),
|
185
183
|
spec = new j$.Spec({
|
186
|
-
fn: function() {},
|
184
|
+
queueableFn: { fn: function() {} },
|
187
185
|
catchExceptions: function() { return false; },
|
188
186
|
resultCallback: function() {},
|
189
187
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); }
|
@@ -194,19 +192,19 @@ describe("Spec", function() {
|
|
194
192
|
expect(done).toHaveBeenCalled();
|
195
193
|
});
|
196
194
|
|
197
|
-
it("#status returns passing by default", function(){
|
198
|
-
var spec = new j$.Spec({ fn:
|
199
|
-
expect(spec.status()).toBe(
|
195
|
+
it("#status returns passing by default", function() {
|
196
|
+
var spec = new j$.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
197
|
+
expect(spec.status()).toBe('passed');
|
200
198
|
});
|
201
199
|
|
202
200
|
it("#status returns passed if all expectations in the spec have passed", function() {
|
203
|
-
var spec = new j$.Spec({fn: jasmine.createSpy("spec body")});
|
201
|
+
var spec = new j$.Spec({queueableFn: { fn: jasmine.createSpy("spec body")} });
|
204
202
|
spec.addExpectationResult(true);
|
205
203
|
expect(spec.status()).toBe('passed');
|
206
204
|
});
|
207
205
|
|
208
206
|
it("#status returns failed if any expectations in the spec have failed", function() {
|
209
|
-
var spec = new j$.Spec({ fn: jasmine.createSpy("spec body") });
|
207
|
+
var spec = new j$.Spec({queueableFn: { fn: jasmine.createSpy("spec body") } });
|
210
208
|
spec.addExpectationResult(true);
|
211
209
|
spec.addExpectationResult(false);
|
212
210
|
expect(spec.status()).toBe('failed');
|
@@ -215,7 +213,7 @@ describe("Spec", function() {
|
|
215
213
|
it("keeps track of passed and failed expectations", function() {
|
216
214
|
var resultCallback = jasmine.createSpy('resultCallback'),
|
217
215
|
spec = new j$.Spec({
|
218
|
-
fn: jasmine.createSpy("spec body"),
|
216
|
+
queueableFn: { fn: jasmine.createSpy("spec body") },
|
219
217
|
expectationResultFactory: function (data) { return data; },
|
220
218
|
queueRunnerFactory: function(attrs) { attrs.onComplete(); },
|
221
219
|
resultCallback: resultCallback
|
@@ -233,7 +231,8 @@ describe("Spec", function() {
|
|
233
231
|
var specNameSpy = jasmine.createSpy('specNameSpy').and.returnValue('expected val');
|
234
232
|
|
235
233
|
var spec = new j$.Spec({
|
236
|
-
getSpecName: specNameSpy
|
234
|
+
getSpecName: specNameSpy,
|
235
|
+
queueableFn: { fn: null }
|
237
236
|
});
|
238
237
|
|
239
238
|
expect(spec.getFullName()).toBe('expected val');
|
@@ -248,7 +247,7 @@ describe("Spec", function() {
|
|
248
247
|
spec = new j$.Spec({
|
249
248
|
description: 'my test',
|
250
249
|
id: 'some-id',
|
251
|
-
fn: function() { },
|
250
|
+
queueableFn: { fn: function() { } },
|
252
251
|
queueRunnerFactory: fakeQueueRunner
|
253
252
|
});
|
254
253
|
|
@@ -0,0 +1,55 @@
|
|
1
|
+
describe("SpyRegistry", function() {
|
2
|
+
describe("#spyOn", function() {
|
3
|
+
it("checks for the existence of the object", function() {
|
4
|
+
var spyRegistry = new j$.SpyRegistry();
|
5
|
+
expect(function() {
|
6
|
+
spyRegistry.spyOn(void 0, 'pants');
|
7
|
+
}).toThrowError(/could not find an object/);
|
8
|
+
});
|
9
|
+
|
10
|
+
it("checks for the existence of the method", function() {
|
11
|
+
var spyRegistry = new j$.SpyRegistry(),
|
12
|
+
subject = {};
|
13
|
+
|
14
|
+
expect(function() {
|
15
|
+
spyRegistry.spyOn(subject, 'pants');
|
16
|
+
}).toThrowError(/method does not exist/);
|
17
|
+
});
|
18
|
+
|
19
|
+
it("checks if it has already been spied upon", function() {
|
20
|
+
var spies = [],
|
21
|
+
spyRegistry = new j$.SpyRegistry({currentSpies: function() { return spies; }}),
|
22
|
+
subject = { spiedFunc: function() {} };
|
23
|
+
|
24
|
+
spyRegistry.spyOn(subject, 'spiedFunc');
|
25
|
+
|
26
|
+
expect(function() {
|
27
|
+
spyRegistry.spyOn(subject, 'spiedFunc');
|
28
|
+
}).toThrowError(/has already been spied upon/);
|
29
|
+
});
|
30
|
+
|
31
|
+
it("overrides the method on the object and returns the spy", function() {
|
32
|
+
var originalFunctionWasCalled = false,
|
33
|
+
spyRegistry = new j$.SpyRegistry(),
|
34
|
+
subject = { spiedFunc: function() { originalFunctionWasCalled = true; } };
|
35
|
+
|
36
|
+
var spy = spyRegistry.spyOn(subject, 'spiedFunc');
|
37
|
+
|
38
|
+
expect(subject.spiedFunc).toEqual(spy);
|
39
|
+
});
|
40
|
+
});
|
41
|
+
|
42
|
+
describe("#clearSpies", function() {
|
43
|
+
it("restores the original functions on the spied-upon objects", function() {
|
44
|
+
var spies = [],
|
45
|
+
spyRegistry = new j$.SpyRegistry({currentSpies: function() { return spies; }}),
|
46
|
+
originalFunction = function() {},
|
47
|
+
subject = { spiedFunc: originalFunction };
|
48
|
+
|
49
|
+
spyRegistry.spyOn(subject, 'spiedFunc');
|
50
|
+
spyRegistry.clearSpies();
|
51
|
+
|
52
|
+
expect(subject.spiedFunc).toBe(originalFunction);
|
53
|
+
});
|
54
|
+
});
|
55
|
+
});
|
@@ -47,6 +47,16 @@ describe('Spies', function () {
|
|
47
47
|
|
48
48
|
expect(trackSpy.calls.mostRecent().args[0].object).toEqual(contextObject);
|
49
49
|
});
|
50
|
+
|
51
|
+
it("tracks the return value of calls", function () {
|
52
|
+
var spy = j$.createSpy(TestClass.prototype, TestClass.prototype.someFunction);
|
53
|
+
var trackSpy = spyOn(spy.calls, "track");
|
54
|
+
|
55
|
+
spy.and.returnValue("return value");
|
56
|
+
spy();
|
57
|
+
|
58
|
+
expect(trackSpy.calls.mostRecent().args[0].returnValue).toEqual("return value");
|
59
|
+
});
|
50
60
|
});
|
51
61
|
|
52
62
|
describe("createSpyObj", function() {
|
@@ -46,6 +46,19 @@ describe("SpyStrategy", function() {
|
|
46
46
|
expect(returnValue).toEqual(17);
|
47
47
|
});
|
48
48
|
|
49
|
+
it("can return specified values in order specified when executed", function() {
|
50
|
+
var originalFn = jasmine.createSpy("original"),
|
51
|
+
spyStrategy = new j$.SpyStrategy({fn: originalFn});
|
52
|
+
|
53
|
+
spyStrategy.returnValues('value1', 'value2', 'value3');
|
54
|
+
|
55
|
+
expect(spyStrategy.exec()).toEqual('value1');
|
56
|
+
expect(spyStrategy.exec()).toEqual('value2');
|
57
|
+
expect(spyStrategy.exec()).toBe('value3');
|
58
|
+
expect(spyStrategy.exec()).toBeUndefined();
|
59
|
+
expect(originalFn).not.toHaveBeenCalled();
|
60
|
+
});
|
61
|
+
|
49
62
|
it("allows an exception to be thrown when executed", function() {
|
50
63
|
var originalFn = jasmine.createSpy("original"),
|
51
64
|
spyStrategy = new j$.SpyStrategy({fn: originalFn});
|
@@ -52,6 +52,31 @@ describe("Suite", function() {
|
|
52
52
|
expect(suite.beforeFns).toEqual([innerBefore, outerBefore]);
|
53
53
|
});
|
54
54
|
|
55
|
+
it("runs beforeAll functions in order of needed execution", function() {
|
56
|
+
var env = new j$.Env(),
|
57
|
+
fakeQueueRunner = jasmine.createSpy('fake queue runner'),
|
58
|
+
suite = new j$.Suite({
|
59
|
+
env: env,
|
60
|
+
description: "I am a suite",
|
61
|
+
queueRunner: fakeQueueRunner
|
62
|
+
}),
|
63
|
+
firstBefore = jasmine.createSpy('outerBeforeAll'),
|
64
|
+
lastBefore = jasmine.createSpy('insideBeforeAll'),
|
65
|
+
fakeIt = {execute: jasmine.createSpy('it'), isExecutable: function() { return true; } };
|
66
|
+
|
67
|
+
suite.beforeAll(firstBefore);
|
68
|
+
suite.beforeAll(lastBefore);
|
69
|
+
suite.addChild(fakeIt);
|
70
|
+
|
71
|
+
suite.execute();
|
72
|
+
var suiteFns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
|
73
|
+
|
74
|
+
suiteFns[0]();
|
75
|
+
expect(firstBefore).toHaveBeenCalled();
|
76
|
+
suiteFns[1]();
|
77
|
+
expect(lastBefore).toHaveBeenCalled();
|
78
|
+
});
|
79
|
+
|
55
80
|
it("adds after functions in order of needed execution", function() {
|
56
81
|
var env = new j$.Env(),
|
57
82
|
suite = new j$.Suite({
|
@@ -67,6 +92,31 @@ describe("Suite", function() {
|
|
67
92
|
expect(suite.afterFns).toEqual([innerAfter, outerAfter]);
|
68
93
|
});
|
69
94
|
|
95
|
+
it("runs afterAll functions in order of needed execution", function() {
|
96
|
+
var env = new j$.Env(),
|
97
|
+
fakeQueueRunner = jasmine.createSpy('fake queue runner'),
|
98
|
+
suite = new j$.Suite({
|
99
|
+
env: env,
|
100
|
+
description: "I am a suite",
|
101
|
+
queueRunner: fakeQueueRunner
|
102
|
+
}),
|
103
|
+
firstAfter = jasmine.createSpy('outerAfterAll'),
|
104
|
+
lastAfter = jasmine.createSpy('insideAfterAll'),
|
105
|
+
fakeIt = {execute: jasmine.createSpy('it'), isExecutable: function() { return true; } };
|
106
|
+
|
107
|
+
suite.afterAll(firstAfter);
|
108
|
+
suite.afterAll(lastAfter);
|
109
|
+
suite.addChild(fakeIt);
|
110
|
+
|
111
|
+
suite.execute();
|
112
|
+
var suiteFns = fakeQueueRunner.calls.mostRecent().args[0].queueableFns;
|
113
|
+
|
114
|
+
suiteFns[1]();
|
115
|
+
expect(firstAfter).toHaveBeenCalled();
|
116
|
+
suiteFns[2]();
|
117
|
+
expect(lastAfter).toHaveBeenCalled();
|
118
|
+
});
|
119
|
+
|
70
120
|
it("can be disabled, but still calls callbacks", function() {
|
71
121
|
var env = new j$.Env(),
|
72
122
|
fakeQueueRunner = jasmine.createSpy('fake queue runner'),
|
@@ -93,7 +143,7 @@ describe("Suite", function() {
|
|
93
143
|
expect(onComplete).toHaveBeenCalled();
|
94
144
|
});
|
95
145
|
|
96
|
-
it("delegates execution of its specs and
|
146
|
+
it("delegates execution of its specs, suites, beforeAlls, and afterAlls", function() {
|
97
147
|
var env = new j$.Env(),
|
98
148
|
parentSuiteDone = jasmine.createSpy('parent suite done'),
|
99
149
|
fakeQueueRunnerForParent = jasmine.createSpy('fake parent queue runner'),
|
@@ -109,22 +159,57 @@ describe("Suite", function() {
|
|
109
159
|
queueRunner: fakeQueueRunner
|
110
160
|
}),
|
111
161
|
fakeSpec1 = {
|
112
|
-
execute: jasmine.createSpy('fakeSpec1')
|
113
|
-
|
162
|
+
execute: jasmine.createSpy('fakeSpec1'),
|
163
|
+
isExecutable: function() { return true; }
|
164
|
+
},
|
165
|
+
beforeAllFn = { fn: jasmine.createSpy('beforeAll') },
|
166
|
+
afterAllFn = { fn: jasmine.createSpy('afterAll') };
|
114
167
|
|
115
168
|
spyOn(suite, "execute");
|
116
169
|
|
117
170
|
parentSuite.addChild(fakeSpec1);
|
118
171
|
parentSuite.addChild(suite);
|
172
|
+
parentSuite.beforeAll(beforeAllFn);
|
173
|
+
parentSuite.afterAll(afterAllFn);
|
119
174
|
|
120
175
|
parentSuite.execute(parentSuiteDone);
|
121
176
|
|
122
|
-
var parentSuiteFns = fakeQueueRunnerForParent.calls.mostRecent().args[0].
|
177
|
+
var parentSuiteFns = fakeQueueRunnerForParent.calls.mostRecent().args[0].queueableFns;
|
123
178
|
|
124
|
-
parentSuiteFns[0]();
|
179
|
+
parentSuiteFns[0].fn();
|
180
|
+
expect(beforeAllFn.fn).toHaveBeenCalled();
|
181
|
+
parentSuiteFns[1].fn();
|
125
182
|
expect(fakeSpec1.execute).toHaveBeenCalled();
|
126
|
-
parentSuiteFns[
|
183
|
+
parentSuiteFns[2].fn();
|
127
184
|
expect(suite.execute).toHaveBeenCalled();
|
185
|
+
parentSuiteFns[3].fn();
|
186
|
+
expect(afterAllFn.fn).toHaveBeenCalled();
|
187
|
+
});
|
188
|
+
|
189
|
+
it("does not run beforeAll or afterAll if there are no child specs to run", function() {
|
190
|
+
var env = new j$.Env(),
|
191
|
+
fakeQueueRunnerForParent = jasmine.createSpy('fake parent queue runner'),
|
192
|
+
fakeQueueRunnerForChild = jasmine.createSpy('fake child queue runner'),
|
193
|
+
parentSuite = new j$.Suite({
|
194
|
+
env: env,
|
195
|
+
description: "I am a suite",
|
196
|
+
queueRunner: fakeQueueRunnerForParent
|
197
|
+
}),
|
198
|
+
childSuite = new j$.Suite({
|
199
|
+
env: env,
|
200
|
+
description: "I am a suite",
|
201
|
+
queueRunner: fakeQueueRunnerForChild,
|
202
|
+
parentSuite: parentSuite
|
203
|
+
}),
|
204
|
+
beforeAllFn = jasmine.createSpy('beforeAll'),
|
205
|
+
afterAllFn = jasmine.createSpy('afterAll');
|
206
|
+
|
207
|
+
parentSuite.addChild(childSuite);
|
208
|
+
parentSuite.beforeAll(beforeAllFn);
|
209
|
+
parentSuite.afterAll(afterAllFn);
|
210
|
+
|
211
|
+
parentSuite.execute();
|
212
|
+
expect(fakeQueueRunnerForParent).toHaveBeenCalledWith(jasmine.objectContaining({queueableFns: []}));
|
128
213
|
});
|
129
214
|
|
130
215
|
it("calls a provided onStart callback when starting", function() {
|
@@ -138,7 +223,8 @@ describe("Suite", function() {
|
|
138
223
|
queueRunner: fakeQueueRunner
|
139
224
|
}),
|
140
225
|
fakeSpec1 = {
|
141
|
-
execute: jasmine.createSpy('fakeSpec1')
|
226
|
+
execute: jasmine.createSpy('fakeSpec1'),
|
227
|
+
isExecutable: function() { return true; }
|
142
228
|
};
|
143
229
|
|
144
230
|
suite.execute();
|
@@ -182,9 +268,10 @@ describe("Suite", function() {
|
|
182
268
|
|
183
269
|
expect(suiteResultsCallback).toHaveBeenCalledWith({
|
184
270
|
id: suite.id,
|
185
|
-
status: '',
|
271
|
+
status: 'finished',
|
186
272
|
description: "with a child suite",
|
187
|
-
fullName: "with a child suite"
|
273
|
+
fullName: "with a child suite",
|
274
|
+
failedExpectations: []
|
188
275
|
});
|
189
276
|
});
|
190
277
|
|
@@ -210,7 +297,18 @@ describe("Suite", function() {
|
|
210
297
|
id: suite.id,
|
211
298
|
status: 'disabled',
|
212
299
|
description: "with a child suite",
|
213
|
-
fullName: "with a child suite"
|
300
|
+
fullName: "with a child suite",
|
301
|
+
failedExpectations: []
|
214
302
|
});
|
215
303
|
});
|
304
|
+
|
305
|
+
it('has a status of failed if any afterAll expectations have failed', function() {
|
306
|
+
var suite = new j$.Suite({
|
307
|
+
expectationResultFactory: function() { return 'hi'; }
|
308
|
+
});
|
309
|
+
suite.addChild({ result: { status: 'done' } });
|
310
|
+
|
311
|
+
suite.addExpectationResult(false);
|
312
|
+
expect(suite.status()).toBe('failed');
|
313
|
+
});
|
216
314
|
});
|
@@ -38,13 +38,13 @@ describe("Custom Matchers (Integration)", function() {
|
|
38
38
|
});
|
39
39
|
|
40
40
|
it("passes the spec if the custom matcher passes", function(done) {
|
41
|
-
env.addMatchers({
|
42
|
-
toBeReal: function() {
|
43
|
-
return { compare: function() { return { pass: true }; } };
|
44
|
-
}
|
45
|
-
});
|
46
|
-
|
47
41
|
env.it("spec using custom matcher", function() {
|
42
|
+
env.addMatchers({
|
43
|
+
toBeReal: function() {
|
44
|
+
return { compare: function() { return { pass: true }; } };
|
45
|
+
}
|
46
|
+
});
|
47
|
+
|
48
48
|
env.expect(true).toBeReal();
|
49
49
|
});
|
50
50
|
|
@@ -57,16 +57,16 @@ describe("Custom Matchers (Integration)", function() {
|
|
57
57
|
});
|
58
58
|
|
59
59
|
it("uses the negative compare function for a negative comparison, if provided", function(done) {
|
60
|
-
env.addMatchers({
|
61
|
-
toBeReal: function() {
|
62
|
-
return {
|
63
|
-
compare: function() { return { pass: true }; },
|
64
|
-
negativeCompare: function() { return { pass: true }; }
|
65
|
-
};
|
66
|
-
}
|
67
|
-
});
|
68
|
-
|
69
60
|
env.it("spec with custom negative comparison matcher", function() {
|
61
|
+
env.addMatchers({
|
62
|
+
toBeReal: function() {
|
63
|
+
return {
|
64
|
+
compare: function() { return { pass: true }; },
|
65
|
+
negativeCompare: function() { return { pass: true }; }
|
66
|
+
};
|
67
|
+
}
|
68
|
+
});
|
69
|
+
|
70
70
|
env.expect(true).not.toBeReal();
|
71
71
|
});
|
72
72
|
|
@@ -79,17 +79,17 @@ describe("Custom Matchers (Integration)", function() {
|
|
79
79
|
});
|
80
80
|
|
81
81
|
it("generates messages with the same rules as built in matchers absent a custom message", function(done) {
|
82
|
-
env.
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
env.it('spec with an expectation', function() {
|
83
|
+
env.addMatchers({
|
84
|
+
toBeReal: function() {
|
85
|
+
return {
|
86
|
+
compare: function() {
|
87
|
+
return { pass: false };
|
88
|
+
}
|
87
89
|
}
|
88
90
|
}
|
89
|
-
}
|
90
|
-
});
|
91
|
+
});
|
91
92
|
|
92
|
-
env.it('spec with an expectation', function() {
|
93
93
|
env.expect("a").toBeReal();
|
94
94
|
});
|
95
95
|
|
@@ -103,13 +103,14 @@ describe("Custom Matchers (Integration)", function() {
|
|
103
103
|
|
104
104
|
it("passes the expected and actual arguments to the comparison function", function(done) {
|
105
105
|
var argumentSpy = jasmine.createSpy("argument spy").and.returnValue({ pass: true });
|
106
|
-
env.addMatchers({
|
107
|
-
toBeReal: function() {
|
108
|
-
return { compare: argumentSpy };
|
109
|
-
}
|
110
|
-
});
|
111
106
|
|
112
107
|
env.it('spec with an expectation', function () {
|
108
|
+
env.addMatchers({
|
109
|
+
toBeReal: function() {
|
110
|
+
return { compare: argumentSpy };
|
111
|
+
}
|
112
|
+
});
|
113
|
+
|
113
114
|
env.expect(true).toBeReal();
|
114
115
|
env.expect(true).toBeReal("arg");
|
115
116
|
env.expect(true).toBeReal("arg1", "arg2");
|
@@ -130,12 +131,13 @@ describe("Custom Matchers (Integration)", function() {
|
|
130
131
|
argumentSpy = jasmine.createSpy("argument spy").and.returnValue(matcherFactory),
|
131
132
|
customEqualityFn = function() { return true; };
|
132
133
|
|
133
|
-
env.addCustomEqualityTester(customEqualityFn);
|
134
|
-
env.addMatchers({
|
135
|
-
toBeReal: argumentSpy
|
136
|
-
});
|
137
134
|
|
138
135
|
env.it("spec with expectation", function() {
|
136
|
+
env.addCustomEqualityTester(customEqualityFn);
|
137
|
+
env.addMatchers({
|
138
|
+
toBeReal: argumentSpy
|
139
|
+
});
|
140
|
+
|
139
141
|
env.expect(true).toBeReal();
|
140
142
|
});
|
141
143
|
|