MockLocationStrategy

A mock implementation of LocationStrategythat 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 }
      
      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: string
internalPath: string
internalTitle: string
urlChanges: string[]

方法

simulatePopState(url: string): void
      
      simulatePopState(url: string): void
    
参数
url string
返回值

void

path(includeHash: boolean = false): string
      
      path(includeHash: boolean = false): string
    
参数
includeHash boolean

可选. 默认值是 false.

返回值

string

prepareExternalUrl(internal: string): string
      
      prepareExternalUrl(internal: string): string
    
参数
internal string
返回值

string

pushState(ctx: any, title: string, path: string, query: string): void
      
      pushState(ctx: any, title: string, path: string, query: string): void
    
参数
ctx any
title string
path string
query string
返回值

void

replaceState(ctx: any, title: string, path: string, query: string): void
      
      replaceState(ctx: any, title: string, path: string, query: string): void
    
参数
ctx any
title string
path string
query string
返回值

void

onPopState(fn: (value: any) => void): void
      
      onPopState(fn: (value: any) => void): void
    
参数
fn (value: any) => void
返回值

void

getBaseHref(): string
      
      getBaseHref(): string
    
参数

没有参数。

返回值

string

back(): void
      
      back(): void
    
参数

没有参数。

返回值

void

forward(): void
      
      forward(): void
    
参数

没有参数。

返回值

void