填写这份《一分钟调查》,帮我们(开发组)做得更好!去填写Home

SpyLocation

A spy for Locationthat allows tests to fire simulated location events.

      
      class SpyLocation implements Location {
  urlChanges: string[]
  setInitialPath(url: string)
  setBaseHref(url: string)
  path(): string
  getState(): unknown
  isCurrentPathEqualTo(path: string, query: string = ''): boolean
  simulateUrlPop(pathname: string)
  simulateHashChange(pathname: string)
  prepareExternalUrl(url: string): string
  go(path: string, query: string = '', state: any = null)
  replaceState(path: string, query: string = '', state: any = null)
  forward()
  back()
  onUrlChange(fn: (url: string, state: unknown) => void)
  subscribe(onNext: (value: any) => void, onThrow?: (error: any) => void, onReturn?: () => void): SubscriptionLike
  normalize(url: string): string
}
    

属性

属性说明
urlChanges: string[]

方法

setInitialPath(url: string)
      
      setInitialPath(url: string)
    
参数
url string
setBaseHref(url: string)
      
      setBaseHref(url: string)
    
参数
url string
path(): string
      
      path(): string
    
参数

没有参数。

返回值

string

getState(): unknown
      
      getState(): unknown
    
参数

没有参数。

返回值

unknown

isCurrentPathEqualTo(path: string, query: string = ''): boolean
      
      isCurrentPathEqualTo(path: string, query: string = ''): boolean
    
参数
path string
query string

可选. 默认值是 ''.

返回值

boolean

simulateUrlPop(pathname: string)
      
      simulateUrlPop(pathname: string)
    
参数
pathname string
simulateHashChange(pathname: string)
      
      simulateHashChange(pathname: string)
    
参数
pathname string
prepareExternalUrl(url: string): string
      
      prepareExternalUrl(url: string): string
    
参数
url string
返回值

string

go(path: string, query: string = '', state: any = null)
      
      go(path: string, query: string = '', state: any = null)
    
参数
path string
query string

可选. 默认值是 ''.

state any

可选. 默认值是 null.

replaceState(path: string, query: string = '', state: any = null)
      
      replaceState(path: string, query: string = '', state: any = null)
    
参数
path string
query string

可选. 默认值是 ''.

state any

可选. 默认值是 null.

forward()
      
      forward()
    
参数

没有参数。

back()
      
      back()
    
参数

没有参数。

onUrlChange(fn: (url: string, state: unknown) => void)
      
      onUrlChange(fn: (url: string, state: unknown) => void)
    
参数
fn (url: string, state: unknown) => void
subscribe(onNext: (value: any) => void, onThrow?: (error: any) => void, onReturn?: () => void): SubscriptionLike
      
      subscribe(onNext: (value: any) => void, onThrow?: (error: any) => void, onReturn?: () => void): SubscriptionLike
    
参数
onNext (value: any) => void
onThrow (error: any) => void

可选. 默认值是 undefined.

onReturn () => void

可选. 默认值是 undefined.

返回值

SubscriptionLike

normalize(url: string): string
      
      normalize(url: string): string
    
参数
url string
返回值

string