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

SpyLocation

的间谍对象,它允许测试者触发模拟的位置事件。

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

Location
      
      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()
  historyGo(relativePosition: number = 0): void
  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)
    
参数
url string
      
      setBaseHref(url: string)
    
参数
url string
      
      path(): string
    
参数

没有参数。

返回值

string

      
      getState(): unknown
    
参数

没有参数。

返回值

unknown

      
      isCurrentPathEqualTo(path: string, query: string = ''): boolean
    
参数
path string
query string
可选. 默认值是 `''`.
返回值

boolean

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

string

      
      go(path: string, query: string = '', state: any = null)
    
参数
path string
query string
可选. 默认值是 `''`.
state any
可选. 默认值是 `null`.
      
      replaceState(path: string, query: string = '', state: any = null)
    
参数
path string
query string
可选. 默认值是 `''`.
state any
可选. 默认值是 `null`.
      
      forward()
    
参数

没有参数。

      
      back()
    
参数

没有参数。

      
      historyGo(relativePosition: number = 0): void
    
参数
relativePosition number
可选. 默认值是 `0`.
返回值

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
    
参数
onNext (value: any) => void
onThrow (error: any) => void
可选. 默认值是 `undefined`.
onReturn () => void
可选. 默认值是 `undefined`.
返回值

SubscriptionLike

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

string