How to use the @aurelia/router.QueuedBrowserHistory function in @aurelia/router

To help you get started, we’ve selected a few @aurelia/router examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github aurelia / aurelia / packages / __tests__ / router / queued-browser-history.spec.ts View on Github external
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 };
  }