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.
Files changed (87) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jasmine-core/jasmine-html.js +24 -1
  3. data/lib/jasmine-core/jasmine.css +1 -0
  4. data/lib/jasmine-core/jasmine.js +50 -6
  5. data/lib/jasmine-core/version.rb +1 -1
  6. metadata +3 -84
  7. data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +0 -270
  8. data/lib/jasmine-core/spec/core/CallTrackerSpec.js +0 -130
  9. data/lib/jasmine-core/spec/core/ClearStackSpec.js +0 -137
  10. data/lib/jasmine-core/spec/core/ClockSpec.js +0 -754
  11. data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -270
  12. data/lib/jasmine-core/spec/core/EnvSpec.js +0 -200
  13. data/lib/jasmine-core/spec/core/ExceptionFormatterSpec.js +0 -63
  14. data/lib/jasmine-core/spec/core/ExceptionsSpec.js +0 -68
  15. data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +0 -61
  16. data/lib/jasmine-core/spec/core/ExpectationSpec.js +0 -434
  17. data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +0 -110
  18. data/lib/jasmine-core/spec/core/JsApiReporterSpec.js +0 -259
  19. data/lib/jasmine-core/spec/core/MockDateSpec.js +0 -200
  20. data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +0 -337
  21. data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +0 -620
  22. data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +0 -79
  23. data/lib/jasmine-core/spec/core/SpecSpec.js +0 -441
  24. data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +0 -356
  25. data/lib/jasmine-core/spec/core/SpySpec.js +0 -127
  26. data/lib/jasmine-core/spec/core/SpyStrategySpec.js +0 -159
  27. data/lib/jasmine-core/spec/core/SuiteSpec.js +0 -155
  28. data/lib/jasmine-core/spec/core/TimerSpec.js +0 -31
  29. data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +0 -756
  30. data/lib/jasmine-core/spec/core/UserContextSpec.js +0 -54
  31. data/lib/jasmine-core/spec/core/UtilSpec.js +0 -99
  32. data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +0 -84
  33. data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +0 -76
  34. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +0 -52
  35. data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +0 -47
  36. data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +0 -102
  37. data/lib/jasmine-core/spec/core/asymmetric_equality/StringMatchingSpec.js +0 -27
  38. data/lib/jasmine-core/spec/core/formatErrorMsgSpec.js +0 -13
  39. data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +0 -199
  40. data/lib/jasmine-core/spec/core/integration/EnvSpec.js +0 -2007
  41. data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +0 -950
  42. data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +0 -47
  43. data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +0 -13
  44. data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +0 -43
  45. data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +0 -658
  46. data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +0 -8
  47. data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +0 -93
  48. data/lib/jasmine-core/spec/core/matchers/toBeDefinedSpec.js +0 -18
  49. data/lib/jasmine-core/spec/core/matchers/toBeFalsySpec.js +0 -38
  50. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanOrEqualSpec.js +0 -29
  51. data/lib/jasmine-core/spec/core/matchers/toBeGreaterThanSpec.js +0 -20
  52. data/lib/jasmine-core/spec/core/matchers/toBeLessThanOrEqualSpec.js +0 -29
  53. data/lib/jasmine-core/spec/core/matchers/toBeLessThanSpec.js +0 -20
  54. data/lib/jasmine-core/spec/core/matchers/toBeNaNSpec.js +0 -37
  55. data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +0 -31
  56. data/lib/jasmine-core/spec/core/matchers/toBeNullSpec.js +0 -17
  57. data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +0 -31
  58. data/lib/jasmine-core/spec/core/matchers/toBeSpec.js +0 -17
  59. data/lib/jasmine-core/spec/core/matchers/toBeTruthySpec.js +0 -38
  60. data/lib/jasmine-core/spec/core/matchers/toBeUndefinedSpec.js +0 -18
  61. data/lib/jasmine-core/spec/core/matchers/toContainSpec.js +0 -26
  62. data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +0 -804
  63. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +0 -99
  64. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledSpec.js +0 -47
  65. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledTimesSpec.js +0 -86
  66. data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledWithSpec.js +0 -67
  67. data/lib/jasmine-core/spec/core/matchers/toMatchSpec.js +0 -43
  68. data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -315
  69. data/lib/jasmine-core/spec/core/matchers/toThrowSpec.js +0 -100
  70. data/lib/jasmine-core/spec/helpers/BrowserFlags.js +0 -27
  71. data/lib/jasmine-core/spec/helpers/asyncAwait.js +0 -27
  72. data/lib/jasmine-core/spec/helpers/checkForMap.js +0 -37
  73. data/lib/jasmine-core/spec/helpers/checkForSet.js +0 -41
  74. data/lib/jasmine-core/spec/helpers/checkForSymbol.js +0 -28
  75. data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +0 -20
  76. data/lib/jasmine-core/spec/helpers/defineJasmineUnderTest.js +0 -7
  77. data/lib/jasmine-core/spec/helpers/nodeDefineJasmineUnderTest.js +0 -33
  78. data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +0 -982
  79. data/lib/jasmine-core/spec/html/HtmlSpecFilterSpec.js +0 -18
  80. data/lib/jasmine-core/spec/html/MatchersHtmlSpec.js +0 -37
  81. data/lib/jasmine-core/spec/html/PrettyPrintHtmlSpec.js +0 -15
  82. data/lib/jasmine-core/spec/html/QueryStringSpec.js +0 -72
  83. data/lib/jasmine-core/spec/html/ResultsNodeSpec.js +0 -62
  84. data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +0 -34
  85. data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +0 -101
  86. data/lib/jasmine-core/spec/performance/large_object_test.js +0 -36
  87. data/lib/jasmine-core/spec/performance/performance_test.js +0 -10
