Throw if the argument to jasmine.clock().mockDate() is not a Date
This commit is contained in:
@@ -7054,10 +7054,9 @@ getJasmineRequireObj().MockDate = function(j$) {
|
|||||||
currentTime = mockDate.getTime();
|
currentTime = mockDate.getTime();
|
||||||
} else {
|
} else {
|
||||||
if (!j$.util.isUndefined(mockDate)) {
|
if (!j$.util.isUndefined(mockDate)) {
|
||||||
j$.getEnv().deprecated(
|
throw new Error(
|
||||||
'The argument to jasmine.clock().mockDate(), if specified, ' +
|
'The argument to jasmine.clock().mockDate(), if specified, ' +
|
||||||
'should be a Date instance. Passing anything other than a Date ' +
|
'should be a Date instance.'
|
||||||
'will be treated as an error in a future release.'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -950,7 +950,7 @@ describe('Clock (acceptance)', function() {
|
|||||||
expect(timeoutDate).toEqual(baseTime.getTime() + 150);
|
expect(timeoutDate).toEqual(baseTime.getTime() + 150);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('logs a deprecation when mockDate is called with a non-Date', function() {
|
it('throws mockDate is called with a non-Date', function() {
|
||||||
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
var delayedFunctionScheduler = new jasmineUnderTest.DelayedFunctionScheduler(),
|
||||||
global = { Date: Date },
|
global = { Date: Date },
|
||||||
mockDate = new jasmineUnderTest.MockDate(global),
|
mockDate = new jasmineUnderTest.MockDate(global),
|
||||||
@@ -963,12 +963,9 @@ describe('Clock (acceptance)', function() {
|
|||||||
),
|
),
|
||||||
env = jasmineUnderTest.getEnv();
|
env = jasmineUnderTest.getEnv();
|
||||||
|
|
||||||
spyOn(env, 'deprecated');
|
expect(() => clock.mockDate(12345)).toThrowError(
|
||||||
clock.mockDate(12345);
|
|
||||||
expect(env.deprecated).toHaveBeenCalledWith(
|
|
||||||
'The argument to jasmine.clock().mockDate(), if specified, should be ' +
|
'The argument to jasmine.clock().mockDate(), if specified, should be ' +
|
||||||
'a Date instance. Passing anything other than a Date will be ' +
|
'a Date instance.'
|
||||||
'treated as an error in a future release.'
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -17,10 +17,9 @@ getJasmineRequireObj().MockDate = function(j$) {
|
|||||||
currentTime = mockDate.getTime();
|
currentTime = mockDate.getTime();
|
||||||
} else {
|
} else {
|
||||||
if (!j$.util.isUndefined(mockDate)) {
|
if (!j$.util.isUndefined(mockDate)) {
|
||||||
j$.getEnv().deprecated(
|
throw new Error(
|
||||||
'The argument to jasmine.clock().mockDate(), if specified, ' +
|
'The argument to jasmine.clock().mockDate(), if specified, ' +
|
||||||
'should be a Date instance. Passing anything other than a Date ' +
|
'should be a Date instance.'
|
||||||
'will be treated as an error in a future release.'
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user