jasmine-core 2.0.0.rc5 → 2.0.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 +7 -0
- data/lib/console/console.js +4 -4
- data/lib/jasmine-core/example/spec/SpecHelper.js +11 -11
- data/lib/jasmine-core/jasmine.js +104 -69
- data/lib/jasmine-core/spec/console/ConsoleReporterSpec.js +3 -3
- data/lib/jasmine-core/spec/core/ClockSpec.js +15 -0
- data/lib/jasmine-core/spec/core/DelayedFunctionSchedulerSpec.js +67 -0
- data/lib/jasmine-core/spec/core/EnvSpec.js +2 -481
- data/lib/jasmine-core/spec/core/ExceptionsSpec.js +17 -7
- data/lib/jasmine-core/spec/core/ExpectationResultSpec.js +1 -1
- data/lib/jasmine-core/spec/core/ExpectationSpec.js +3 -3
- data/lib/jasmine-core/spec/core/SpecSpec.js +97 -15
- data/lib/jasmine-core/spec/core/SpySpec.js +20 -1
- data/lib/jasmine-core/spec/core/{CustomMatchersSpec.js → integration/CustomMatchersSpec.js} +0 -0
- data/lib/jasmine-core/spec/core/integration/EnvSpec.js +488 -0
- data/lib/jasmine-core/spec/core/{SpecRunningSpec.js → integration/SpecRunningSpec.js} +0 -1
- data/lib/jasmine-core/spec/core/matchers/matchersUtilSpec.js +1 -1
- data/lib/jasmine-core/spec/core/matchers/toThrowErrorSpec.js +1 -1
- data/lib/jasmine-core/version.rb +1 -1
- metadata +19 -31
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 64fc08a60b942909e10f43cd7568374e95e0ccda
|
|
4
|
+
data.tar.gz: f6cc9a58eeb24163496fb22903321b73d97cd3fd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 24d62c7f7aea8cc8b640f562a77ba219d25b203e587df68b2b29245d22e98e0475ca27fbf2f994f031b89b35b4c8e08c1ba402f1dc8eb81281c90ee27a909daf
|
|
7
|
+
data.tar.gz: d2ee9eacc009ce20f427baf2a13d61b69abb814d1a40788986d393322ccad3347d2f00b57c5c2feb57ccb88231fa6d5e49049aa8c99c1268566a798ddb9aa60a
|
data/lib/console/console.js
CHANGED
|
@@ -50,10 +50,10 @@ getJasmineRequireObj().ConsoleReporter = function() {
|
|
|
50
50
|
failedSpecs = [],
|
|
51
51
|
pendingCount,
|
|
52
52
|
ansi = {
|
|
53
|
-
green: '\
|
|
54
|
-
red: '\
|
|
55
|
-
yellow: '\
|
|
56
|
-
none: '\
|
|
53
|
+
green: '\x1B[32m',
|
|
54
|
+
red: '\x1B[31m',
|
|
55
|
+
yellow: '\x1B[33m',
|
|
56
|
+
none: '\x1B[0m'
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
this.jasmineStarted = function() {
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
beforeEach(function () {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
jasmine.addMatchers({
|
|
3
|
+
toBePlaying: function () {
|
|
4
|
+
return {
|
|
5
|
+
compare: function (actual, expected) {
|
|
6
|
+
var player = actual;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
};
|
|
8
|
+
return {
|
|
9
|
+
pass: player.currentlyPlayingSong === expected && player.isPlaying
|
|
10
|
+
}
|
|
13
11
|
}
|
|
14
|
-
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
15
|
});
|
data/lib/jasmine-core/jasmine.js
CHANGED
|
@@ -97,13 +97,12 @@ getJasmineRequireObj().base = function(j$) {
|
|
|
97
97
|
j$.MAX_PRETTY_PRINT_DEPTH = 40;
|
|
98
98
|
j$.DEFAULT_TIMEOUT_INTERVAL = 5000;
|
|
99
99
|
|
|
100
|
-
j$.getGlobal = function() {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
};
|
|
100
|
+
j$.getGlobal = (function() {
|
|
101
|
+
var jasmineGlobal = eval.call(null, "this");
|
|
102
|
+
return function() {
|
|
103
|
+
return jasmineGlobal;
|
|
104
|
+
};
|
|
105
|
+
})();
|
|
107
106
|
|
|
108
107
|
j$.getEnv = function(options) {
|
|
109
108
|
var env = j$.currentEnv_ = j$.currentEnv_ || new j$.Env(options);
|
|
@@ -231,14 +230,13 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
231
230
|
this.id = attrs.id;
|
|
232
231
|
this.description = attrs.description || '';
|
|
233
232
|
this.fn = attrs.fn;
|
|
234
|
-
this.beforeFns = attrs.beforeFns || function() {};
|
|
235
|
-
this.afterFns = attrs.afterFns || function() {};
|
|
236
|
-
this.catchingExceptions = attrs.catchingExceptions;
|
|
233
|
+
this.beforeFns = attrs.beforeFns || function() { return []; };
|
|
234
|
+
this.afterFns = attrs.afterFns || function() { return []; };
|
|
237
235
|
this.onStart = attrs.onStart || function() {};
|
|
238
236
|
this.exceptionFormatter = attrs.exceptionFormatter || function() {};
|
|
239
237
|
this.getSpecName = attrs.getSpecName || function() { return ''; };
|
|
240
238
|
this.expectationResultFactory = attrs.expectationResultFactory || function() { };
|
|
241
|
-
this.
|
|
239
|
+
this.queueRunnerFactory = attrs.queueRunnerFactory || function() {};
|
|
242
240
|
this.catchingExceptions = attrs.catchingExceptions || function() { return true; };
|
|
243
241
|
|
|
244
242
|
this.timer = attrs.timer || {setTimeout: setTimeout, clearTimeout: clearTimeout};
|
|
@@ -267,7 +265,8 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
267
265
|
};
|
|
268
266
|
|
|
269
267
|
Spec.prototype.execute = function(onComplete) {
|
|
270
|
-
var self = this
|
|
268
|
+
var self = this,
|
|
269
|
+
timeout;
|
|
271
270
|
|
|
272
271
|
this.onStart(this);
|
|
273
272
|
|
|
@@ -278,13 +277,13 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
278
277
|
|
|
279
278
|
function timeoutable(fn) {
|
|
280
279
|
return function(done) {
|
|
281
|
-
|
|
280
|
+
timeout = Function.prototype.apply.apply(self.timer.setTimeout, [j$.getGlobal(), [function() {
|
|
282
281
|
onException(new Error('Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.'));
|
|
283
282
|
done();
|
|
284
283
|
}, j$.DEFAULT_TIMEOUT_INTERVAL]]);
|
|
285
284
|
|
|
286
285
|
var callDone = function() {
|
|
287
|
-
|
|
286
|
+
clearTimeoutable();
|
|
288
287
|
done();
|
|
289
288
|
};
|
|
290
289
|
|
|
@@ -292,18 +291,26 @@ getJasmineRequireObj().Spec = function(j$) {
|
|
|
292
291
|
};
|
|
293
292
|
}
|
|
294
293
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
294
|
+
function clearTimeoutable() {
|
|
295
|
+
Function.prototype.apply.apply(self.timer.clearTimeout, [j$.getGlobal(), [timeout]]);
|
|
296
|
+
timeout = void 0;
|
|
297
|
+
}
|
|
299
298
|
|
|
300
|
-
this.
|
|
301
|
-
|
|
299
|
+
var allFns = this.beforeFns().concat(this.fn).concat(this.afterFns()),
|
|
300
|
+
allTimeoutableFns = [];
|
|
301
|
+
for (var i = 0; i < allFns.length; i++) {
|
|
302
|
+
var fn = allFns[i];
|
|
303
|
+
allTimeoutableFns.push(fn.length > 0 ? timeoutable(fn) : fn);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
this.queueRunnerFactory({
|
|
307
|
+
fns: allTimeoutableFns,
|
|
302
308
|
onException: onException,
|
|
303
309
|
onComplete: complete
|
|
304
310
|
});
|
|
305
311
|
|
|
306
312
|
function onException(e) {
|
|
313
|
+
clearTimeoutable();
|
|
307
314
|
if (Spec.isPendingSpecException(e)) {
|
|
308
315
|
self.pend();
|
|
309
316
|
return;
|
|
@@ -641,7 +648,7 @@ getJasmineRequireObj().Env = function(j$) {
|
|
|
641
648
|
onStart: specStarted,
|
|
642
649
|
description: description,
|
|
643
650
|
expectationResultFactory: expectationResultFactory,
|
|
644
|
-
|
|
651
|
+
queueRunnerFactory: queueRunnerFactory,
|
|
645
652
|
fn: fn,
|
|
646
653
|
timer: {setTimeout: realSetTimeout, clearTimeout: realClearTimeout}
|
|
647
654
|
});
|
|
@@ -976,14 +983,17 @@ getJasmineRequireObj().Clock = function() {
|
|
|
976
983
|
getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|
977
984
|
function DelayedFunctionScheduler() {
|
|
978
985
|
var self = this;
|
|
986
|
+
var scheduledLookup = [];
|
|
979
987
|
var scheduledFunctions = {};
|
|
980
988
|
var currentTime = 0;
|
|
981
989
|
var delayedFnCount = 0;
|
|
982
990
|
|
|
983
991
|
self.tick = function(millis) {
|
|
984
992
|
millis = millis || 0;
|
|
985
|
-
|
|
986
|
-
|
|
993
|
+
var endTime = currentTime + millis;
|
|
994
|
+
|
|
995
|
+
runScheduledFunctions(endTime);
|
|
996
|
+
currentTime = endTime;
|
|
987
997
|
};
|
|
988
998
|
|
|
989
999
|
self.scheduleFunction = function(funcToCall, millis, params, recurring, timeoutKey, runAtMillis) {
|
|
@@ -999,7 +1009,8 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|
|
999
1009
|
millis = millis || 0;
|
|
1000
1010
|
timeoutKey = timeoutKey || ++delayedFnCount;
|
|
1001
1011
|
runAtMillis = runAtMillis || (currentTime + millis);
|
|
1002
|
-
|
|
1012
|
+
|
|
1013
|
+
var funcToSchedule = {
|
|
1003
1014
|
runAtMillis: runAtMillis,
|
|
1004
1015
|
funcToCall: f,
|
|
1005
1016
|
recurring: recurring,
|
|
@@ -1007,58 +1018,73 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|
|
1007
1018
|
timeoutKey: timeoutKey,
|
|
1008
1019
|
millis: millis
|
|
1009
1020
|
};
|
|
1021
|
+
|
|
1022
|
+
if (runAtMillis in scheduledFunctions) {
|
|
1023
|
+
scheduledFunctions[runAtMillis].push(funcToSchedule);
|
|
1024
|
+
} else {
|
|
1025
|
+
scheduledFunctions[runAtMillis] = [funcToSchedule];
|
|
1026
|
+
scheduledLookup.push(runAtMillis);
|
|
1027
|
+
scheduledLookup.sort(function (a, b) {
|
|
1028
|
+
return a - b;
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1010
1032
|
return timeoutKey;
|
|
1011
1033
|
};
|
|
1012
1034
|
|
|
1013
1035
|
self.removeFunctionWithId = function(timeoutKey) {
|
|
1014
|
-
|
|
1036
|
+
for (var runAtMillis in scheduledFunctions) {
|
|
1037
|
+
var funcs = scheduledFunctions[runAtMillis];
|
|
1038
|
+
var i = indexOfFirstToPass(funcs, function (func) {
|
|
1039
|
+
return func.timeoutKey === timeoutKey;
|
|
1040
|
+
});
|
|
1041
|
+
|
|
1042
|
+
if (i > -1) {
|
|
1043
|
+
if (funcs.length === 1) {
|
|
1044
|
+
delete scheduledFunctions[runAtMillis];
|
|
1045
|
+
deleteFromLookup(runAtMillis);
|
|
1046
|
+
} else {
|
|
1047
|
+
funcs.splice(i, 1);
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
// intervals get rescheduled when executed, so there's never more
|
|
1051
|
+
// than a single scheduled function with a given timeoutKey
|
|
1052
|
+
break;
|
|
1053
|
+
}
|
|
1054
|
+
}
|
|
1015
1055
|
};
|
|
1016
1056
|
|
|
1017
1057
|
self.reset = function() {
|
|
1018
1058
|
currentTime = 0;
|
|
1059
|
+
scheduledLookup = [];
|
|
1019
1060
|
scheduledFunctions = {};
|
|
1020
1061
|
delayedFnCount = 0;
|
|
1021
1062
|
};
|
|
1022
1063
|
|
|
1023
1064
|
return self;
|
|
1024
1065
|
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
for (var
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
scheduledFunc.runAtMillis <= endMillis) {
|
|
1033
|
-
|
|
1034
|
-
// remove fn -- we'll reschedule later if it is recurring.
|
|
1035
|
-
self.removeFunctionWithId(timeoutKey);
|
|
1036
|
-
if (!scheduledFunc.recurring) {
|
|
1037
|
-
fnsToRun.push(scheduledFunc); // schedules each function only once
|
|
1038
|
-
} else {
|
|
1039
|
-
fnsToRun.push(buildNthInstanceOf(scheduledFunc, 0));
|
|
1040
|
-
var additionalTimesFnRunsInRange =
|
|
1041
|
-
Math.floor((endMillis - scheduledFunc.runAtMillis) / scheduledFunc.millis);
|
|
1042
|
-
for (var i = 0; i < additionalTimesFnRunsInRange; i++) {
|
|
1043
|
-
fnsToRun.push(buildNthInstanceOf(scheduledFunc, i + 1));
|
|
1044
|
-
}
|
|
1045
|
-
reschedule(buildNthInstanceOf(scheduledFunc, additionalTimesFnRunsInRange));
|
|
1046
|
-
}
|
|
1066
|
+
function indexOfFirstToPass(array, testFn) {
|
|
1067
|
+
var index = -1;
|
|
1068
|
+
|
|
1069
|
+
for (var i = 0; i < array.length; ++i) {
|
|
1070
|
+
if (testFn(array[i])) {
|
|
1071
|
+
index = i;
|
|
1072
|
+
break;
|
|
1047
1073
|
}
|
|
1048
1074
|
}
|
|
1049
1075
|
|
|
1050
|
-
return
|
|
1076
|
+
return index;
|
|
1051
1077
|
}
|
|
1052
1078
|
|
|
1053
|
-
function
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
}
|
|
1079
|
+
function deleteFromLookup(key) {
|
|
1080
|
+
var value = Number(key);
|
|
1081
|
+
var i = indexOfFirstToPass(scheduledLookup, function (millis) {
|
|
1082
|
+
return millis === value;
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1085
|
+
if (i > -1) {
|
|
1086
|
+
scheduledLookup.splice(i, 1);
|
|
1087
|
+
}
|
|
1062
1088
|
}
|
|
1063
1089
|
|
|
1064
1090
|
function reschedule(scheduledFn) {
|
|
@@ -1070,21 +1096,30 @@ getJasmineRequireObj().DelayedFunctionScheduler = function() {
|
|
|
1070
1096
|
scheduledFn.runAtMillis + scheduledFn.millis);
|
|
1071
1097
|
}
|
|
1072
1098
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
var funcsToRun = functionsWithinRange(startMillis, endMillis);
|
|
1076
|
-
if (funcsToRun.length === 0) {
|
|
1099
|
+
function runScheduledFunctions(endTime) {
|
|
1100
|
+
if (scheduledLookup.length === 0 || scheduledLookup[0] > endTime) {
|
|
1077
1101
|
return;
|
|
1078
1102
|
}
|
|
1079
1103
|
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
});
|
|
1104
|
+
do {
|
|
1105
|
+
currentTime = scheduledLookup.shift();
|
|
1083
1106
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1107
|
+
var funcsToRun = scheduledFunctions[currentTime];
|
|
1108
|
+
delete scheduledFunctions[currentTime];
|
|
1109
|
+
|
|
1110
|
+
for (var i = 0; i < funcsToRun.length; ++i) {
|
|
1111
|
+
var funcToRun = funcsToRun[i];
|
|
1112
|
+
funcToRun.funcToCall.apply(null, funcToRun.params || []);
|
|
1113
|
+
|
|
1114
|
+
if (funcToRun.recurring) {
|
|
1115
|
+
reschedule(funcToRun);
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
} while (scheduledLookup.length > 0 &&
|
|
1119
|
+
// checking first if we're out of time prevents setTimeout(0)
|
|
1120
|
+
// scheduled in a funcToRun from forcing an extra iteration
|
|
1121
|
+
currentTime !== endTime &&
|
|
1122
|
+
scheduledLookup[0] <= endTime);
|
|
1088
1123
|
}
|
|
1089
1124
|
}
|
|
1090
1125
|
|
|
@@ -2363,5 +2398,5 @@ getJasmineRequireObj().toThrowError = function(j$) {
|
|
|
2363
2398
|
};
|
|
2364
2399
|
|
|
2365
2400
|
getJasmineRequireObj().version = function() {
|
|
2366
|
-
return "2.0.0
|
|
2401
|
+
return "2.0.0";
|
|
2367
2402
|
};
|
|
@@ -80,7 +80,7 @@ describe("ConsoleReporter", function() {
|
|
|
80
80
|
expect(out.getOutput()).toEqual("*");
|
|
81
81
|
});
|
|
82
82
|
|
|
83
|
-
it("reports a summary when done (
|
|
83
|
+
it("reports a summary when done (singular spec and time)", function() {
|
|
84
84
|
var timerSpy = jasmine.createSpyObj('timer', ['start', 'elapsed']),
|
|
85
85
|
reporter = new j$.ConsoleReporter({
|
|
86
86
|
print: out.print,
|
|
@@ -198,7 +198,7 @@ describe("ConsoleReporter", function() {
|
|
|
198
198
|
|
|
199
199
|
reporter.specDone({status: "passed"});
|
|
200
200
|
|
|
201
|
-
expect(out.getOutput()).toEqual("\
|
|
201
|
+
expect(out.getOutput()).toEqual("\x1B[32m.\x1B[0m");
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
it("does not report a disabled spec", function() {
|
|
@@ -220,7 +220,7 @@ describe("ConsoleReporter", function() {
|
|
|
220
220
|
|
|
221
221
|
reporter.specDone({status: 'failed'});
|
|
222
222
|
|
|
223
|
-
expect(out.getOutput()).toEqual("\
|
|
223
|
+
expect(out.getOutput()).toEqual("\x1B[31mF\x1B[0m");
|
|
224
224
|
});
|
|
225
225
|
});
|
|
226
226
|
});
|
|
@@ -341,4 +341,19 @@ describe("Clock (acceptance)", function() {
|
|
|
341
341
|
clock.tick();
|
|
342
342
|
expect(delayedFn2).toHaveBeenCalled();
|
|
343
343
|
});
|
|
344
|
+
|
|
345
|
+
it("correctly calls functions scheduled while the Clock is advancing", function() {
|
|
346
|
+
var delayedFn1 = jasmine.createSpy('delayedFn1'),
|
|
347
|
+
delayedFn2 = jasmine.createSpy('delayedFn2'),
|
|
348
|
+
delayedFunctionScheduler = new j$.DelayedFunctionScheduler(),
|
|
349
|
+
clock = new j$.Clock({setTimeout: function() {}}, delayedFunctionScheduler);
|
|
350
|
+
|
|
351
|
+
delayedFn1.and.callFake(function() { clock.setTimeout(delayedFn2, 1); });
|
|
352
|
+
clock.install();
|
|
353
|
+
clock.setTimeout(delayedFn1, 5);
|
|
354
|
+
|
|
355
|
+
clock.tick(6);
|
|
356
|
+
expect(delayedFn1).toHaveBeenCalled();
|
|
357
|
+
expect(delayedFn2).toHaveBeenCalled();
|
|
358
|
+
});
|
|
344
359
|
});
|
|
@@ -175,5 +175,72 @@ describe("DelayedFunctionScheduler", function() {
|
|
|
175
175
|
expect(fn).toHaveBeenCalled();
|
|
176
176
|
});
|
|
177
177
|
|
|
178
|
+
it("schedules a function for later execution during a tick", function () {
|
|
179
|
+
var scheduler = new j$.DelayedFunctionScheduler(),
|
|
180
|
+
fn = jasmine.createSpy('fn'),
|
|
181
|
+
fnDelay = 10;
|
|
182
|
+
|
|
183
|
+
scheduler.scheduleFunction(function () {
|
|
184
|
+
scheduler.scheduleFunction(fn, fnDelay);
|
|
185
|
+
}, 0);
|
|
186
|
+
|
|
187
|
+
expect(fn).not.toHaveBeenCalled();
|
|
188
|
+
|
|
189
|
+
scheduler.tick(fnDelay);
|
|
190
|
+
|
|
191
|
+
expect(fn).toHaveBeenCalled();
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it("#removeFunctionWithId removes a previously scheduled function with a given id during a tick", function () {
|
|
195
|
+
var scheduler = new j$.DelayedFunctionScheduler(),
|
|
196
|
+
fn = jasmine.createSpy('fn'),
|
|
197
|
+
fnDelay = 10,
|
|
198
|
+
timeoutKey;
|
|
199
|
+
|
|
200
|
+
scheduler.scheduleFunction(function () {
|
|
201
|
+
scheduler.removeFunctionWithId(timeoutKey);
|
|
202
|
+
}, 0);
|
|
203
|
+
timeoutKey = scheduler.scheduleFunction(fn, fnDelay);
|
|
204
|
+
|
|
205
|
+
expect(fn).not.toHaveBeenCalled();
|
|
206
|
+
|
|
207
|
+
scheduler.tick(fnDelay);
|
|
208
|
+
|
|
209
|
+
expect(fn).not.toHaveBeenCalled();
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("executes recurring functions interleaved with regular functions and functions scheduled during a tick in the correct order", function () {
|
|
213
|
+
var scheduler = new j$.DelayedFunctionScheduler(),
|
|
214
|
+
fn = jasmine.createSpy('fn'),
|
|
215
|
+
recurringCallCount = 0,
|
|
216
|
+
recurring = jasmine.createSpy('recurring').and.callFake(function() {
|
|
217
|
+
recurringCallCount++;
|
|
218
|
+
if (recurringCallCount < 5) {
|
|
219
|
+
expect(fn).not.toHaveBeenCalled();
|
|
220
|
+
}
|
|
221
|
+
}),
|
|
222
|
+
innerFn = jasmine.createSpy('innerFn').and.callFake(function() {
|
|
223
|
+
expect(recurring.calls.count()).toBe(4);
|
|
224
|
+
expect(fn).not.toHaveBeenCalled();
|
|
225
|
+
}),
|
|
226
|
+
scheduling = jasmine.createSpy('scheduling').and.callFake(function() {
|
|
227
|
+
expect(recurring.calls.count()).toBe(3);
|
|
228
|
+
expect(fn).not.toHaveBeenCalled();
|
|
229
|
+
scheduler.scheduleFunction(innerFn, 10); // 41ms absolute
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
scheduler.scheduleFunction(recurring, 10, [], true);
|
|
233
|
+
scheduler.scheduleFunction(fn, 50);
|
|
234
|
+
scheduler.scheduleFunction(scheduling, 31);
|
|
235
|
+
|
|
236
|
+
scheduler.tick(60);
|
|
237
|
+
|
|
238
|
+
expect(recurring).toHaveBeenCalled();
|
|
239
|
+
expect(recurring.calls.count()).toBe(6);
|
|
240
|
+
expect(fn).toHaveBeenCalled();
|
|
241
|
+
expect(scheduling).toHaveBeenCalled();
|
|
242
|
+
expect(innerFn).toHaveBeenCalled();
|
|
243
|
+
});
|
|
244
|
+
|
|
178
245
|
});
|
|
179
246
|
|