填寫這份《一分鐘調查》,幫我們(開發組)做得更好!去填寫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