jasmine-core 2.9.0 → 2.99.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/jasmine-core/jasmine-html.js +24 -1
- data/lib/jasmine-core/jasmine.css +1 -0
- data/lib/jasmine-core/jasmine.js +50 -6
- data/lib/jasmine-core/version.rb +1 -1
- metadata +3 -84
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +0 -270
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
- data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
- data/lib/jasmine-core/spec/core/ClockSpec.js +0 -754
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -270
- data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
- data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -63
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -68
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
- data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
- data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
- data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -337
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -620
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -79
- data/lib/jasmine-core/spec/core/SpecSpec.js +0 -441
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -356
- data/lib/jasmine-core/spec/core/SpySpec.js +0 -127
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -159
- data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -155
- data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -756
- data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
- data/lib/jasmine-core/spec/core/UtilSpec.js +0 -99
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -84
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -102
- data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
- data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -199
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2007
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -950
- data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
- data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
- data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -658
- data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
- data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
- data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
- data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
- data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
- data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
- data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
- data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
- data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
- data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
- data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
- data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
- data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -804
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
- data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
- data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -27
- data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
- data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
- data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
- data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
- data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
- data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -7
- data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -33
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -982
- data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
- data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
- data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -15
- data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
- data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
- data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -34
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
- data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
- data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
|
@@ -1,434 +0,0 @@
|
|
|
1
|
-
describe("Expectation", function() {
|
|
2
|
-
it("makes custom matchers available to this expectation", function() {
|
|
3
|
-
var matchers = {
|
|
4
|
-
toFoo: function() {},
|
|
5
|
-
toBar: function() {}
|
|
6
|
-
},
|
|
7
|
-
expectation;
|
|
8
|
-
|
|
9
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
10
|
-
customMatchers: matchers
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
expect(expectation.toFoo).toBeDefined();
|
|
14
|
-
expect(expectation.toBar).toBeDefined();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it(".addCoreMatchers makes matchers available to any expectation", function() {
|
|
18
|
-
var coreMatchers = {
|
|
19
|
-
toQuux: function() {}
|
|
20
|
-
},
|
|
21
|
-
expectation;
|
|
22
|
-
|
|
23
|
-
jasmineUnderTest.Expectation.addCoreMatchers(coreMatchers);
|
|
24
|
-
|
|
25
|
-
expectation = new jasmineUnderTest.Expectation({});
|
|
26
|
-
|
|
27
|
-
expect(expectation.toQuux).toBeDefined();
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("Factory builds an expectation/negative expectation", function() {
|
|
31
|
-
var builtExpectation = jasmineUnderTest.Expectation.Factory();
|
|
32
|
-
|
|
33
|
-
expect(builtExpectation instanceof jasmineUnderTest.Expectation).toBe(true);
|
|
34
|
-
expect(builtExpectation.not instanceof jasmineUnderTest.Expectation).toBe(true);
|
|
35
|
-
expect(builtExpectation.not.isNot).toBe(true);
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it("wraps matchers's compare functions, passing in matcher dependencies", function() {
|
|
39
|
-
var fakeCompare = function() { return { pass: true }; },
|
|
40
|
-
matcherFactory = jasmine.createSpy("matcher").and.returnValue({ compare: fakeCompare }),
|
|
41
|
-
matchers = {
|
|
42
|
-
toFoo: matcherFactory
|
|
43
|
-
},
|
|
44
|
-
util = {},
|
|
45
|
-
customEqualityTesters = ['a'],
|
|
46
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
47
|
-
expectation;
|
|
48
|
-
|
|
49
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
50
|
-
util: util,
|
|
51
|
-
customMatchers: matchers,
|
|
52
|
-
customEqualityTesters: customEqualityTesters,
|
|
53
|
-
actual: "an actual",
|
|
54
|
-
addExpectationResult: addExpectationResult
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
expectation.toFoo("hello");
|
|
58
|
-
|
|
59
|
-
expect(matcherFactory).toHaveBeenCalledWith(util, customEqualityTesters)
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("wraps matchers's compare functions, passing the actual and expected", function() {
|
|
63
|
-
var fakeCompare = jasmine.createSpy('fake-compare').and.returnValue({pass: true}),
|
|
64
|
-
matchers = {
|
|
65
|
-
toFoo: function() {
|
|
66
|
-
return {
|
|
67
|
-
compare: fakeCompare
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
util = {
|
|
72
|
-
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
|
73
|
-
},
|
|
74
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
75
|
-
expectation;
|
|
76
|
-
|
|
77
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
78
|
-
util: util,
|
|
79
|
-
customMatchers: matchers,
|
|
80
|
-
actual: "an actual",
|
|
81
|
-
addExpectationResult: addExpectationResult
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
expectation.toFoo("hello");
|
|
85
|
-
|
|
86
|
-
expect(fakeCompare).toHaveBeenCalledWith("an actual", "hello");
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it("reports a passing result to the spec when the comparison passes", function() {
|
|
90
|
-
var matchers = {
|
|
91
|
-
toFoo: function() {
|
|
92
|
-
return {
|
|
93
|
-
compare: function() { return { pass: true }; }
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
util = {
|
|
98
|
-
buildFailureMessage: jasmine.createSpy('buildFailureMessage')
|
|
99
|
-
},
|
|
100
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
101
|
-
expectation;
|
|
102
|
-
|
|
103
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
104
|
-
customMatchers: matchers,
|
|
105
|
-
util: util,
|
|
106
|
-
actual: "an actual",
|
|
107
|
-
addExpectationResult: addExpectationResult
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
expectation.toFoo("hello");
|
|
111
|
-
|
|
112
|
-
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
|
113
|
-
matcherName: "toFoo",
|
|
114
|
-
passed: true,
|
|
115
|
-
message: "",
|
|
116
|
-
error: undefined,
|
|
117
|
-
expected: "hello",
|
|
118
|
-
actual: "an actual"
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
it("reports a failing result to the spec when the comparison fails", function() {
|
|
123
|
-
var matchers = {
|
|
124
|
-
toFoo: function() {
|
|
125
|
-
return {
|
|
126
|
-
compare: function() { return { pass: false }; }
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
},
|
|
130
|
-
util = {
|
|
131
|
-
buildFailureMessage: function() { return ""; }
|
|
132
|
-
},
|
|
133
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
134
|
-
expectation;
|
|
135
|
-
|
|
136
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
137
|
-
customMatchers: matchers,
|
|
138
|
-
util: util,
|
|
139
|
-
actual: "an actual",
|
|
140
|
-
addExpectationResult: addExpectationResult
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
expectation.toFoo("hello");
|
|
144
|
-
|
|
145
|
-
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
|
146
|
-
matcherName: "toFoo",
|
|
147
|
-
passed: false,
|
|
148
|
-
expected: "hello",
|
|
149
|
-
actual: "an actual",
|
|
150
|
-
message: "",
|
|
151
|
-
error: undefined
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
it("reports a failing result and a custom fail message to the spec when the comparison fails", function() {
|
|
156
|
-
var matchers = {
|
|
157
|
-
toFoo: function() {
|
|
158
|
-
return {
|
|
159
|
-
compare: function() {
|
|
160
|
-
return {
|
|
161
|
-
pass: false,
|
|
162
|
-
message: "I am a custom message"
|
|
163
|
-
};
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
},
|
|
168
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
169
|
-
expectation;
|
|
170
|
-
|
|
171
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
172
|
-
actual: "an actual",
|
|
173
|
-
customMatchers: matchers,
|
|
174
|
-
addExpectationResult: addExpectationResult
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
expectation.toFoo("hello");
|
|
178
|
-
|
|
179
|
-
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
|
180
|
-
matcherName: "toFoo",
|
|
181
|
-
passed: false,
|
|
182
|
-
expected: "hello",
|
|
183
|
-
actual: "an actual",
|
|
184
|
-
message: "I am a custom message",
|
|
185
|
-
error: undefined
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it("reports a failing result with a custom fail message function to the spec when the comparison fails", function() {
|
|
190
|
-
var matchers = {
|
|
191
|
-
toFoo: function() {
|
|
192
|
-
return {
|
|
193
|
-
compare: function() {
|
|
194
|
-
return {
|
|
195
|
-
pass: false,
|
|
196
|
-
message: function() { return "I am a custom message"; }
|
|
197
|
-
};
|
|
198
|
-
}
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
},
|
|
202
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
203
|
-
expectation;
|
|
204
|
-
|
|
205
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
206
|
-
customMatchers: matchers,
|
|
207
|
-
actual: "an actual",
|
|
208
|
-
addExpectationResult: addExpectationResult
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
expectation.toFoo("hello");
|
|
212
|
-
|
|
213
|
-
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
|
214
|
-
matcherName: "toFoo",
|
|
215
|
-
passed: false,
|
|
216
|
-
expected: "hello",
|
|
217
|
-
actual: "an actual",
|
|
218
|
-
message: "I am a custom message",
|
|
219
|
-
error: undefined
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it("reports a passing result to the spec when the comparison fails for a negative expectation", function() {
|
|
224
|
-
var matchers = {
|
|
225
|
-
toFoo: function() {
|
|
226
|
-
return {
|
|
227
|
-
compare: function() { return { pass: false }; }
|
|
228
|
-
};
|
|
229
|
-
}
|
|
230
|
-
},
|
|
231
|
-
util = {
|
|
232
|
-
buildFailureMessage: function() { return ""; }
|
|
233
|
-
},
|
|
234
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
235
|
-
actual = "an actual",
|
|
236
|
-
expectation;
|
|
237
|
-
|
|
238
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
239
|
-
customMatchers: matchers,
|
|
240
|
-
actual: "an actual",
|
|
241
|
-
addExpectationResult: addExpectationResult,
|
|
242
|
-
isNot: true
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
expectation.toFoo("hello");
|
|
246
|
-
|
|
247
|
-
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
|
248
|
-
matcherName: "toFoo",
|
|
249
|
-
passed: true,
|
|
250
|
-
message: "",
|
|
251
|
-
error: undefined,
|
|
252
|
-
expected: "hello",
|
|
253
|
-
actual: actual
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
it("reports a failing result to the spec when the comparison passes for a negative expectation", function() {
|
|
258
|
-
var matchers = {
|
|
259
|
-
toFoo: function() {
|
|
260
|
-
return {
|
|
261
|
-
compare: function() { return { pass: true }; }
|
|
262
|
-
};
|
|
263
|
-
}
|
|
264
|
-
},
|
|
265
|
-
util = {
|
|
266
|
-
buildFailureMessage: function() { return "default message"; }
|
|
267
|
-
},
|
|
268
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
269
|
-
actual = "an actual",
|
|
270
|
-
expectation;
|
|
271
|
-
|
|
272
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
273
|
-
customMatchers: matchers,
|
|
274
|
-
actual: "an actual",
|
|
275
|
-
util: util,
|
|
276
|
-
addExpectationResult: addExpectationResult,
|
|
277
|
-
isNot: true
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
expectation.toFoo("hello");
|
|
281
|
-
|
|
282
|
-
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
|
283
|
-
matcherName: "toFoo",
|
|
284
|
-
passed: false,
|
|
285
|
-
expected: "hello",
|
|
286
|
-
actual: actual,
|
|
287
|
-
message: "default message",
|
|
288
|
-
error: undefined
|
|
289
|
-
});
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
it("reports a failing result and a custom fail message to the spec when the comparison passes for a negative expectation", function() {
|
|
293
|
-
var matchers = {
|
|
294
|
-
toFoo: function() {
|
|
295
|
-
return {
|
|
296
|
-
compare: function() {
|
|
297
|
-
return {
|
|
298
|
-
pass: true,
|
|
299
|
-
message: "I am a custom message"
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
},
|
|
305
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
306
|
-
actual = "an actual",
|
|
307
|
-
expectation;
|
|
308
|
-
|
|
309
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
310
|
-
customMatchers: matchers,
|
|
311
|
-
actual: "an actual",
|
|
312
|
-
addExpectationResult: addExpectationResult,
|
|
313
|
-
isNot: true
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
expectation.toFoo("hello");
|
|
317
|
-
|
|
318
|
-
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
|
319
|
-
matcherName: "toFoo",
|
|
320
|
-
passed: false,
|
|
321
|
-
expected: "hello",
|
|
322
|
-
actual: actual,
|
|
323
|
-
message: "I am a custom message",
|
|
324
|
-
error: undefined
|
|
325
|
-
});
|
|
326
|
-
});
|
|
327
|
-
|
|
328
|
-
it("reports a passing result to the spec when the 'not' comparison passes, given a negativeCompare", function() {
|
|
329
|
-
var matchers = {
|
|
330
|
-
toFoo: function() {
|
|
331
|
-
return {
|
|
332
|
-
compare: function() { return { pass: true }; },
|
|
333
|
-
negativeCompare: function() { return { pass: true }; }
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
},
|
|
337
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
338
|
-
actual = "an actual",
|
|
339
|
-
expectation;
|
|
340
|
-
|
|
341
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
342
|
-
customMatchers: matchers,
|
|
343
|
-
actual: "an actual",
|
|
344
|
-
addExpectationResult: addExpectationResult,
|
|
345
|
-
isNot: true
|
|
346
|
-
});
|
|
347
|
-
|
|
348
|
-
expectation.toFoo("hello");
|
|
349
|
-
|
|
350
|
-
expect(addExpectationResult).toHaveBeenCalledWith(true, {
|
|
351
|
-
matcherName: "toFoo",
|
|
352
|
-
passed: true,
|
|
353
|
-
expected: "hello",
|
|
354
|
-
actual: actual,
|
|
355
|
-
message: "",
|
|
356
|
-
error: undefined
|
|
357
|
-
});
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it("reports a failing result and a custom fail message to the spec when the 'not' comparison fails, given a negativeCompare", function() {
|
|
361
|
-
var matchers = {
|
|
362
|
-
toFoo: function() {
|
|
363
|
-
return {
|
|
364
|
-
compare: function() { return { pass: true }; },
|
|
365
|
-
negativeCompare: function() {
|
|
366
|
-
return {
|
|
367
|
-
pass: false,
|
|
368
|
-
message: "I'm a custom message"
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
}
|
|
373
|
-
},
|
|
374
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
375
|
-
actual = "an actual",
|
|
376
|
-
expectation;
|
|
377
|
-
|
|
378
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
379
|
-
customMatchers: matchers,
|
|
380
|
-
actual: "an actual",
|
|
381
|
-
addExpectationResult: addExpectationResult,
|
|
382
|
-
isNot: true
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
expectation.toFoo("hello");
|
|
386
|
-
|
|
387
|
-
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
|
388
|
-
matcherName: "toFoo",
|
|
389
|
-
passed: false,
|
|
390
|
-
expected: "hello",
|
|
391
|
-
actual: actual,
|
|
392
|
-
message: "I'm a custom message",
|
|
393
|
-
error: undefined
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
|
|
397
|
-
it("reports a custom error message to the spec", function() {
|
|
398
|
-
var customError = new Error("I am a custom error");
|
|
399
|
-
var matchers = {
|
|
400
|
-
toFoo: function() {
|
|
401
|
-
return {
|
|
402
|
-
compare: function() {
|
|
403
|
-
return {
|
|
404
|
-
pass: false,
|
|
405
|
-
message: "I am a custom message",
|
|
406
|
-
error: customError
|
|
407
|
-
};
|
|
408
|
-
}
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
},
|
|
412
|
-
addExpectationResult = jasmine.createSpy("addExpectationResult"),
|
|
413
|
-
expectation;
|
|
414
|
-
|
|
415
|
-
expectation = new jasmineUnderTest.Expectation({
|
|
416
|
-
actual: "an actual",
|
|
417
|
-
customMatchers: matchers,
|
|
418
|
-
addExpectationResult: addExpectationResult
|
|
419
|
-
});
|
|
420
|
-
|
|
421
|
-
expectation.toFoo("hello");
|
|
422
|
-
|
|
423
|
-
expect(addExpectationResult).toHaveBeenCalledWith(false, {
|
|
424
|
-
matcherName: "toFoo",
|
|
425
|
-
passed: false,
|
|
426
|
-
expected: "hello",
|
|
427
|
-
actual: "an actual",
|
|
428
|
-
message: "I am a custom message",
|
|
429
|
-
error: customError
|
|
430
|
-
});
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
});
|
|
434
|
-
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
describe("GlobalErrors", function() {
|
|
2
|
-
it("calls the added handler on error", function() {
|
|
3
|
-
var fakeGlobal = { onerror: null },
|
|
4
|
-
handler = jasmine.createSpy('errorHandler'),
|
|
5
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
|
6
|
-
|
|
7
|
-
errors.install();
|
|
8
|
-
errors.pushListener(handler);
|
|
9
|
-
|
|
10
|
-
fakeGlobal.onerror('foo');
|
|
11
|
-
|
|
12
|
-
expect(handler).toHaveBeenCalledWith('foo');
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
it("only calls the most recent handler", function() {
|
|
16
|
-
var fakeGlobal = { onerror: null },
|
|
17
|
-
handler1 = jasmine.createSpy('errorHandler1'),
|
|
18
|
-
handler2 = jasmine.createSpy('errorHandler2'),
|
|
19
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
|
20
|
-
|
|
21
|
-
errors.install();
|
|
22
|
-
errors.pushListener(handler1);
|
|
23
|
-
errors.pushListener(handler2);
|
|
24
|
-
|
|
25
|
-
fakeGlobal.onerror('foo');
|
|
26
|
-
|
|
27
|
-
expect(handler1).not.toHaveBeenCalled();
|
|
28
|
-
expect(handler2).toHaveBeenCalledWith('foo');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it("calls previous handlers when one is removed", function() {
|
|
32
|
-
var fakeGlobal = { onerror: null },
|
|
33
|
-
handler1 = jasmine.createSpy('errorHandler1'),
|
|
34
|
-
handler2 = jasmine.createSpy('errorHandler2'),
|
|
35
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
|
36
|
-
|
|
37
|
-
errors.install();
|
|
38
|
-
errors.pushListener(handler1);
|
|
39
|
-
errors.pushListener(handler2);
|
|
40
|
-
|
|
41
|
-
errors.popListener();
|
|
42
|
-
|
|
43
|
-
fakeGlobal.onerror('foo');
|
|
44
|
-
|
|
45
|
-
expect(handler1).toHaveBeenCalledWith('foo');
|
|
46
|
-
expect(handler2).not.toHaveBeenCalled();
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it("uninstalls itself, putting back a previous callback", function() {
|
|
50
|
-
var originalCallback = jasmine.createSpy('error'),
|
|
51
|
-
fakeGlobal = { onerror: originalCallback },
|
|
52
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
|
53
|
-
|
|
54
|
-
expect(fakeGlobal.onerror).toBe(originalCallback);
|
|
55
|
-
|
|
56
|
-
errors.install();
|
|
57
|
-
|
|
58
|
-
expect(fakeGlobal.onerror).not.toBe(originalCallback);
|
|
59
|
-
|
|
60
|
-
errors.uninstall();
|
|
61
|
-
|
|
62
|
-
expect(fakeGlobal.onerror).toBe(originalCallback);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it("rethrows the original error when there is no handler", function() {
|
|
66
|
-
var fakeGlobal = { },
|
|
67
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal),
|
|
68
|
-
originalError = new Error('nope');
|
|
69
|
-
|
|
70
|
-
errors.install();
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
fakeGlobal.onerror(originalError);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
expect(e).toBe(originalError);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
errors.uninstall();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("works in node.js", function() {
|
|
82
|
-
var fakeGlobal = {
|
|
83
|
-
process: {
|
|
84
|
-
on: jasmine.createSpy('process.on'),
|
|
85
|
-
removeListener: jasmine.createSpy('process.removeListener'),
|
|
86
|
-
listeners: jasmine.createSpy('process.listeners').and.returnValue(['foo']),
|
|
87
|
-
removeAllListeners: jasmine.createSpy('process.removeAllListeners')
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
handler = jasmine.createSpy('errorHandler'),
|
|
91
|
-
errors = new jasmineUnderTest.GlobalErrors(fakeGlobal);
|
|
92
|
-
|
|
93
|
-
errors.install();
|
|
94
|
-
expect(fakeGlobal.process.on).toHaveBeenCalledWith('uncaughtException', jasmine.any(Function));
|
|
95
|
-
expect(fakeGlobal.process.listeners).toHaveBeenCalledWith('uncaughtException');
|
|
96
|
-
expect(fakeGlobal.process.removeAllListeners).toHaveBeenCalledWith('uncaughtException');
|
|
97
|
-
|
|
98
|
-
errors.pushListener(handler);
|
|
99
|
-
|
|
100
|
-
var addedListener = fakeGlobal.process.on.calls.argsFor(0)[1];
|
|
101
|
-
addedListener(new Error('bar'));
|
|
102
|
-
|
|
103
|
-
expect(handler).toHaveBeenCalledWith(new Error('bar'));
|
|
104
|
-
|
|
105
|
-
errors.uninstall();
|
|
106
|
-
|
|
107
|
-
expect(fakeGlobal.process.removeListener).toHaveBeenCalledWith('uncaughtException', addedListener);
|
|
108
|
-
expect(fakeGlobal.process.on).toHaveBeenCalledWith('uncaughtException', 'foo');
|
|
109
|
-
});
|
|
110
|
-
});
|