A mock implementation of LocationStrategy
that allows tests to fire simulated location events.
class MockLocationStrategy extends LocationStrategy { internalBaseHref: string internalPath: string internalTitle: string urlChanges: string[] simulatePopState(url: string): void path(includeHash: boolean = false): 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 // 继承自 common/LocationStrategy abstract path(includeHash?: boolean): string abstract prepareExternalUrl(internal: string): string abstract pushState(state: any, title: string, url: string, queryParams: string): void abstract replaceState(state: any, title: string, url: string, queryParams: string): void abstract forward(): void abstract back(): void abstract onPopState(fn: LocationChangeListener): void abstract getBaseHref(): string }属性
属性名 | 类型 | 说明 |
---|
internalBaseHref | | |
internalPath | | |
internalTitle | | |
urlChanges | | |
方法
|
---|
simulatePopState(url: string): void参数返回值void
|
|
---|
path(includeHash: boolean = false): string参数includeHash | Type: boolean . 可选. 默认值是 false . |
返回值string
|
|
---|
prepareExternalUrl(internal: string): string参数返回值string
|
|
---|
pushState(ctx: any, title: string, path: string, query: string): void参数ctx | Type: any . | title | Type: string . | path | Type: string . | query | Type: string . |
返回值void
|
|
---|
replaceState(ctx: any, title: string, path: string, query: string): void参数ctx | Type: any . | title | Type: string . | path | Type: string . | query | Type: string . |
返回值void
|
|
---|
onPopState(fn: (value: any) => void): void参数fn | Type: (value: any) => void . |
返回值void
|
|
---|
getBaseHref(): string参数没有参数。 返回值string
|
|
---|
back(): void参数没有参数。 返回值void
|
|
---|
forward(): void参数没有参数。 返回值void
|