Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setup() {
const ctx = TestContext.createHTMLTestContext();
const originalWnd = ctx.wnd;
const mockWnd = new MockWindow(originalWnd.history);
const addEventListener = createSpy(mockWnd, 'addEventListener');
const removeEventListener = createSpy(mockWnd, 'removeEventListener');
(DOM as Writable).window = mockWnd;
const lifecycle = DI.createContainer().get(ILifecycle);
lifecycle.startTicking();
const sut = new QueuedBrowserHistory(lifecycle);
function tearDown() {
(DOM as Writable).window = originalWnd;
lifecycle.stopTicking();
}
let callbackCount = 0;
const callback = ((info) => {
callbackCount++;
});
return { addEventListener, removeEventListener, sut, tearDown, callback, lifecycle };
}