add prettier and eslint
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
getJasmineRequireObj().Clock = function() {
|
||||
|
||||
/* global process */
|
||||
var NODE_JS = typeof process !== 'undefined' && process.versions && typeof process.versions.node === 'string';
|
||||
var NODE_JS =
|
||||
typeof process !== 'undefined' &&
|
||||
process.versions &&
|
||||
typeof process.versions.node === 'string';
|
||||
|
||||
/**
|
||||
* _Note:_ Do not construct this directly, Jasmine will make one during booting. You can get the current clock with {@link jasmine.clock}.
|
||||
@@ -35,8 +37,10 @@ getJasmineRequireObj().Clock = function() {
|
||||
* @return {Clock}
|
||||
*/
|
||||
self.install = function() {
|
||||
if(!originalTimingFunctionsIntact()) {
|
||||
throw new Error('Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?');
|
||||
if (!originalTimingFunctionsIntact()) {
|
||||
throw new Error(
|
||||
'Jasmine Clock was unable to install over custom global timer functions. Is the clock already installed?'
|
||||
);
|
||||
}
|
||||
replace(global, fakeTimingFunctions);
|
||||
timer = fakeTimingFunctions;
|
||||
@@ -88,11 +92,17 @@ getJasmineRequireObj().Clock = function() {
|
||||
};
|
||||
|
||||
self.setTimeout = function(fn, delay, params) {
|
||||
return Function.prototype.apply.apply(timer.setTimeout, [global, arguments]);
|
||||
return Function.prototype.apply.apply(timer.setTimeout, [
|
||||
global,
|
||||
arguments
|
||||
]);
|
||||
};
|
||||
|
||||
self.setInterval = function(fn, delay, params) {
|
||||
return Function.prototype.apply.apply(timer.setInterval, [global, arguments]);
|
||||
return Function.prototype.apply.apply(timer.setInterval, [
|
||||
global,
|
||||
arguments
|
||||
]);
|
||||
};
|
||||
|
||||
self.clearTimeout = function(id) {
|
||||
@@ -111,19 +121,25 @@ getJasmineRequireObj().Clock = function() {
|
||||
*/
|
||||
self.tick = function(millis) {
|
||||
if (installed) {
|
||||
delayedFunctionScheduler.tick(millis, function(millis) { mockDate.tick(millis); });
|
||||
delayedFunctionScheduler.tick(millis, function(millis) {
|
||||
mockDate.tick(millis);
|
||||
});
|
||||
} else {
|
||||
throw new Error('Mock clock is not installed, use jasmine.clock().install()');
|
||||
throw new Error(
|
||||
'Mock clock is not installed, use jasmine.clock().install()'
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
return self;
|
||||
|
||||
function originalTimingFunctionsIntact() {
|
||||
return global.setTimeout === realTimingFunctions.setTimeout &&
|
||||
return (
|
||||
global.setTimeout === realTimingFunctions.setTimeout &&
|
||||
global.clearTimeout === realTimingFunctions.clearTimeout &&
|
||||
global.setInterval === realTimingFunctions.setInterval &&
|
||||
global.clearInterval === realTimingFunctions.clearInterval;
|
||||
global.clearInterval === realTimingFunctions.clearInterval
|
||||
);
|
||||
}
|
||||
|
||||
function replace(dest, source) {
|
||||
@@ -134,12 +150,22 @@ getJasmineRequireObj().Clock = function() {
|
||||
|
||||
function setTimeout(fn, delay) {
|
||||
if (!NODE_JS) {
|
||||
return delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2));
|
||||
return delayedFunctionScheduler.scheduleFunction(
|
||||
fn,
|
||||
delay,
|
||||
argSlice(arguments, 2)
|
||||
);
|
||||
}
|
||||
|
||||
var timeout = new FakeTimeout();
|
||||
|
||||
delayedFunctionScheduler.scheduleFunction(fn, delay, argSlice(arguments, 2), false, timeout);
|
||||
delayedFunctionScheduler.scheduleFunction(
|
||||
fn,
|
||||
delay,
|
||||
argSlice(arguments, 2),
|
||||
false,
|
||||
timeout
|
||||
);
|
||||
|
||||
return timeout;
|
||||
}
|
||||
@@ -150,12 +176,23 @@ getJasmineRequireObj().Clock = function() {
|
||||
|
||||
function setInterval(fn, interval) {
|
||||
if (!NODE_JS) {
|
||||
return delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true);
|
||||
return delayedFunctionScheduler.scheduleFunction(
|
||||
fn,
|
||||
interval,
|
||||
argSlice(arguments, 2),
|
||||
true
|
||||
);
|
||||
}
|
||||
|
||||
var timeout = new FakeTimeout();
|
||||
|
||||
delayedFunctionScheduler.scheduleFunction(fn, interval, argSlice(arguments, 2), true, timeout);
|
||||
delayedFunctionScheduler.scheduleFunction(
|
||||
fn,
|
||||
interval,
|
||||
argSlice(arguments, 2),
|
||||
true,
|
||||
timeout
|
||||
);
|
||||
|
||||
return timeout;
|
||||
}
|
||||
@@ -174,11 +211,11 @@ getJasmineRequireObj().Clock = function() {
|
||||
*/
|
||||
function FakeTimeout() {}
|
||||
|
||||
FakeTimeout.prototype.ref = function () {
|
||||
FakeTimeout.prototype.ref = function() {
|
||||
return this;
|
||||
};
|
||||
|
||||
FakeTimeout.prototype.unref = function () {
|
||||
FakeTimeout.prototype.unref = function() {
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user