Prevent mock clock timing fns from being spied on

Fixes #826
This commit is contained in:
Steve Gravrock
2025-09-25 20:56:19 -07:00
parent 979e4a5d0f
commit 190a13ed96
5 changed files with 73 additions and 0 deletions

View File

@@ -135,6 +135,18 @@ describe('SpyRegistry', function() {
target.spiedFunc();
expect(originalFunctionWasCalled).toBe(false);
});
it('throws if the method is a mock clock method', function() {
const spyRegistry = new jasmineUnderTest.SpyRegistry({
createSpy: createSpy
});
const target = { spiedFunc: function() {} };
target.spiedFunc[jasmineUnderTest.Clock.IsMockClockTimingFn] = true;
expect(function() {
spyRegistry.spyOn(target, 'spiedFunc');
}).toThrowError("Mock clock timing functions can't be spied on");
});
});
describe('#spyOnProperty', function() {