@@ -1,620 +0,0 @@
1
- describe("QueueRunner", function() {
2
-
3
- it("runs all the functions it's passed", function() {
4
- var calls = [],
5
- queueableFn1 = { fn: jasmine.createSpy('fn1') },
6
- queueableFn2 = { fn: jasmine.createSpy('fn2') },
7
- queueRunner = new jasmineUnderTest.QueueRunner({
8
- queueableFns: [queueableFn1, queueableFn2]
9
- });
10
- queueableFn1.fn.and.callFake(function() {
11
- calls.push('fn1');
12
- });
13
- queueableFn2.fn.and.callFake(function() {
14
- calls.push('fn2');
15
- });
16
-
17
- queueRunner.execute();
18
-
19
- expect(calls).toEqual(['fn1', 'fn2']);
20
- });
21
-
22
- it("runs cleanup functions after the others", function() {
23
- var calls = [],
24
- queueableFn1 = { fn: jasmine.createSpy('fn1') },
25
- queueableFn2 = { fn: jasmine.createSpy('fn2') },
26
- queueRunner = new jasmineUnderTest.QueueRunner({
27
- queueableFns: [queueableFn1],
28
- cleanupFns: [queueableFn2]
29
- });
30
- queueableFn1.fn.and.callFake(function() {
31
- calls.push('fn1');
32
- });
33
- queueableFn2.fn.and.callFake(function() {
34
- calls.push('fn2');
35
- });
36
-
37
- queueRunner.execute();
38
-
39
- expect(calls).toEqual(['fn1', 'fn2']);
40
- });
41
-
42
- it("calls each function with a consistent 'this'-- an empty object", function() {
43
- var queueableFn1 = { fn: jasmine.createSpy('fn1') },
44
- queueableFn2 = { fn: jasmine.createSpy('fn2') },
45
- queueableFn3 = { fn: function(done) { asyncContext = this; done(); } },
46
- queueRunner = new jasmineUnderTest.QueueRunner({
47
- queueableFns: [queueableFn1, queueableFn2, queueableFn3]
48
- }),
49
- asyncContext;
50
-
51
- queueRunner.execute();
52
-
53
- var context = queueableFn1.fn.calls.first().object;
54
- expect(context).toEqual(new jasmineUnderTest.UserContext());
55
- expect(queueableFn2.fn.calls.first().object).toBe(context);
56
- expect(asyncContext).toBe(context);
57
- });
58
-
59
- describe("with an asynchronous function", function() {
60
- beforeEach(function() {
61
- jasmine.clock().install();
62
- });
63
-
64
- afterEach(function() {
65
- jasmine.clock().uninstall();
66
- });
67
-
68
- it("supports asynchronous functions, only advancing to next function after a done() callback", function() {
69
- //TODO: it would be nice if spy arity could match the fake, so we could do something like:
70
- //createSpy('asyncfn').and.callFake(function(done) {});
71
-
72
- var onComplete = jasmine.createSpy('onComplete'),
73
- beforeCallback = jasmine.createSpy('beforeCallback'),
74
- fnCallback = jasmine.createSpy('fnCallback'),
75
- afterCallback = jasmine.createSpy('afterCallback'),
76
- queueableFn1 = { fn: function(done) {
77
- beforeCallback();
78
- setTimeout(done, 100);
79
- } },
80
- queueableFn2 = { fn: function(done) {
81
- fnCallback();
82
- setTimeout(done, 100);
83
- } },
84
- queueableFn3 = { fn: function(done) {
85
- afterCallback();
86
- setTimeout(done, 100);
87
- } },
88
- queueRunner = new jasmineUnderTest.QueueRunner({
89
- queueableFns: [queueableFn1, queueableFn2, queueableFn3],
90
- onComplete: onComplete
91
- });
92
-
93
- queueRunner.execute();
94
-
95
- expect(beforeCallback).toHaveBeenCalled();
96
- expect(fnCallback).not.toHaveBeenCalled();
97
- expect(afterCallback).not.toHaveBeenCalled();
98
- expect(onComplete).not.toHaveBeenCalled();
99
-
100
- jasmine.clock().tick(100);
101
-
102
- expect(fnCallback).toHaveBeenCalled();
103
- expect(afterCallback).not.toHaveBeenCalled();
104
- expect(onComplete).not.toHaveBeenCalled();
105
-
106
- jasmine.clock().tick(100);
107
-
108
- expect(afterCallback).toHaveBeenCalled();
109
- expect(onComplete).not.toHaveBeenCalled();
110
-
111
- jasmine.clock().tick(100);
112
-
113
- expect(onComplete).toHaveBeenCalled();
114
- });
115
-
116
- it("explicitly fails an async function with a provided fail function and moves to the next function", function() {
117
- var queueableFn1 = { fn: function(done) {
118
- setTimeout(function() { done.fail('foo'); }, 100);
119
- } },
120
- queueableFn2 = { fn: jasmine.createSpy('fn2') },
121
- failFn = jasmine.createSpy('fail'),
122
- queueRunner = new jasmineUnderTest.QueueRunner({
123
- queueableFns: [queueableFn1, queueableFn2],
124
- fail: failFn
125
- });
126
-
127
- queueRunner.execute();
128
-
129
- expect(failFn).not.toHaveBeenCalled();
130
- expect(queueableFn2.fn).not.toHaveBeenCalled();
131
-
132
- jasmine.clock().tick(100);
133
-
134
- expect(failFn).toHaveBeenCalledWith('foo');
135
- expect(queueableFn2.fn).toHaveBeenCalled();
136
- });
137
-
138
- it("sets a timeout if requested for asynchronous functions so they don't go on forever", function() {
139
- var timeout = 3,
140
- beforeFn = { fn: function(done) { }, type: 'before', timeout: function() { return timeout; } },
141
- queueableFn = { fn: jasmine.createSpy('fn'), type: 'queueable' },
142
- onComplete = jasmine.createSpy('onComplete'),
143
- onException = jasmine.createSpy('onException'),
144
- queueRunner = new jasmineUnderTest.QueueRunner({
145
- queueableFns: [beforeFn, queueableFn],
146
- onComplete: onComplete,
147
- onException: onException
148
- });
149
-
150
- queueRunner.execute();
151
- expect(queueableFn.fn).not.toHaveBeenCalled();
152
-
153
- jasmine.clock().tick(timeout);
154
-
155
- expect(onException).toHaveBeenCalledWith(jasmine.any(Error));
156
- expect(queueableFn.fn).toHaveBeenCalled();
157
- expect(onComplete).toHaveBeenCalled();
158
- });
159
-
160
- it("by default does not set a timeout for asynchronous functions", function() {
161
- var beforeFn = { fn: function(done) { } },
162
- queueableFn = { fn: jasmine.createSpy('fn') },
163
- onComplete = jasmine.createSpy('onComplete'),
164
- onException = jasmine.createSpy('onException'),
165
- queueRunner = new jasmineUnderTest.QueueRunner({
166
- queueableFns: [beforeFn, queueableFn],
167
- onComplete: onComplete,
168
- onException: onException,
169
- });
170
-
171
- queueRunner.execute();
172
- expect(queueableFn.fn).not.toHaveBeenCalled();
173
-
174
- jasmine.clock().tick(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL);
175
-
176
- expect(onException).not.toHaveBeenCalled();
177
- expect(queueableFn.fn).not.toHaveBeenCalled();
178
- expect(onComplete).not.toHaveBeenCalled();
179
- });
180
-
181
- it("clears the timeout when an async function throws an exception, to prevent additional exception reporting", function() {
182
- var queueableFn = { fn: function(done) { throw new Error("error!"); } },
183
- onComplete = jasmine.createSpy('onComplete'),
184
- onException = jasmine.createSpy('onException'),
185
- queueRunner = new jasmineUnderTest.QueueRunner({
186
- queueableFns: [queueableFn],
187
- onComplete: onComplete,
188
- onException: onException
189
- });
190
-
191
- queueRunner.execute();
192
-
193
- expect(onComplete).toHaveBeenCalled();
194
- expect(onException).toHaveBeenCalled();
195
-
196
- jasmine.clock().tick(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL);
197
- expect(onException.calls.count()).toEqual(1);
198
- });
199
-
200
- it("clears the timeout when the done callback is called", function() {
201
- var queueableFn = { fn: function(done) { done(); } },
202
- onComplete = jasmine.createSpy('onComplete'),
203
- onException = jasmine.createSpy('onException'),
204
- queueRunner = new jasmineUnderTest.QueueRunner({
205
- queueableFns: [queueableFn],
206
- onComplete: onComplete,
207
- onException: onException
208
- });
209
-
210
- queueRunner.execute();
211
-
212
- jasmine.clock().tick(1);
213
- expect(onComplete).toHaveBeenCalled();
214
-
215
- jasmine.clock().tick(jasmineUnderTest.DEFAULT_TIMEOUT_INTERVAL);
216
- expect(onException).not.toHaveBeenCalled();
217
- });
218
-
219
- it("only moves to the next spec the first time you call done", function() {
220
- var queueableFn = { fn: function(done) {done(); done();} },
221
- nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
222
- queueRunner = new jasmineUnderTest.QueueRunner({
223
- queueableFns: [queueableFn, nextQueueableFn]
224
- });
225
-
226
- queueRunner.execute();
227
- jasmine.clock().tick(1);
228
- expect(nextQueueableFn.fn.calls.count()).toEqual(1);
229
- });
230
-
231
- it("does not move to the next spec if done is called after an exception has ended the spec", function() {
232
- var queueableFn = { fn: function(done) {
233
- setTimeout(done, 1);
234
- throw new Error('error!');
235
- } },
236
- nextQueueableFn = { fn: jasmine.createSpy('nextFn') },
237
- queueRunner = new jasmineUnderTest.QueueRunner({
238
- queueableFns: [queueableFn, nextQueueableFn]
239
- });
240
-
241
- queueRunner.execute();
242
- jasmine.clock().tick(1);
243
- expect(nextQueueableFn.fn.calls.count()).toEqual(1);
244
- });
245
-
246
- it("should return a null when you call done", function () {
247
- // Some promises want handlers to return anything but undefined to help catch "forgotten returns".
248
- var doneReturn,
249
- queueableFn = { fn: function(done) {
250
- doneReturn = done();
251
- } },
252
- queueRunner = new jasmineUnderTest.QueueRunner({
253
- queueableFns: [queueableFn]
254
- });
255
-
256
- queueRunner.execute();
257
- expect(doneReturn).toBe(null);
258
- });
259
-
260
- it("continues running functions when an exception is thrown in async code without timing out", function() {
261
- var queueableFn = { fn: function(done) { throwAsync(); }, timeout: function() { return 1; } },
262
- nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
263
- onException = jasmine.createSpy('onException'),
264
- globalErrors = { pushListener: jasmine.createSpy('pushListener'), popListener: jasmine.createSpy('popListener') },
265
- queueRunner = new jasmineUnderTest.QueueRunner({
266
- queueableFns: [queueableFn, nextQueueableFn],
267
- onException: onException,
268
- globalErrors: globalErrors
269
- }),
270
- throwAsync = function() {
271
- globalErrors.pushListener.calls.mostRecent().args[0](new Error('foo'));
272
- jasmine.clock().tick(2);
273
- };
274
-
275
- nextQueueableFn.fn.and.callFake(function() {
276
- // should remove the same function that was added
277
- expect(globalErrors.popListener).toHaveBeenCalledWith(globalErrors.pushListener.calls.argsFor(1)[0]);
278
- });
279
-
280
- queueRunner.execute();
281
-
282
- function errorWithMessage(message) {
283
- return {
284
- asymmetricMatch: function(other) {
285
- return new RegExp(message).test(other.message);
286
- },
287
- toString: function() {
288
- return '<Error with message like "' + message + '">';
289
- }
290
- };
291
- }
292
- expect(onException).not.toHaveBeenCalledWith(errorWithMessage(/DEFAULT_TIMEOUT_INTERVAL/));
293
- expect(onException).toHaveBeenCalledWith(errorWithMessage(/^foo$/));
294
- expect(nextQueueableFn.fn).toHaveBeenCalled();
295
- });
296
-
297
- it("handles exceptions thrown while waiting for the stack to clear", function() {
298
- var queueableFn = { fn: function(done) { done() } },
299
- global = {},
300
- errorListeners = [],
301
- globalErrors = {
302
- pushListener: function(f) { errorListeners.push(f); },
303
- popListener: function() { errorListeners.pop(); }
304
- },
305
- clearStack = jasmine.createSpy('clearStack'),
306
- onException = jasmine.createSpy('onException'),
307
- queueRunner = new jasmineUnderTest.QueueRunner({
308
- queueableFns: [queueableFn],
309
- globalErrors: globalErrors,
310
- clearStack: clearStack,
311
- onException: onException
312
- }),
313
- error = new Error('nope');
314
-
315
- queueRunner.execute();
316
- jasmine.clock().tick();
317
- expect(clearStack).toHaveBeenCalled();
318
- expect(errorListeners.length).toEqual(1);
319
- errorListeners[0](error);
320
- clearStack.calls.argsFor(0)[0]();
321
- expect(onException).toHaveBeenCalledWith(error);
322
- });
323
- });
324
-
325
- describe("with a function that returns a promise", function() {
326
- function StubPromise() {}
327
-
328
- StubPromise.prototype.then = function(resolve, reject) {
329
- this.resolveHandler = resolve;
330
- this.rejectHandler = reject;
331
- };
332
-
333
- beforeEach(function() {
334
- jasmine.clock().install();
335
- });
336
-
337
- afterEach(function() {
338
- jasmine.clock().uninstall();
339
- });
340
-
341
- it("runs the function asynchronously, advancing once the promise is settled", function() {
342
- var onComplete = jasmine.createSpy('onComplete'),
343
- fnCallback = jasmine.createSpy('fnCallback'),
344
- p1 = new StubPromise(),
345
- p2 = new StubPromise(),
346
- queueableFn1 = { fn: function() {
347
- setTimeout(function() {
348
- p1.resolveHandler();
349
- }, 100);
350
- return p1;
351
- } };
352
- queueableFn2 = { fn: function() {
353
- fnCallback();
354
- setTimeout(function() {
355
- p2.resolveHandler();
356
- }, 100);
357
- return p2;
358
- } },
359
- queueRunner = new jasmineUnderTest.QueueRunner({
360
- queueableFns: [queueableFn1, queueableFn2],
361
- onComplete: onComplete
362
- });
363
-
364
- queueRunner.execute();
365
- expect(fnCallback).not.toHaveBeenCalled();
366
- expect(onComplete).not.toHaveBeenCalled();
367
-
368
- jasmine.clock().tick(100);
369
-
370
- expect(fnCallback).toHaveBeenCalled();
371
- expect(onComplete).not.toHaveBeenCalled();
372
-
373
- jasmine.clock().tick(100);
374
-
375
- expect(onComplete).toHaveBeenCalled();
376
- });
377
-
378
- it("handles a rejected promise like an unhandled exception", function() {
379
- var promise = new StubPromise(),
380
- queueableFn1 = { fn: function() {
381
- setTimeout(function() {
382
- promise.rejectHandler('foo')
383
- }, 100);
384
- return promise;
385
- } },
386
- queueableFn2 = { fn: jasmine.createSpy('fn2') },
387
- failFn = jasmine.createSpy('fail'),
388
- onExceptionCallback = jasmine.createSpy('on exception callback'),
389
- queueRunner = new jasmineUnderTest.QueueRunner({
390
- queueableFns: [queueableFn1, queueableFn2],
391
- onException: onExceptionCallback
392
- });
393
-
394
- queueRunner.execute();
395
-
396
- expect(onExceptionCallback).not.toHaveBeenCalled();
397
- expect(queueableFn2.fn).not.toHaveBeenCalled();
398
-
399
- jasmine.clock().tick(100);
400
-
401
- expect(onExceptionCallback).toHaveBeenCalledWith('foo');
402
- expect(queueableFn2.fn).toHaveBeenCalled();
403
- });
404
- });
405
-
406
- it("calls exception handlers when an exception is thrown in a fn", function() {
407
- var queueableFn = { type: 'queueable',
408
- fn: function() {
409
- throw new Error('fake error');
410
- } },
411
- onExceptionCallback = jasmine.createSpy('on exception callback'),
412
- queueRunner = new jasmineUnderTest.QueueRunner({
413
- queueableFns: [queueableFn],
414
- onException: onExceptionCallback
415
- });
416
-
417
- queueRunner.execute();
418
-
419
- expect(onExceptionCallback).toHaveBeenCalledWith(jasmine.any(Error));
420
- });
421
-
422
- it("rethrows an exception if told to", function() {
423
- var queueableFn = { fn: function() {
424
- throw new Error('fake error');
425
- } },
426
- queueRunner = new jasmineUnderTest.QueueRunner({
427
- queueableFns: [queueableFn],
428
- catchException: function(e) { return false; }
429
- });
430
-
431
- expect(function() {
432
- queueRunner.execute();
433
- }).toThrowError('fake error');
434
- });
435
-
436
- it("continues running the functions even after an exception is thrown in an async spec", function() {
437
- var queueableFn = { fn: function(done) { throw new Error("error"); } },
438
- nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
439
- queueRunner = new jasmineUnderTest.QueueRunner({
440
- queueableFns: [queueableFn, nextQueueableFn]
441
- });
442
-
443
- queueRunner.execute();
444
- expect(nextQueueableFn.fn).toHaveBeenCalled();
445
- });
446
-
447
- describe("When configured to complete on first error", function() {
448
- it("skips to cleanup functions on the first exception", function() {
449
- var queueableFn = { fn: function() { throw new Error("error"); } },
450
- nextQueueableFn = { fn: jasmine.createSpy("nextFunction") },
451
- cleanupFn = { fn: jasmine.createSpy("cleanup") },
452
- queueRunner = new jasmineUnderTest.QueueRunner({
453
- queueableFns: [queueableFn, nextQueueableFn],
454
- cleanupFns: [cleanupFn],
455
- completeOnFirstError: true
456
- });
457
-
458
- queueRunner.execute();
459
- expect(nextQueueableFn.fn).not.toHaveBeenCalled();
460
- expect(cleanupFn.fn).toHaveBeenCalled();
461
- });
462
-
463
- it("does not skip when a cleanup function throws", function() {
464
- var queueableFn = { fn: function() { } },
465
- cleanupFn1 = { fn: function() { throw new Error("error"); } },
466
- cleanupFn2 = { fn: jasmine.createSpy("cleanupFn2") },
467
- queueRunner = new jasmineUnderTest.QueueRunner({
468
- queueableFns: [queueableFn],
469
- cleanupFns: [cleanupFn1, cleanupFn2],
470
- completeOnFirstError: true
471
- });
472
-
473
- queueRunner.execute();
474
- expect(cleanupFn2.fn).toHaveBeenCalled();
475
- });
476
-
477
- describe("with an asynchronous function", function() {
478
- beforeEach(function() {
479
- jasmine.clock().install();
480
- });
481
-
482
- afterEach(function() {
483
- jasmine.clock().uninstall();
484
- });
485
-
486
-
487
- it("skips to cleanup functions on the first exception", function() {
488
- var errorListeners = [],
489
- queueableFn = { fn: function(done) {} },
490
- nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
491
- cleanupFn = { fn: jasmine.createSpy('cleanup') },
492
- queueRunner = new jasmineUnderTest.QueueRunner({
493
- globalErrors: {
494
- pushListener: function(f) { errorListeners.push(f); },
495
- popListener: function() { errorListeners.pop(); },
496
- },
497
- queueableFns: [queueableFn, nextQueueableFn],
498
- cleanupFns: [cleanupFn],
499
- completeOnFirstError: true,
500
- });
501
-
502
- queueRunner.execute();
503
- errorListeners[errorListeners.length - 1](new Error('error'));
504
- expect(nextQueueableFn.fn).not.toHaveBeenCalled();
505
- expect(cleanupFn.fn).toHaveBeenCalled();
506
- });
507
-
508
- it("skips to cleanup functions when next.fail is called", function() {
509
- var queueableFn = { fn: function(done) {
510
- done.fail('nope');
511
- } },
512
- nextQueueableFn = { fn: jasmine.createSpy('nextFunction') },
513
- cleanupFn = { fn: jasmine.createSpy('cleanup') },
514
- queueRunner = new jasmineUnderTest.QueueRunner({
515
- queueableFns: [queueableFn, nextQueueableFn],
516
- cleanupFns: [cleanupFn],
517
- completeOnFirstError: true,
518
- });
519
-
520
- queueRunner.execute();
521
- jasmine.clock().tick();
522
- expect(nextQueueableFn.fn).not.toHaveBeenCalled();
523
- expect(cleanupFn.fn).toHaveBeenCalled();
524
- });
525
- });
526
- });
527
-
528
- it("calls a provided complete callback when done", function() {
529
- var queueableFn = { fn: jasmine.createSpy('fn') },
530
- completeCallback = jasmine.createSpy('completeCallback'),
531
- queueRunner = new jasmineUnderTest.QueueRunner({
532
- queueableFns: [queueableFn],
533
- onComplete: completeCallback
534
- });
535
-
536
- queueRunner.execute();
537
-
538
- expect(completeCallback).toHaveBeenCalled();
539
- });
540
-
541
- describe("clearing the stack", function() {
542
- beforeEach(function() {
543
- jasmine.clock().install();
544
- });
545
-
546
- afterEach(function() {
547
- jasmine.clock().uninstall();
548
- });
549
-
550
- it("calls a provided stack clearing function when done", function() {
551
- var asyncFn = { fn: function(done) { done() } },
552
- afterFn = { fn: jasmine.createSpy('afterFn') },
553
- completeCallback = jasmine.createSpy('completeCallback'),
554
- clearStack = jasmine.createSpy('clearStack'),
555
- queueRunner = new jasmineUnderTest.QueueRunner({
556
- queueableFns: [asyncFn, afterFn],
557
- clearStack: clearStack,
558
- onComplete: completeCallback
559
- });
560
-
561
- clearStack.and.callFake(function(fn) { fn(); });
562
-
563
- queueRunner.execute();
564
- jasmine.clock().tick();
565
- expect(afterFn.fn).toHaveBeenCalled();
566
- expect(clearStack).toHaveBeenCalled();
567
- clearStack.calls.argsFor(0)[0]();
568
- expect(completeCallback).toHaveBeenCalled();
569
- });
570
- });
571
-
572
- describe('when user context has not been defined', function() {
573
- beforeEach(function() {
574
- var fn;
575
-
576
- this.fn = fn = jasmine.createSpy('fn1');
577
- this.queueRunner = new jasmineUnderTest.QueueRunner({
578
- queueableFns: [{ fn: fn }]
579
- });
580
- });
581
-
582
- it('runs the functions on the scope of a UserContext', function() {
583
- var calls = [],
584
- context;
585
-
586
- this.fn.and.callFake(function() {
587
- context = this;
588
- });
589
-
590
- this.queueRunner.execute();
591
-
592
- expect(context.constructor).toBe(jasmineUnderTest.UserContext);
593
- });
594
- });
595
-
596
- describe('when user context has been defined', function() {
597
- beforeEach(function() {
598
- var fn, context;
599
-
600
- this.fn = fn = jasmine.createSpy('fn1');
601
- this.context = context = new jasmineUnderTest.UserContext();
602
- this.queueRunner = new jasmineUnderTest.QueueRunner({
603
- queueableFns: [{ fn: fn }],
604
- userContext: context
605
- });
606
- });
607
-
608
- it('runs the functions on the scope of a UserContext', function() {
609
- var calls = [],
610
- context;
611
- this.fn.and.callFake(function() {
612
- context = this;
613
- });
614
-
615
- this.queueRunner.execute();
616
-
617
- expect(context).toBe(this.context);
618
- });
619
- });
620
- });
@@ -1,79 +0,0 @@
1
- describe("ReportDispatcher", function() {
2
-
3
- it("builds an interface of requested methods", function() {
4
- var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar', 'baz']);
5
-
6
- expect(dispatcher.foo).toBeDefined();
7
- expect(dispatcher.bar).toBeDefined();
8
- expect(dispatcher.baz).toBeDefined();
9
- });
10
-
11
- it("dispatches requested methods to added reporters", function() {
12
- var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
13
- reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
14
- anotherReporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
15
-
16
- dispatcher.addReporter(reporter);
17
- dispatcher.addReporter(anotherReporter);
18
-
19
- dispatcher.foo(123, 456);
20
-
21
- expect(reporter.foo).toHaveBeenCalledWith(123, 456);
22
- expect(anotherReporter.foo).toHaveBeenCalledWith(123, 456);
23
-
24
- dispatcher.bar('a', 'b');
25
-
26
- expect(reporter.bar).toHaveBeenCalledWith('a', 'b');
27
- expect(anotherReporter.bar).toHaveBeenCalledWith('a', 'b');
28
- });
29
-
30
- it("does not dispatch to a reporter if the reporter doesn't accept the method", function() {
31
- var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo']),
32
- reporter = jasmine.createSpyObj('reporter', ['baz']);
33
-
34
- dispatcher.addReporter(reporter);
35
-
36
- expect(function() {
37
- dispatcher.foo(123, 456);
38
- }).not.toThrow();
39
- });
40
-
41
- it("allows providing a fallback reporter in case there's no other report", function() {
42
- var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
43
- reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']);
44
-
45
- dispatcher.provideFallbackReporter(reporter);
46
- dispatcher.foo(123, 456);
47
- expect(reporter.foo).toHaveBeenCalledWith(123, 456);
48
- });
49
-
50
- it("does not call fallback reporting methods when another report is provided", function() {
51
- var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
52
- reporter = jasmine.createSpyObj('reporter', ['foo', 'bar']),
53
- fallbackReporter = jasmine.createSpyObj('otherReporter', ['foo', 'bar']);
54
-
55
- dispatcher.provideFallbackReporter(fallbackReporter);
56
- dispatcher.addReporter(reporter);
57
- dispatcher.foo(123, 456);
58
-
59
- expect(reporter.foo).toHaveBeenCalledWith(123, 456);
60
- expect(fallbackReporter.foo).not.toHaveBeenCalledWith(123, 456);
61
- });
62
-
63
- it("allows registered reporters to be cleared", function() {
64
- var dispatcher = new jasmineUnderTest.ReportDispatcher(['foo', 'bar']),
65
- reporter1 = jasmine.createSpyObj('reporter1', ['foo', 'bar']),
66
- reporter2 = jasmine.createSpyObj('reporter2', ['foo', 'bar']);
67
-
68
- dispatcher.addReporter(reporter1);
69
- dispatcher.foo(123);
70
- expect(reporter1.foo).toHaveBeenCalledWith(123);
71
-
72
- dispatcher.clearReporters();
73
- dispatcher.addReporter(reporter2);
74
- dispatcher.bar(456);
75
-
76
- expect(reporter1.bar).not.toHaveBeenCalled();
77
- expect(reporter2.bar).toHaveBeenCalledWith(456);
78
- });
79
- });