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

MockLocationStrategy

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

Overview

      
      class MockLocationStrategy extends LocationStrategy {
  constructor()
  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
  // inherited from common/LocationStrategy
  path(includeHash?: boolean): string
  prepareExternalUrl(internal: string): string
  pushState(state: any, title: string, url: string, queryParams: string): void
  replaceState(state: any, title: string, url: string, queryParams: string): void
  forward(): void
  back(): void
  onPopState(fn: LocationChangeListener): void
  getBaseHref(): string
}
    

Description

A mock implementation of LocationStrategy that allows tests to fire simulated location events.

Constructor

      
      constructor()
    

Members

      
      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
    

Annotations

      
      @Injectable()