This is the archived documentation for Angular v5. Please visit angular.io to see documentation for the current version of Angular.

SpyLocation

npm Package @angular/common
Module import { SpyLocation } from '@angular/common/testing';
Source common/testing/src/location_mock.ts

Overview

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

Description

A spy for Location that allows tests to fire simulated location events.

Members

      
      urlChanges: string[]
    

      
      setInitialPath(url: string)
    

      
      setBaseHref(url: string)
    

      
      path(): string
    

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

      
      simulateUrlPop(pathname: string)
    

      
      simulateHashChange(pathname: string)
    

      
      prepareExternalUrl(url: string): string
    

      
      go(path: string, query: string = '')
    

      
      replaceState(path: string, query: string = '')
    

      
      forward()
    

      
      back()
    

      
      subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): ISubscription
    

      
      normalize(url: string): string
    

Annotations

      
      @Injectable()