jasmine-core 2.5.0 → 2.99.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/console/console.js +1 -1
- data/lib/jasmine-core/boot/boot.js +4 -1
- data/lib/jasmine-core/boot.js +5 -2
- data/lib/jasmine-core/jasmine-html.js +95 -31
- data/lib/jasmine-core/jasmine.css +1 -0
- data/lib/jasmine-core/jasmine.js +3635 -1684
- data/lib/jasmine-core/node_boot.js +1 -1
- data/lib/jasmine-core/spec/core/CallTrackerSpec.js +10 -0
- data/lib/jasmine-core/spec/core/ClearStackSpec.js +137 -0
- data/lib/jasmine-core/spec/core/ClockSpec.js +94 -14
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +26 -8
- data/lib/jasmine-core/spec/core/EnvSpec.js +142 -10
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +52 -7
- data/lib/jasmine-core/spec/core/GlobalErrorsSpec.js +110 -0
- data/lib/jasmine-core/spec/core/PrettyPrintSpec.js +132 -4
- data/lib/jasmine-core/spec/core/QueueRunnerSpec.js +333 -23
- data/lib/jasmine-core/spec/core/ReportDispatcherSpec.js +16 -1
- data/lib/jasmine-core/spec/core/SpecSpec.js +30 -8
- data/lib/jasmine-core/spec/core/SpyRegistrySpec.js +225 -1
- data/lib/jasmine-core/spec/core/SpySpec.js +44 -2
- data/lib/jasmine-core/spec/core/SpyStrategySpec.js +28 -5
- data/lib/jasmine-core/spec/core/SuiteSpec.js +14 -19
- data/lib/jasmine-core/spec/core/UserContextSpec.js +54 -0
- data/lib/jasmine-core/spec/core/UtilSpec.js +71 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnySpec.js +32 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/AnythingSpec.js +32 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayContainingSpec.js +13 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ArrayWithExactContentsSpec.js +47 -0
- data/lib/jasmine-core/spec/core/asymmetric_equality/ObjectContainingSpec.js +13 -0
- data/lib/jasmine-core/spec/core/integration/CustomMatchersSpec.js +48 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +339 -38
- data/lib/jasmine-core/spec/core/integration/SpecRunningSpec.js +156 -3
- data/lib/jasmine-core/spec/core/matchers/DiffBuilderSpec.js +47 -0
- data/lib/jasmine-core/spec/core/matchers/NullDiffBuilderSpec.js +13 -0
- data/lib/jasmine-core/spec/core/matchers/ObjectPathSpec.js +43 -0
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +231 -8
- data/lib/jasmine-core/spec/core/matchers/nothingSpec.js +8 -0
- data/lib/jasmine-core/spec/core/matchers/toBeCloseToSpec.js +42 -0
- data/lib/jasmine-core/spec/core/matchers/toBeNegativeInfinitySpec.js +31 -0
- data/lib/jasmine-core/spec/core/matchers/toBePositiveInfinitySpec.js +31 -0
- data/lib/jasmine-core/spec/core/matchers/toEqualSpec.js +780 -4
- data/lib/jasmine-core/spec/core/matchers/toHaveBeenCalledBeforeSpec.js +99 -0
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +37 -0
- data/lib/jasmine-core/spec/helpers/BrowserFlags.js +4 -0
- data/lib/jasmine-core/spec/helpers/asyncAwait.js +27 -0
- data/lib/jasmine-core/spec/helpers/checkForMap.js +37 -0
- data/lib/jasmine-core/spec/helpers/checkForSet.js +41 -0
- data/lib/jasmine-core/spec/helpers/checkForSymbol.js +28 -0
- data/lib/jasmine-core/spec/helpers/checkForTypedArrays.js +20 -0
- data/lib/jasmine-core/spec/html/HtmlReporterSpec.js +105 -23
- data/lib/jasmine-core/spec/html/SpyRegistryHtmlSpec.js +34 -0
- data/lib/jasmine-core/spec/npmPackage/npmPackageSpec.js +1 -1
- data/lib/jasmine-core/version.rb +1 -1
- metadata +19 -4
@@ -117,4 +117,14 @@ describe("CallTracker", function() {
|
|
117
117
|
expect(callTracker.mostRecent().args[1]).not.toBe(arrayArg);
|
118
118
|
expect(callTracker.mostRecent().args[1]).toEqual(arrayArg);
|
119
119
|
});
|
120
|
+
|
121
|
+
it('saves primitive arguments by value', function() {
|
122
|
+
var callTracker = new jasmineUnderTest.CallTracker(),
|
123
|
+
args = [undefined, null, false, '', /\s/, 0, 1.2, NaN];
|
124
|
+
|
125
|
+
callTracker.saveArgumentsByValue();
|
126
|
+
callTracker.track({ object: {}, args: args });
|
127
|
+
|
128
|
+
expect(callTracker.mostRecent().args).toEqual(args);
|
129
|
+
});
|
120
130
|
});
|
@@ -0,0 +1,137 @@
|
|
1
|
+
describe("ClearStack", function() {
|
2
|
+
it("works in an integrationy way", function(done) {
|
3
|
+
var clearStack = jasmineUnderTest.getClearStack(jasmineUnderTest.getGlobal());
|
4
|
+
|
5
|
+
clearStack(function() {
|
6
|
+
done();
|
7
|
+
});
|
8
|
+
});
|
9
|
+
|
10
|
+
it("uses setImmediate when available", function() {
|
11
|
+
var setImmediate = jasmine.createSpy('setImmediate').and.callFake(function(fn) { fn() }),
|
12
|
+
global = { setImmediate: setImmediate },
|
13
|
+
clearStack = jasmineUnderTest.getClearStack(global),
|
14
|
+
called = false;
|
15
|
+
|
16
|
+
clearStack(function() {
|
17
|
+
called = true;
|
18
|
+
});
|
19
|
+
|
20
|
+
expect(called).toBe(true);
|
21
|
+
expect(setImmediate).toHaveBeenCalled();
|
22
|
+
});
|
23
|
+
|
24
|
+
it("uses setTimeout instead of setImmediate every 10 calls to make sure we release the CPU", function() {
|
25
|
+
var setImmediate = jasmine.createSpy('setImmediate'),
|
26
|
+
setTimeout = jasmine.createSpy('setTimeout'),
|
27
|
+
global = { setImmediate: setImmediate, setTimeout: setTimeout },
|
28
|
+
clearStack = jasmineUnderTest.getClearStack(global);
|
29
|
+
|
30
|
+
clearStack(function() { });
|
31
|
+
clearStack(function() { });
|
32
|
+
clearStack(function() { });
|
33
|
+
clearStack(function() { });
|
34
|
+
clearStack(function() { });
|
35
|
+
clearStack(function() { });
|
36
|
+
clearStack(function() { });
|
37
|
+
clearStack(function() { });
|
38
|
+
clearStack(function() { });
|
39
|
+
|
40
|
+
expect(setImmediate).toHaveBeenCalled();
|
41
|
+
expect(setTimeout).not.toHaveBeenCalled();
|
42
|
+
|
43
|
+
clearStack(function() { });
|
44
|
+
expect(setImmediate.calls.count()).toEqual(9);
|
45
|
+
expect(setTimeout.calls.count()).toEqual(1);
|
46
|
+
|
47
|
+
clearStack(function() { });
|
48
|
+
expect(setImmediate.calls.count()).toEqual(10);
|
49
|
+
expect(setTimeout.calls.count()).toEqual(1);
|
50
|
+
});
|
51
|
+
|
52
|
+
it("uses MessageChannels when available", function() {
|
53
|
+
var fakeChannel = {
|
54
|
+
port1: {},
|
55
|
+
port2: { postMessage: function() { fakeChannel.port1.onmessage(); } }
|
56
|
+
},
|
57
|
+
global = { MessageChannel: function() { return fakeChannel; } },
|
58
|
+
clearStack = jasmineUnderTest.getClearStack(global),
|
59
|
+
called = false;
|
60
|
+
|
61
|
+
clearStack(function() {
|
62
|
+
called = true;
|
63
|
+
});
|
64
|
+
|
65
|
+
expect(called).toBe(true);
|
66
|
+
});
|
67
|
+
|
68
|
+
it("uses setTimeout instead of MessageChannel every 10 calls to make sure we release the CPU", function() {
|
69
|
+
var fakeChannel = {
|
70
|
+
port1: {},
|
71
|
+
port2: {
|
72
|
+
postMessage: jasmine.createSpy('postMessage').and.callFake(function() {
|
73
|
+
fakeChannel.port1.onmessage();
|
74
|
+
})
|
75
|
+
}
|
76
|
+
},
|
77
|
+
setTimeout = jasmine.createSpy('setTimeout'),
|
78
|
+
global = { MessageChannel: function() { return fakeChannel; }, setTimeout: setTimeout },
|
79
|
+
clearStack = jasmineUnderTest.getClearStack(global);
|
80
|
+
|
81
|
+
clearStack(function() { });
|
82
|
+
clearStack(function() { });
|
83
|
+
clearStack(function() { });
|
84
|
+
clearStack(function() { });
|
85
|
+
clearStack(function() { });
|
86
|
+
clearStack(function() { });
|
87
|
+
clearStack(function() { });
|
88
|
+
clearStack(function() { });
|
89
|
+
clearStack(function() { });
|
90
|
+
|
91
|
+
expect(fakeChannel.port2.postMessage).toHaveBeenCalled();
|
92
|
+
expect(setTimeout).not.toHaveBeenCalled();
|
93
|
+
|
94
|
+
clearStack(function() { });
|
95
|
+
expect(fakeChannel.port2.postMessage.calls.count()).toEqual(9);
|
96
|
+
expect(setTimeout.calls.count()).toEqual(1);
|
97
|
+
|
98
|
+
clearStack(function() { });
|
99
|
+
expect(fakeChannel.port2.postMessage.calls.count()).toEqual(10);
|
100
|
+
expect(setTimeout.calls.count()).toEqual(1);
|
101
|
+
});
|
102
|
+
|
103
|
+
it("calls setTimeout when onmessage is called recursively", function() {
|
104
|
+
var fakeChannel = {
|
105
|
+
port1: {},
|
106
|
+
port2: { postMessage: function() { fakeChannel.port1.onmessage(); } }
|
107
|
+
},
|
108
|
+
setTimeout = jasmine.createSpy('setTimeout'),
|
109
|
+
global = {
|
110
|
+
MessageChannel: function() { return fakeChannel; },
|
111
|
+
setTimeout: setTimeout,
|
112
|
+
},
|
113
|
+
clearStack = jasmineUnderTest.getClearStack(global),
|
114
|
+
fn = jasmine.createSpy("second clearStack function");
|
115
|
+
|
116
|
+
clearStack(function() {
|
117
|
+
clearStack(fn);
|
118
|
+
});
|
119
|
+
|
120
|
+
expect(fn).not.toHaveBeenCalled();
|
121
|
+
expect(setTimeout).toHaveBeenCalledWith(fn, 0);
|
122
|
+
});
|
123
|
+
|
124
|
+
it("falls back to setTimeout", function() {
|
125
|
+
var setTimeout = jasmine.createSpy('setTimeout').and.callFake(function(fn) { fn() }),
|
126
|
+
global = { setTimeout: setTimeout },
|
127
|
+
clearStack = jasmineUnderTest.getClearStack(global),
|
128
|
+
called = false;
|
129
|
+
|
130
|
+
clearStack(function() {
|
131
|
+
called = true;
|
132
|
+
});
|
133
|
+
|
134
|
+
expect(called).toBe(true);
|
135
|
+
expect(setTimeout).toHaveBeenCalledWith(jasmine.any(Function), 0);
|
136
|
+
});
|
137
|
+
});
|
@@ -1,5 +1,7 @@
|
|
1
1
|
describe("Clock", function() {
|
2
2
|
|
3
|
+
var NODE_JS = typeof process !== 'undefined' && process.versions && typeof process.versions.node === 'string';
|
4
|
+
|
3
5
|
it("does not replace setTimeout until it is installed", function() {
|
4
6
|
var fakeSetTimeout = jasmine.createSpy("global setTimeout"),
|
5
7
|
fakeGlobal = { setTimeout: fakeSetTimeout },
|
@@ -294,13 +296,19 @@ describe("Clock", function() {
|
|
294
296
|
fakeGlobal = { setTimeout: fakeSetTimeout },
|
295
297
|
delayedFn = jasmine.createSpy('delayedFn'),
|
296
298
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
297
|
-
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate)
|
299
|
+
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
300
|
+
timeout = new clock.FakeTimeout();
|
298
301
|
|
299
302
|
clock.install();
|
300
303
|
clock.setTimeout(delayedFn, 0, 'a', 'b');
|
301
304
|
|
302
305
|
expect(fakeSetTimeout).not.toHaveBeenCalled();
|
303
|
-
|
306
|
+
|
307
|
+
if (!NODE_JS) {
|
308
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b']);
|
309
|
+
} else {
|
310
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b'], false, timeout);
|
311
|
+
}
|
304
312
|
});
|
305
313
|
|
306
314
|
it("returns an id for the delayed function", function() {
|
@@ -312,12 +320,16 @@ describe("Clock", function() {
|
|
312
320
|
delayedFn = jasmine.createSpy('delayedFn'),
|
313
321
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
314
322
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
315
|
-
|
323
|
+
timeout;
|
316
324
|
|
317
325
|
clock.install();
|
318
|
-
|
326
|
+
timeout = clock.setTimeout(delayedFn, 0);
|
319
327
|
|
320
|
-
|
328
|
+
if (!NODE_JS) {
|
329
|
+
expect(timeout).toEqual(123);
|
330
|
+
} else {
|
331
|
+
expect(timeout.constructor.name).toEqual('FakeTimeout');
|
332
|
+
}
|
321
333
|
});
|
322
334
|
|
323
335
|
it("clears the scheduled function with the scheduler", function() {
|
@@ -342,13 +354,19 @@ describe("Clock", function() {
|
|
342
354
|
fakeGlobal = { setInterval: fakeSetInterval },
|
343
355
|
delayedFn = jasmine.createSpy('delayedFn'),
|
344
356
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
345
|
-
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate)
|
357
|
+
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
358
|
+
timeout = new clock.FakeTimeout;
|
346
359
|
|
347
360
|
clock.install();
|
348
361
|
clock.setInterval(delayedFn, 0, 'a', 'b');
|
349
362
|
|
350
363
|
expect(fakeSetInterval).not.toHaveBeenCalled();
|
351
|
-
|
364
|
+
|
365
|
+
if (!NODE_JS) {
|
366
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b'], true);
|
367
|
+
} else {
|
368
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(delayedFn, 0, ['a', 'b'], true, timeout);
|
369
|
+
}
|
352
370
|
});
|
353
371
|
|
354
372
|
it("returns an id for the delayed function", function() {
|
@@ -360,12 +378,16 @@ describe("Clock", function() {
|
|
360
378
|
delayedFn = jasmine.createSpy('delayedFn'),
|
361
379
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
362
380
|
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
363
|
-
|
381
|
+
interval;
|
364
382
|
|
365
383
|
clock.install();
|
366
|
-
|
384
|
+
interval = clock.setInterval(delayedFn, 0);
|
367
385
|
|
368
|
-
|
386
|
+
if (!NODE_JS) {
|
387
|
+
expect(interval).toEqual(123);
|
388
|
+
} else {
|
389
|
+
expect(interval.constructor.name).toEqual('FakeTimeout');
|
390
|
+
}
|
369
391
|
});
|
370
392
|
|
371
393
|
it("clears the scheduled function with the scheduler", function() {
|
@@ -401,7 +423,8 @@ describe("Clock", function() {
|
|
401
423
|
setInterval: fakeSetInterval
|
402
424
|
},
|
403
425
|
mockDate = { install: function() {}, tick: function() {}, uninstall: function() {} },
|
404
|
-
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate)
|
426
|
+
clock = new jasmineUnderTest.Clock(fakeGlobal, function () { return delayedFunctionScheduler; }, mockDate),
|
427
|
+
timeout = new clock.FakeTimeout();
|
405
428
|
|
406
429
|
fakeSetTimeout.apply = null;
|
407
430
|
fakeSetInterval.apply = null;
|
@@ -409,13 +432,25 @@ describe("Clock", function() {
|
|
409
432
|
clock.install();
|
410
433
|
|
411
434
|
clock.setTimeout(fn, 0);
|
412
|
-
|
435
|
+
|
436
|
+
if (!NODE_JS) {
|
437
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(fn, 0, []);
|
438
|
+
} else {
|
439
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(fn, 0, [], false, timeout);
|
440
|
+
}
|
441
|
+
|
413
442
|
expect(function() {
|
414
443
|
clock.setTimeout(fn, 0, 'extra');
|
415
444
|
}).toThrow();
|
416
445
|
|
417
446
|
clock.setInterval(fn, 0);
|
418
|
-
|
447
|
+
|
448
|
+
if (!NODE_JS) {
|
449
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(fn, 0, [], true);
|
450
|
+
} else {
|
451
|
+
expect(delayedFunctionScheduler.scheduleFunction).toHaveBeenCalledWith(fn, 0, [], true, timeout);
|
452
|
+
}
|
453
|
+
|
419
454
|
expect(function() {
|
420
455
|
clock.setInterval(fn, 0, 'extra');
|
421
456
|
}).toThrow();
|
@@ -666,9 +701,54 @@ describe("Clock (acceptance)", function() {
|
|
666
701
|
var pushCurrentTime = function() { actualTimes.push(global.Date().getTime()); };
|
667
702
|
delayedFunctionScheduler.scheduleFunction(pushCurrentTime);
|
668
703
|
delayedFunctionScheduler.scheduleFunction(pushCurrentTime, 1);
|
704
|
+
delayedFunctionScheduler.scheduleFunction(pushCurrentTime, 3);
|
705
|
+
|
706
|
+
clock.tick(1);
|
707
|
+
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 1);
|
708
|
+
|
709
|
+
clock.tick(3);
|
710
|
+
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 4);
|
669
711
|
|
670
712
|
clock.tick(1);
|
713
|
+
expect(global.Date().getTime()).toEqual(baseTime.getTime() + 5);
|
671
714
|
|
672
|
-
expect(actualTimes).toEqual([baseTime.getTime(), baseTime.getTime() + 1]);
|
715
|
+
expect(actualTimes).toEqual([baseTime.getTime(), baseTime.getTime() + 1, baseTime.getTime() + 3]);
|
673
716
|
})
|
717
|
+
|
718
|
+
it('correctly clears a scheduled timeout while the Clock is advancing', function () {
|
719
|
+
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
720
|
+
global = {Date: Date, setTimeout: undefined},
|
721
|
+
mockDate = new jasmineUnderTest.MockDate(global),
|
722
|
+
clock = new jasmineUnderTest.Clock(global, function () { return delayedFunctionScheduler; }, mockDate);
|
723
|
+
|
724
|
+
clock.install();
|
725
|
+
|
726
|
+
var timerId2;
|
727
|
+
|
728
|
+
global.setTimeout(function () {
|
729
|
+
global.clearTimeout(timerId2);
|
730
|
+
}, 100);
|
731
|
+
|
732
|
+
timerId2 = global.setTimeout(fail, 100);
|
733
|
+
|
734
|
+
clock.tick(100);
|
735
|
+
});
|
736
|
+
|
737
|
+
it('correctly clears a scheduled interval while the Clock is advancing', function () {
|
738
|
+
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
739
|
+
global = {Date: Date, setTimeout: undefined},
|
740
|
+
mockDate = new jasmineUnderTest.MockDate(global),
|
741
|
+
clock = new jasmineUnderTest.Clock(global, function () { return delayedFunctionScheduler; }, mockDate);
|
742
|
+
|
743
|
+
clock.install();
|
744
|
+
|
745
|
+
var timerId2;
|
746
|
+
var timerId1 = global.setInterval(function () {
|
747
|
+
global.clearInterval(timerId2);
|
748
|
+
}, 100);
|
749
|
+
|
750
|
+
timerId2 = global.setInterval(fail, 100);
|
751
|
+
|
752
|
+
clock.tick(400);
|
753
|
+
});
|
674
754
|
});
|
@@ -216,21 +216,23 @@ describe("DelayedFunctionScheduler", function() {
|
|
216
216
|
|
217
217
|
it("removes functions during a tick that runs the function", function() {
|
218
218
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
219
|
-
|
219
|
+
spy = jasmine.createSpy('fn'),
|
220
|
+
spyAndRemove = jasmine.createSpy('fn'),
|
220
221
|
fnDelay = 10,
|
221
222
|
timeoutKey;
|
222
223
|
|
223
|
-
|
224
|
-
scheduler.scheduleFunction(function () {
|
224
|
+
spyAndRemove.and.callFake(function() {
|
225
225
|
scheduler.removeFunctionWithId(timeoutKey);
|
226
|
-
}
|
226
|
+
});
|
227
227
|
|
228
|
-
|
228
|
+
scheduler.scheduleFunction(spyAndRemove, fnDelay);
|
229
229
|
|
230
|
-
scheduler.
|
230
|
+
timeoutKey = scheduler.scheduleFunction(spy, fnDelay, [], true);
|
231
231
|
|
232
|
-
|
233
|
-
|
232
|
+
scheduler.tick(2 * fnDelay);
|
233
|
+
|
234
|
+
expect(spy).not.toHaveBeenCalled();
|
235
|
+
expect(spyAndRemove).toHaveBeenCalled();
|
234
236
|
});
|
235
237
|
|
236
238
|
it("removes functions during the first tick that runs the function", function() {
|
@@ -252,6 +254,22 @@ describe("DelayedFunctionScheduler", function() {
|
|
252
254
|
expect(fn.calls.count()).toBe(1);
|
253
255
|
});
|
254
256
|
|
257
|
+
it("does not remove a function that hasn't been added yet", function() {
|
258
|
+
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
259
|
+
fn = jasmine.createSpy('fn'),
|
260
|
+
fnDelay = 10,
|
261
|
+
timeoutKey;
|
262
|
+
|
263
|
+
scheduler.removeFunctionWithId('foo');
|
264
|
+
scheduler.scheduleFunction(fn, fnDelay, [], false, 'foo');
|
265
|
+
|
266
|
+
expect(fn).not.toHaveBeenCalled();
|
267
|
+
|
268
|
+
scheduler.tick(fnDelay + 1);
|
269
|
+
|
270
|
+
expect(fn).toHaveBeenCalled();
|
271
|
+
});
|
272
|
+
|
255
273
|
it("updates the mockDate per scheduled time", function () {
|
256
274
|
var scheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
257
275
|
tickDate = jasmine.createSpy('tickDate');
|
@@ -26,15 +26,6 @@ describe("Env", function() {
|
|
26
26
|
});
|
27
27
|
});
|
28
28
|
|
29
|
-
describe('#describe', function () {
|
30
|
-
var spec = function(done){};
|
31
|
-
it("throws the error", function() {
|
32
|
-
expect(function() {
|
33
|
-
env.describe('done method', spec);
|
34
|
-
}).toThrow(new Error('describe does not expect any arguments'));
|
35
|
-
});
|
36
|
-
});
|
37
|
-
|
38
29
|
it('can configure specs to throw errors on expectation failures', function() {
|
39
30
|
env.throwOnExpectationFailure(true);
|
40
31
|
|
@@ -55,14 +46,155 @@ describe("Env", function() {
|
|
55
46
|
}));
|
56
47
|
});
|
57
48
|
|
49
|
+
describe('#describe', function () {
|
50
|
+
it("throws an error when given arguments", function() {
|
51
|
+
expect(function() {
|
52
|
+
env.describe('done method', function(done) {});
|
53
|
+
}).toThrowError('describe does not expect any arguments');
|
54
|
+
});
|
55
|
+
|
56
|
+
it('throws an error when it receives a non-fn argument', function() {
|
57
|
+
// Some versions of PhantomJS return [object DOMWindow] when
|
58
|
+
// Object.prototype.toString.apply is called with `undefined` or `null`.
|
59
|
+
// In a similar fashion, IE8 gives [object Object] for both `undefined`
|
60
|
+
// and `null`. We mostly just want these tests to check that using
|
61
|
+
// anything other than a function throws an error.
|
62
|
+
expect(function() {
|
63
|
+
env.describe('undefined arg', undefined);
|
64
|
+
}).toThrowError(/describe expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
|
65
|
+
expect(function() {
|
66
|
+
env.describe('null arg', null);
|
67
|
+
}).toThrowError(/describe expects a function argument; received \[object (Null|DOMWindow|Object)\]/);
|
68
|
+
|
69
|
+
expect(function() {
|
70
|
+
env.describe('array arg', []);
|
71
|
+
}).toThrowError('describe expects a function argument; received [object Array]');
|
72
|
+
expect(function() {
|
73
|
+
env.describe('object arg', {});
|
74
|
+
}).toThrowError('describe expects a function argument; received [object Object]');
|
75
|
+
|
76
|
+
expect(function() {
|
77
|
+
env.describe('fn arg', function() {});
|
78
|
+
}).not.toThrowError('describe expects a function argument; received [object Function]');
|
79
|
+
});
|
80
|
+
});
|
81
|
+
|
82
|
+
describe('#it', function () {
|
83
|
+
it('throws an error when it receives a non-fn argument', function() {
|
84
|
+
expect(function() {
|
85
|
+
env.it('undefined arg', null);
|
86
|
+
}).toThrowError(/it expects a function argument; received \[object (Null|DOMWindow|Object)\]/);
|
87
|
+
});
|
88
|
+
|
89
|
+
it('does not throw when it is not given a fn argument', function() {
|
90
|
+
expect(function() {
|
91
|
+
env.it('pending spec');
|
92
|
+
}).not.toThrow();
|
93
|
+
});
|
94
|
+
|
95
|
+
it('accepts an async function', function() {
|
96
|
+
jasmine.getEnv().requireAsyncAwait();
|
97
|
+
expect(function() {
|
98
|
+
env.it('async', jasmine.getEnv().makeAsyncAwaitFunction());
|
99
|
+
}).not.toThrow();
|
100
|
+
});
|
101
|
+
});
|
102
|
+
|
58
103
|
describe('#xit', function() {
|
59
104
|
it('calls spec.pend with "Temporarily disabled with xit"', function() {
|
60
105
|
var pendSpy = jasmine.createSpy();
|
61
106
|
spyOn(env, 'it').and.returnValue({
|
62
107
|
pend: pendSpy
|
63
108
|
});
|
64
|
-
env.xit();
|
109
|
+
env.xit('foo', function() {});
|
65
110
|
expect(pendSpy).toHaveBeenCalledWith('Temporarily disabled with xit');
|
66
111
|
});
|
112
|
+
|
113
|
+
it('throws an error when it receives a non-fn argument', function() {
|
114
|
+
expect(function() {
|
115
|
+
env.xit('undefined arg', null);
|
116
|
+
}).toThrowError(/xit expects a function argument; received \[object (Null|DOMWindow|Object)\]/);
|
117
|
+
});
|
118
|
+
|
119
|
+
it('does not throw when it is not given a fn argument', function() {
|
120
|
+
expect(function() {
|
121
|
+
env.xit('pending spec');
|
122
|
+
}).not.toThrow();
|
123
|
+
});
|
124
|
+
|
125
|
+
it('accepts an async function', function() {
|
126
|
+
jasmine.getEnv().requireAsyncAwait();
|
127
|
+
expect(function() {
|
128
|
+
env.xit('async', jasmine.getEnv().makeAsyncAwaitFunction());
|
129
|
+
}).not.toThrow();
|
130
|
+
});
|
131
|
+
});
|
132
|
+
|
133
|
+
describe('#fit', function () {
|
134
|
+
it('throws an error when it receives a non-fn argument', function() {
|
135
|
+
expect(function() {
|
136
|
+
env.fit('undefined arg', undefined);
|
137
|
+
}).toThrowError(/fit expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
|
138
|
+
});
|
139
|
+
});
|
140
|
+
|
141
|
+
describe('#beforeEach', function () {
|
142
|
+
it('throws an error when it receives a non-fn argument', function() {
|
143
|
+
expect(function() {
|
144
|
+
env.beforeEach(undefined);
|
145
|
+
}).toThrowError(/beforeEach expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
|
146
|
+
});
|
147
|
+
|
148
|
+
it('accepts an async function', function() {
|
149
|
+
jasmine.getEnv().requireAsyncAwait();
|
150
|
+
expect(function() {
|
151
|
+
env.beforeEach(jasmine.getEnv().makeAsyncAwaitFunction());
|
152
|
+
}).not.toThrow();
|
153
|
+
});
|
154
|
+
});
|
155
|
+
|
156
|
+
describe('#beforeAll', function () {
|
157
|
+
it('throws an error when it receives a non-fn argument', function() {
|
158
|
+
expect(function() {
|
159
|
+
env.beforeAll(undefined);
|
160
|
+
}).toThrowError(/beforeAll expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
|
161
|
+
});
|
162
|
+
|
163
|
+
it('accepts an async function', function() {
|
164
|
+
jasmine.getEnv().requireAsyncAwait();
|
165
|
+
expect(function() {
|
166
|
+
env.beforeAll(jasmine.getEnv().makeAsyncAwaitFunction());
|
167
|
+
}).not.toThrow();
|
168
|
+
});
|
169
|
+
});
|
170
|
+
|
171
|
+
describe('#afterEach', function () {
|
172
|
+
it('throws an error when it receives a non-fn argument', function() {
|
173
|
+
expect(function() {
|
174
|
+
env.afterEach(undefined);
|
175
|
+
}).toThrowError(/afterEach expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
|
176
|
+
});
|
177
|
+
|
178
|
+
it('accepts an async function', function() {
|
179
|
+
jasmine.getEnv().requireAsyncAwait();
|
180
|
+
expect(function() {
|
181
|
+
env.afterEach(jasmine.getEnv().makeAsyncAwaitFunction());
|
182
|
+
}).not.toThrow();
|
183
|
+
});
|
184
|
+
});
|
185
|
+
|
186
|
+
describe('#afterAll', function () {
|
187
|
+
it('throws an error when it receives a non-fn argument', function() {
|
188
|
+
expect(function() {
|
189
|
+
env.afterAll(undefined);
|
190
|
+
}).toThrowError(/afterAll expects a function argument; received \[object (Undefined|DOMWindow|Object)\]/);
|
191
|
+
});
|
192
|
+
|
193
|
+
it('accepts an async function', function() {
|
194
|
+
jasmine.getEnv().requireAsyncAwait();
|
195
|
+
expect(function() {
|
196
|
+
env.afterAll(jasmine.getEnv().makeAsyncAwaitFunction());
|
197
|
+
}).not.toThrow();
|
198
|
+
});
|
67
199
|
});
|
68
200
|
});
|
@@ -113,6 +113,7 @@ describe("Expectation", function() {
|
|
113
113
|
matcherName: "toFoo",
|
114
114
|
passed: true,
|
115
115
|
message: "",
|
116
|
+
error: undefined,
|
116
117
|
expected: "hello",
|
117
118
|
actual: "an actual"
|
118
119
|
});
|
@@ -146,7 +147,8 @@ describe("Expectation", function() {
|
|
146
147
|
passed: false,
|
147
148
|
expected: "hello",
|
148
149
|
actual: "an actual",
|
149
|
-
message: ""
|
150
|
+
message: "",
|
151
|
+
error: undefined
|
150
152
|
});
|
151
153
|
});
|
152
154
|
|
@@ -179,7 +181,8 @@ describe("Expectation", function() {
|
|
179
181
|
passed: false,
|
180
182
|
expected: "hello",
|
181
183
|
actual: "an actual",
|
182
|
-
message: "I am a custom message"
|
184
|
+
message: "I am a custom message",
|
185
|
+
error: undefined
|
183
186
|
});
|
184
187
|
});
|
185
188
|
|
@@ -212,7 +215,8 @@ describe("Expectation", function() {
|
|
212
215
|
passed: false,
|
213
216
|
expected: "hello",
|
214
217
|
actual: "an actual",
|
215
|
-
message: "I am a custom message"
|
218
|
+
message: "I am a custom message",
|
219
|
+
error: undefined
|
216
220
|
});
|
217
221
|
});
|
218
222
|
|
@@ -244,6 +248,7 @@ describe("Expectation", function() {
|
|
244
248
|
matcherName: "toFoo",
|
245
249
|
passed: true,
|
246
250
|
message: "",
|
251
|
+
error: undefined,
|
247
252
|
expected: "hello",
|
248
253
|
actual: actual
|
249
254
|
});
|
@@ -279,7 +284,8 @@ describe("Expectation", function() {
|
|
279
284
|
passed: false,
|
280
285
|
expected: "hello",
|
281
286
|
actual: actual,
|
282
|
-
message: "default message"
|
287
|
+
message: "default message",
|
288
|
+
error: undefined
|
283
289
|
});
|
284
290
|
});
|
285
291
|
|
@@ -314,7 +320,8 @@ describe("Expectation", function() {
|
|
314
320
|
passed: false,
|
315
321
|
expected: "hello",
|
316
322
|
actual: actual,
|
317
|
-
message: "I am a custom message"
|
323
|
+
message: "I am a custom message",
|
324
|
+
error: undefined
|
318
325
|
});
|
319
326
|
});
|
320
327
|
|
@@ -345,7 +352,8 @@ describe("Expectation", function() {
|
|
345
352
|
passed: true,
|
346
353
|
expected: "hello",
|
347
354
|
actual: actual,
|
348
|
-
message: ""
|
355
|
+
message: "",
|
356
|
+
error: undefined
|
349
357
|
});
|
350
358
|
});
|
351
359
|
|
@@ -381,7 +389,44 @@ describe("Expectation", function() {
|
|
381
389
|
passed: false,
|
382
390
|
expected: "hello",
|
383
391
|
actual: actual,
|
384
|
-
message: "I'm a custom message"
|
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
|
385
430
|
});
|
386
431
|
});
|
387
432
|
|