The old style of merging all of a function's variable declarations into a single statement made some sense back in the days of var, but there's no reason to keep doing it now that we use const and let.
26 lines
675 B
JavaScript
26 lines
675 B
JavaScript
describe('Spy Registry browser-specific behavior', function() {
|
|
function createSpy(name, originalFn) {
|
|
return privateUnderTest.Spy(name, originalFn);
|
|
}
|
|
|
|
it('can spy on and unspy window.onerror', function() {
|
|
const spies = [];
|
|
const spyRegistry = new privateUnderTest.SpyRegistry({
|
|
currentSpies: function() {
|
|
return spies;
|
|
},
|
|
createSpy: createSpy,
|
|
global: window
|
|
});
|
|
const originalHandler = window.onerror;
|
|
|
|
try {
|
|
spyRegistry.spyOn(window, 'onerror');
|
|
spyRegistry.clearSpies();
|
|
expect(window.onerror).toBe(originalHandler);
|
|
} finally {
|
|
window.onerror = originalHandler;
|
|
}
|
|
});
|
|
});
|