Deprecate non-Date arguments to jasmine.clock().mockDate()

This commit is contained in:
Steve Gravrock
2021-09-23 16:04:39 -07:00
parent 497a7fc3e5
commit 64d58ed1f0
4 changed files with 42 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
getJasmineRequireObj().MockDate = function() {
getJasmineRequireObj().MockDate = function(j$) {
function MockDate(global) {
var self = this;
var currentTime = 0;
@@ -16,6 +16,14 @@ getJasmineRequireObj().MockDate = function() {
if (mockDate instanceof GlobalDate) {
currentTime = mockDate.getTime();
} else {
if (!j$.util.isUndefined(mockDate)) {
j$.getEnv().deprecated(
'The argument to jasmine.clock().mockDate(), if specified, ' +
'should be a Date instance. Passing anything other than a Date ' +
'will be treated as an error in a future release.'
);
}
currentTime = new GlobalDate().getTime();
}

View File

@@ -38,7 +38,7 @@ var getJasmineRequireObj = (function(jasmineGlobal) {
j$.Any = jRequire.Any(j$);
j$.Anything = jRequire.Anything(j$);
j$.CallTracker = jRequire.CallTracker(j$);
j$.MockDate = jRequire.MockDate();
j$.MockDate = jRequire.MockDate(j$);
j$.getClearStack = jRequire.clearStack(j$);
j$.Clock = jRequire.Clock();
j$.DelayedFunctionScheduler = jRequire.DelayedFunctionScheduler(j$);