jasmine-core 2.2.0 → 2.3.0
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/boot.js +6 -6
- data/lib/jasmine-core/boot/boot.js +6 -6
- data/lib/jasmine-core/example/spec/SpecHelper.js +1 -1
- data/lib/jasmine-core/jasmine-html.js +43 -13
- data/lib/jasmine-core/jasmine.css +6 -3
- data/lib/jasmine-core/jasmine.js +399 -149
- data/lib/jasmine-core/spec/core/ClockSpec.js +214 -22
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +0 -41
- data/lib/jasmine-core/spec/core/EnvSpec.js +20 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +57 -27
- data/lib/jasmine-core/spec/core/SpecSpec.js +140 -1
- data/lib/jasmine-core/spec/core/SuiteSpec.js +47 -244
- data/lib/jasmine-core/spec/core/TreeProcessorSpec.js +633 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +2 -3
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +31 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +35 -6
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +108 -15
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +27 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +0 -2
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +115 -1
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +2 -5
- data/lib/jasmine-core/version.rb +1 -1
- metadata +96 -95
@@ -6,7 +6,7 @@ describe("Clock", function() {
|
|
6
6
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
|
7
7
|
delayedFn = jasmine.createSpy("delayedFn"),
|
8
8
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
9
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
9
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
10
10
|
|
11
11
|
fakeGlobal.setTimeout(delayedFn, 0);
|
12
12
|
|
@@ -28,7 +28,7 @@ describe("Clock", function() {
|
|
28
28
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
|
29
29
|
delayedFn = jasmine.createSpy("delayedFn"),
|
30
30
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
31
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
31
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
32
32
|
|
33
33
|
fakeGlobal.clearTimeout("foo");
|
34
34
|
|
@@ -50,7 +50,7 @@ describe("Clock", function() {
|
|
50
50
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction"]),
|
51
51
|
delayedFn = jasmine.createSpy("delayedFn"),
|
52
52
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
53
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
53
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
54
54
|
|
55
55
|
fakeGlobal.setInterval(delayedFn, 0);
|
56
56
|
|
@@ -72,7 +72,7 @@ describe("Clock", function() {
|
|
72
72
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["removeFunctionWithId"]),
|
73
73
|
delayedFn = jasmine.createSpy("delayedFn"),
|
74
74
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
75
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
75
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
76
76
|
|
77
77
|
fakeGlobal.clearInterval("foo");
|
78
78
|
|
@@ -88,6 +88,78 @@ describe("Clock", function() {
|
|
88
88
|
expect(fakeClearInterval).not.toHaveBeenCalled();
|
89
89
|
});
|
90
90
|
|
91
|
+
it("does not install if the current setTimeout is not the original function on the global", function() {
|
92
|
+
var originalFakeSetTimeout = function() {},
|
93
|
+
replacedSetTimeout = function() {},
|
94
|
+
fakeGlobal = { setTimeout: originalFakeSetTimeout },
|
95
|
+
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
96
|
+
mockDate = {},
|
97
|
+
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
98
|
+
|
99
|
+
fakeGlobal.setTimeout = replacedSetTimeout;
|
100
|
+
|
101
|
+
expect(function() {
|
102
|
+
clock.install();
|
103
|
+
}).toThrowError(/unable to install/);
|
104
|
+
|
105
|
+
expect(delayedFunctionSchedulerFactory).not.toHaveBeenCalled();
|
106
|
+
expect(fakeGlobal.setTimeout).toBe(replacedSetTimeout);
|
107
|
+
});
|
108
|
+
|
109
|
+
it("does not install if the current clearTimeout is not the original function on the global", function() {
|
110
|
+
var originalFakeClearTimeout = function() {},
|
111
|
+
replacedClearTimeout = function() {},
|
112
|
+
fakeGlobal = { clearTimeout: originalFakeClearTimeout },
|
113
|
+
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
114
|
+
mockDate = {},
|
115
|
+
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
116
|
+
|
117
|
+
fakeGlobal.clearTimeout = replacedClearTimeout;
|
118
|
+
|
119
|
+
expect(function() {
|
120
|
+
clock.install();
|
121
|
+
}).toThrowError(/unable to install/);
|
122
|
+
|
123
|
+
expect(delayedFunctionSchedulerFactory).not.toHaveBeenCalled();
|
124
|
+
expect(fakeGlobal.clearTimeout).toBe(replacedClearTimeout);
|
125
|
+
});
|
126
|
+
|
127
|
+
it("does not install if the current setInterval is not the original function on the global", function() {
|
128
|
+
var originalFakeSetInterval = function() {},
|
129
|
+
replacedSetInterval = function() {},
|
130
|
+
fakeGlobal = { setInterval: originalFakeSetInterval },
|
131
|
+
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
132
|
+
mockDate = {},
|
133
|
+
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
134
|
+
|
135
|
+
fakeGlobal.setInterval = replacedSetInterval;
|
136
|
+
|
137
|
+
expect(function() {
|
138
|
+
clock.install();
|
139
|
+
}).toThrowError(/unable to install/);
|
140
|
+
|
141
|
+
expect(delayedFunctionSchedulerFactory).not.toHaveBeenCalled();
|
142
|
+
expect(fakeGlobal.setInterval).toBe(replacedSetInterval);
|
143
|
+
});
|
144
|
+
|
145
|
+
it("does not install if the current clearInterval is not the original function on the global", function() {
|
146
|
+
var originalFakeClearInterval = function() {},
|
147
|
+
replacedClearInterval = function() {},
|
148
|
+
fakeGlobal = { clearInterval: originalFakeClearInterval },
|
149
|
+
delayedFunctionSchedulerFactory = jasmine.createSpy('delayedFunctionSchedulerFactory'),
|
150
|
+
mockDate = {},
|
151
|
+
clock = new j$.Clock(fakeGlobal, delayedFunctionSchedulerFactory, mockDate);
|
152
|
+
|
153
|
+
fakeGlobal.clearInterval = replacedClearInterval;
|
154
|
+
|
155
|
+
expect(function() {
|
156
|
+
clock.install();
|
157
|
+
}).toThrowError(/unable to install/);
|
158
|
+
|
159
|
+
expect(delayedFunctionSchedulerFactory).not.toHaveBeenCalled();
|
160
|
+
expect(fakeGlobal.clearInterval).toBe(replacedClearInterval);
|
161
|
+
});
|
162
|
+
|
91
163
|
it("replaces the global timer functions on uninstall", function() {
|
92
164
|
var fakeSetTimeout = jasmine.createSpy("global setTimeout"),
|
93
165
|
fakeClearTimeout = jasmine.createSpy("global clearTimeout"),
|
@@ -102,7 +174,7 @@ describe("Clock", function() {
|
|
102
174
|
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset"]),
|
103
175
|
delayedFn = jasmine.createSpy("delayedFn"),
|
104
176
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
105
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
177
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
106
178
|
|
107
179
|
clock.install();
|
108
180
|
clock.uninstall();
|
@@ -118,6 +190,103 @@ describe("Clock", function() {
|
|
118
190
|
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
|
119
191
|
});
|
120
192
|
|
193
|
+
it("can be installed for the duration of a passed in function and uninstalled when done", function() {
|
194
|
+
var fakeSetTimeout = jasmine.createSpy("global setTimeout"),
|
195
|
+
fakeClearTimeout = jasmine.createSpy("global clearTimeout"),
|
196
|
+
fakeSetInterval = jasmine.createSpy("global setInterval"),
|
197
|
+
fakeClearInterval = jasmine.createSpy("global clearInterval"),
|
198
|
+
fakeGlobal = {
|
199
|
+
setTimeout: fakeSetTimeout,
|
200
|
+
clearTimeout: fakeClearTimeout,
|
201
|
+
setInterval: fakeSetInterval,
|
202
|
+
clearInterval: fakeClearInterval
|
203
|
+
},
|
204
|
+
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
|
205
|
+
delayedFn = jasmine.createSpy("delayedFn"),
|
206
|
+
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
207
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
208
|
+
passedFunctionCalled = false;
|
209
|
+
|
210
|
+
clock.withMock(function() {
|
211
|
+
fakeGlobal.setTimeout(delayedFn, 0);
|
212
|
+
fakeGlobal.clearTimeout("foo");
|
213
|
+
fakeGlobal.setInterval(delayedFn, 10);
|
214
|
+
fakeGlobal.clearInterval("bar");
|
215
|
+
passedFunctionCalled = true;
|
216
|
+
});
|
217
|
+
|
218
|
+
expect(passedFunctionCalled).toBe(true);
|
219
|
+
|
220
|
+
expect(fakeSetTimeout).not.toHaveBeenCalled();
|
221
|
+
expect(fakeClearTimeout).not.toHaveBeenCalled();
|
222
|
+
expect(fakeSetInterval).not.toHaveBeenCalled();
|
223
|
+
expect(fakeClearInterval).not.toHaveBeenCalled();
|
224
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalled();
|
225
|
+
|
226
|
+
delayedFunctionScheduler.scheduleFunction.calls.reset();
|
227
|
+
|
228
|
+
fakeGlobal.setTimeout(delayedFn, 0);
|
229
|
+
fakeGlobal.clearTimeout("foo");
|
230
|
+
fakeGlobal.setInterval(delayedFn, 10);
|
231
|
+
fakeGlobal.clearInterval("bar");
|
232
|
+
|
233
|
+
expect(fakeSetTimeout).toHaveBeenCalledWith(delayedFn, 0);
|
234
|
+
expect(fakeClearTimeout).toHaveBeenCalledWith("foo");
|
235
|
+
expect(fakeSetInterval).toHaveBeenCalledWith(delayedFn, 10);
|
236
|
+
expect(fakeClearInterval).toHaveBeenCalledWith("bar");
|
237
|
+
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
|
238
|
+
});
|
239
|
+
|
240
|
+
it("can be installed for the duration of a passed in function and uninstalled if an error is thrown", function() {
|
241
|
+
var fakeSetTimeout = jasmine.createSpy("global setTimeout"),
|
242
|
+
fakeClearTimeout = jasmine.createSpy("global clearTimeout"),
|
243
|
+
fakeSetInterval = jasmine.createSpy("global setInterval"),
|
244
|
+
fakeClearInterval = jasmine.createSpy("global clearInterval"),
|
245
|
+
fakeGlobal = {
|
246
|
+
setTimeout: fakeSetTimeout,
|
247
|
+
clearTimeout: fakeClearTimeout,
|
248
|
+
setInterval: fakeSetInterval,
|
249
|
+
clearInterval: fakeClearInterval
|
250
|
+
},
|
251
|
+
delayedFunctionScheduler = jasmine.createSpyObj("delayedFunctionScheduler", ["scheduleFunction", "reset", "removeFunctionWithId"]),
|
252
|
+
delayedFn = jasmine.createSpy("delayedFn"),
|
253
|
+
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
254
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
255
|
+
passedFunctionCalled = false;
|
256
|
+
|
257
|
+
expect(function() {
|
258
|
+
clock.withMock(function() {
|
259
|
+
fakeGlobal.setTimeout(delayedFn, 0);
|
260
|
+
fakeGlobal.clearTimeout("foo");
|
261
|
+
fakeGlobal.setInterval(delayedFn, 10);
|
262
|
+
fakeGlobal.clearInterval("bar");
|
263
|
+
passedFunctionCalled = true;
|
264
|
+
throw 'oops';
|
265
|
+
});
|
266
|
+
}).toThrow('oops');
|
267
|
+
|
268
|
+
expect(passedFunctionCalled).toBe(true);
|
269
|
+
|
270
|
+
expect(fakeSetTimeout).not.toHaveBeenCalled();
|
271
|
+
expect(fakeClearTimeout).not.toHaveBeenCalled();
|
272
|
+
expect(fakeSetInterval).not.toHaveBeenCalled();
|
273
|
+
expect(fakeClearInterval).not.toHaveBeenCalled();
|
274
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalled();
|
275
|
+
|
276
|
+
delayedFunctionScheduler.scheduleFunction.calls.reset();
|
277
|
+
|
278
|
+
fakeGlobal.setTimeout(delayedFn, 0);
|
279
|
+
fakeGlobal.clearTimeout("foo");
|
280
|
+
fakeGlobal.setInterval(delayedFn, 10);
|
281
|
+
fakeGlobal.clearInterval("bar");
|
282
|
+
|
283
|
+
expect(fakeSetTimeout).toHaveBeenCalledWith(delayedFn, 0);
|
284
|
+
expect(fakeClearTimeout).toHaveBeenCalledWith("foo");
|
285
|
+
expect(fakeSetInterval).toHaveBeenCalledWith(delayedFn, 10);
|
286
|
+
expect(fakeClearInterval).toHaveBeenCalledWith("bar");
|
287
|
+
expect(delayedFunctionScheduler.scheduleFunction).not.toHaveBeenCalled();
|
288
|
+
});
|
289
|
+
|
121
290
|
it("schedules the delayed function (via setTimeout) with the fake timer", function() {
|
122
291
|
var fakeSetTimeout = jasmine.createSpy('setTimeout'),
|
123
292
|
scheduleFunction = jasmine.createSpy('scheduleFunction'),
|
@@ -125,7 +294,7 @@ describe("Clock", function() {
|
|
125
294
|
fakeGlobal = { setTimeout: fakeSetTimeout },
|
126
295
|
delayedFn = jasmine.createSpy('delayedFn'),
|
127
296
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
128
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
297
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
129
298
|
|
130
299
|
clock.install();
|
131
300
|
clock.setTimeout(delayedFn, 0, 'a', 'b');
|
@@ -142,7 +311,7 @@ describe("Clock", function() {
|
|
142
311
|
fakeGlobal = { setTimeout: fakeSetTimeout },
|
143
312
|
delayedFn = jasmine.createSpy('delayedFn'),
|
144
313
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
145
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate),
|
314
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
146
315
|
timeoutId;
|
147
316
|
|
148
317
|
clock.install();
|
@@ -157,7 +326,7 @@ describe("Clock", function() {
|
|
157
326
|
fakeGlobal = { setTimeout: fakeClearTimeout },
|
158
327
|
delayedFn = jasmine.createSpy('delayedFn'),
|
159
328
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
160
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
329
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
161
330
|
|
162
331
|
clock.install();
|
163
332
|
clock.clearTimeout(123);
|
@@ -173,7 +342,7 @@ describe("Clock", function() {
|
|
173
342
|
fakeGlobal = { setInterval: fakeSetInterval },
|
174
343
|
delayedFn = jasmine.createSpy('delayedFn'),
|
175
344
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
176
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
345
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
177
346
|
|
178
347
|
clock.install();
|
179
348
|
clock.setInterval(delayedFn, 0, 'a', 'b');
|
@@ -190,7 +359,7 @@ describe("Clock", function() {
|
|
190
359
|
fakeGlobal = { setInterval: fakeSetInterval },
|
191
360
|
delayedFn = jasmine.createSpy('delayedFn'),
|
192
361
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
193
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate),
|
362
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
194
363
|
intervalId;
|
195
364
|
|
196
365
|
clock.install();
|
@@ -205,7 +374,7 @@ describe("Clock", function() {
|
|
205
374
|
fakeGlobal = { setInterval: clearInterval },
|
206
375
|
delayedFn = jasmine.createSpy('delayedFn'),
|
207
376
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
208
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
377
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
209
378
|
|
210
379
|
clock.install();
|
211
380
|
clock.clearInterval(123);
|
@@ -232,7 +401,7 @@ describe("Clock", function() {
|
|
232
401
|
setInterval: fakeSetInterval
|
233
402
|
},
|
234
403
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
235
|
-
clock = new j$.Clock(fakeGlobal, delayedFunctionScheduler, mockDate);
|
404
|
+
clock = new j$.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate);
|
236
405
|
|
237
406
|
fakeSetTimeout.apply = null;
|
238
407
|
fakeSetInterval.apply = null;
|
@@ -251,7 +420,6 @@ describe("Clock", function() {
|
|
251
420
|
clock.setInterval(fn, 0, 'extra');
|
252
421
|
}).toThrow();
|
253
422
|
});
|
254
|
-
|
255
423
|
});
|
256
424
|
|
257
425
|
describe("Clock (acceptance)", function() {
|
@@ -262,7 +430,7 @@ describe("Clock (acceptance)", function() {
|
|
262
430
|
recurring1 = jasmine.createSpy('recurring1'),
|
263
431
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
264
432
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
265
|
-
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
|
433
|
+
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
266
434
|
|
267
435
|
clock.install();
|
268
436
|
|
@@ -309,7 +477,7 @@ describe("Clock (acceptance)", function() {
|
|
309
477
|
var clearedFn = jasmine.createSpy('clearedFn'),
|
310
478
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
311
479
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
312
|
-
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate),
|
480
|
+
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
|
313
481
|
timeoutId;
|
314
482
|
|
315
483
|
clock.install();
|
@@ -327,7 +495,7 @@ describe("Clock (acceptance)", function() {
|
|
327
495
|
var spy = jasmine.createSpy('spy'),
|
328
496
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
329
497
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
330
|
-
clock = new j$.Clock({setInterval: function() {}}, delayedFunctionScheduler, mockDate),
|
498
|
+
clock = new j$.Clock({setInterval: function() {}}, function () { return delayedFunctionScheduler; }, mockDate),
|
331
499
|
intervalId;
|
332
500
|
|
333
501
|
clock.install();
|
@@ -345,7 +513,7 @@ describe("Clock (acceptance)", function() {
|
|
345
513
|
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
346
514
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
347
515
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
348
|
-
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
|
516
|
+
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
349
517
|
|
350
518
|
clock.install();
|
351
519
|
|
@@ -362,7 +530,7 @@ describe("Clock (acceptance)", function() {
|
|
362
530
|
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
363
531
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
364
532
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
365
|
-
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
|
533
|
+
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
366
534
|
|
367
535
|
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 0); });
|
368
536
|
clock.install();
|
@@ -381,7 +549,7 @@ describe("Clock (acceptance)", function() {
|
|
381
549
|
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
382
550
|
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
383
551
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
384
|
-
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler, mockDate);
|
552
|
+
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
385
553
|
|
386
554
|
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
|
387
555
|
clock.install();
|
@@ -392,11 +560,35 @@ describe("Clock (acceptance)", function() {
|
|
392
560
|
expect(delayedFn2).toHaveBeenCalled();
|
393
561
|
});
|
394
562
|
|
563
|
+
it("correctly schedules functions scheduled while the Clock is advancing but after the Clock is uninstalled", function() {
|
564
|
+
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
565
|
+
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
566
|
+
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
567
|
+
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
568
|
+
clock = new j$.Clock({setTimeout: function() {}}, function () { return delayedFunctionScheduler; }, mockDate);
|
569
|
+
|
570
|
+
delayedFn1.and.callFake(function() {
|
571
|
+
clock.uninstall();
|
572
|
+
clock.install();
|
573
|
+
clock.setTimeout(delayedFn2, 0);
|
574
|
+
});
|
575
|
+
|
576
|
+
clock.install();
|
577
|
+
clock.setTimeout(delayedFn1, 1);
|
578
|
+
|
579
|
+
clock.tick(1);
|
580
|
+
expect(delayedFn1).toHaveBeenCalled();
|
581
|
+
expect(delayedFn2).not.toHaveBeenCalled();
|
582
|
+
|
583
|
+
clock.tick(1);
|
584
|
+
expect(delayedFn2).toHaveBeenCalled();
|
585
|
+
});
|
586
|
+
|
395
587
|
it("does not mock the Date object by default", function() {
|
396
588
|
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
397
589
|
global = {Date: Date},
|
398
590
|
mockDate = new j$.MockDate(global),
|
399
|
-
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
|
591
|
+
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
400
592
|
|
401
593
|
clock.install();
|
402
594
|
|
@@ -413,7 +605,7 @@ describe("Clock (acceptance)", function() {
|
|
413
605
|
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
414
606
|
global = {Date: Date},
|
415
607
|
mockDate = new j$.MockDate(global),
|
416
|
-
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate);
|
608
|
+
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate);
|
417
609
|
|
418
610
|
clock.install().mockDate();
|
419
611
|
|
@@ -437,7 +629,7 @@ describe("Clock (acceptance)", function() {
|
|
437
629
|
var delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
438
630
|
global = {Date: Date},
|
439
631
|
mockDate = new j$.MockDate(global),
|
440
|
-
clock = new j$.Clock({setTimeout: setTimeout}, delayedFunctionScheduler, mockDate),
|
632
|
+
clock = new j$.Clock({setTimeout: setTimeout}, function () { return delayedFunctionScheduler; }, mockDate),
|
441
633
|
baseTime = new Date(2013, 9, 23);
|
442
634
|
|
443
635
|
|
@@ -113,47 +113,6 @@ describe("DelayedFunctionScheduler", function() {
|
|
113
113
|
expect(fn).not.toHaveBeenCalled();
|
114
114
|
});
|
115
115
|
|
116
|
-
it("reset removes scheduled functions", function() {
|
117
|
-
var scheduler = new j$.DelayedFunctionScheduler(),
|
118
|
-
fn = jasmine.createSpy('fn');
|
119
|
-
|
120
|
-
scheduler.scheduleFunction(fn, 0);
|
121
|
-
|
122
|
-
expect(fn).not.toHaveBeenCalled();
|
123
|
-
|
124
|
-
scheduler.reset();
|
125
|
-
|
126
|
-
scheduler.tick(0);
|
127
|
-
|
128
|
-
expect(fn).not.toHaveBeenCalled();
|
129
|
-
});
|
130
|
-
|
131
|
-
it("reset resets the returned ids", function() {
|
132
|
-
var scheduler = new j$.DelayedFunctionScheduler();
|
133
|
-
expect(scheduler.scheduleFunction(function() { }, 0)).toBe(1);
|
134
|
-
expect(scheduler.scheduleFunction(function() { }, 0, [], false, 123)).toBe(123);
|
135
|
-
|
136
|
-
scheduler.reset();
|
137
|
-
expect(scheduler.scheduleFunction(function() { }, 0)).toBe(1);
|
138
|
-
expect(scheduler.scheduleFunction(function() { }, 0, [], false, 123)).toBe(123);
|
139
|
-
});
|
140
|
-
|
141
|
-
it("reset resets the current tick time", function() {
|
142
|
-
var scheduler = new j$.DelayedFunctionScheduler(),
|
143
|
-
fn = jasmine.createSpy('fn');
|
144
|
-
|
145
|
-
expect(fn).not.toHaveBeenCalled();
|
146
|
-
|
147
|
-
scheduler.tick(15);
|
148
|
-
scheduler.reset();
|
149
|
-
|
150
|
-
scheduler.scheduleFunction(fn, 20, [], false, 1, 20);
|
151
|
-
|
152
|
-
scheduler.tick(5);
|
153
|
-
|
154
|
-
expect(fn).not.toHaveBeenCalled();
|
155
|
-
});
|
156
|
-
|
157
116
|
it("executes recurring functions interleaved with regular functions in the correct order", function() {
|
158
117
|
var scheduler = new j$.DelayedFunctionScheduler(),
|
159
118
|
fn = jasmine.createSpy('fn'),
|
@@ -25,4 +25,24 @@ describe("Env", function() {
|
|
25
25
|
expect(suite.description).toEqual('Jasmine__TopLevel__Suite');
|
26
26
|
});
|
27
27
|
});
|
28
|
+
|
29
|
+
it('can configure specs to throw errors on expectation failures', function() {
|
30
|
+
env.throwOnExpectationFailure(true);
|
31
|
+
|
32
|
+
spyOn(j$, 'Spec');
|
33
|
+
env.it('foo', function() {});
|
34
|
+
expect(j$.Spec).toHaveBeenCalledWith(jasmine.objectContaining({
|
35
|
+
throwOnExpectationFailure: true
|
36
|
+
}));
|
37
|
+
});
|
38
|
+
|
39
|
+
it('can configure suites to throw errors on expectation failures', function() {
|
40
|
+
env.throwOnExpectationFailure(true);
|
41
|
+
|
42
|
+
spyOn(j$, 'Suite');
|
43
|
+
env.describe('foo', function() {});
|
44
|
+
expect(j$.Suite).toHaveBeenCalledWith(jasmine.objectContaining({
|
45
|
+
throwOnExpectationFailure: true
|
46
|
+
}));
|
47
|
+
});
|
28
48
|
});
|