blob: 178177871239831fae2f6e3ba2a576e78b30ce9c [file] [log] [blame]
/**
* @license Angular v8.1.1
* (c) 2010-2019 Google LLC. https://angular.io/
* License: MIT
*/
import { InjectionToken } from '@angular/core';
import { Location } from '@angular/common';
import { LocationChangeListener } from '@angular/common';
import { LocationStrategy } from '@angular/common';
import { PlatformLocation } from '@angular/common';
import { SubscriptionLike } from 'rxjs';
/**
* Provider for mock platform location config
*
* @publicApi
*/
export declare const MOCK_PLATFORM_LOCATION_CONFIG: InjectionToken<{}>;
/**
* A mock implementation of {@link LocationStrategy} that allows tests to fire simulated
* location events.
*
* @publicApi
*/
export declare class MockLocationStrategy extends LocationStrategy {
internalBaseHref: string;
internalPath: string;
internalTitle: string;
urlChanges: string[];
private stateChanges;
constructor();
simulatePopState(url: string): void;
path(includeHash?: boolean): string;
prepareExternalUrl(internal: string): string;
pushState(ctx: any, title: string, path: string, query: string): void;
replaceState(ctx: any, title: string, path: string, query: string): void;
onPopState(fn: (value: any) => void): void;
getBaseHref(): string;
back(): void;
forward(): void;
getState(): unknown;
}
/**
* Mock implementation of URL state.
*
* @publicApi
*/
export declare class MockPlatformLocation implements PlatformLocation {
private baseHref;
private hashUpdate;
private urlChanges;
constructor(config?: MockPlatformLocationConfig);
readonly hostname: string;
readonly protocol: string;
readonly port: string;
readonly pathname: string;
readonly search: string;
readonly hash: string;
readonly state: unknown;
getBaseHrefFromDOM(): string;
onPopState(fn: LocationChangeListener): void;
onHashChange(fn: LocationChangeListener): void;
readonly href: string;
readonly url: string;
private parseChanges;
replaceState(state: any, title: string, newUrl: string): void;
pushState(state: any, title: string, newUrl: string): void;
forward(): void;
back(): void;
getState(): unknown;
}
/**
* Mock platform location config
*
* @publicApi
*/
export declare interface MockPlatformLocationConfig {
startUrl?: string;
appBaseHref?: string;
}
/**
* A spy for {@link Location} that allows tests to fire simulated location events.
*
* @publicApi
*/
export declare class SpyLocation implements Location {
urlChanges: string[];
private _history;
private _historyIndex;
setInitialPath(url: string): void;
setBaseHref(url: string): void;
path(): string;
getState(): unknown;
isCurrentPathEqualTo(path: string, query?: string): boolean;
simulateUrlPop(pathname: string): void;
simulateHashChange(pathname: string): void;
prepareExternalUrl(url: string): string;
go(path: string, query?: string, state?: any): void;
replaceState(path: string, query?: string, state?: any): void;
forward(): void;
back(): void;
onUrlChange(fn: (url: string, state: unknown) => void): void;
subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): SubscriptionLike;
normalize(url: string): string;
}
export { }