angular-docs-cn/tools/public_api_guard/common/testing.d.ts

65 lines
2.3 KiB
TypeScript

export declare const MOCK_PLATFORM_LOCATION_CONFIG: InjectionToken<{}>;
export declare class MockLocationStrategy extends LocationStrategy {
internalBaseHref: string;
internalPath: string;
internalTitle: string;
urlChanges: string[];
constructor();
back(): void;
forward(): void;
getBaseHref(): string;
getState(): unknown;
onPopState(fn: (value: any) => void): 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;
simulatePopState(url: string): void;
}
export declare class MockPlatformLocation implements PlatformLocation {
readonly hash: string;
readonly hostname: string;
readonly href: string;
readonly pathname: string;
readonly port: string;
readonly protocol: string;
readonly search: string;
readonly state: unknown;
readonly url: string;
constructor(config?: MockPlatformLocationConfig);
back(): void;
forward(): void;
getBaseHrefFromDOM(): string;
getState(): unknown;
onHashChange(fn: LocationChangeListener): void;
onPopState(fn: LocationChangeListener): void;
pushState(state: any, title: string, newUrl: string): void;
replaceState(state: any, title: string, newUrl: string): void;
}
export interface MockPlatformLocationConfig {
appBaseHref?: string;
startUrl?: string;
}
export declare class SpyLocation implements Location {
urlChanges: string[];
back(): void;
forward(): void;
getState(): unknown;
go(path: string, query?: string, state?: any): void;
isCurrentPathEqualTo(path: string, query?: string): boolean;
normalize(url: string): string;
onUrlChange(fn: (url: string, state: unknown) => void): void;
path(): string;
prepareExternalUrl(url: string): string;
replaceState(path: string, query?: string, state?: any): void;
setBaseHref(url: string): void;
setInitialPath(url: string): void;
simulateHashChange(pathname: string): void;
simulateUrlPop(pathname: string): void;
subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): SubscriptionLike;
}