SpyLocation
From Get docs
< @angular/common | testingAngular/docs/latest/api/common/testing/spylocation
SpyLocation
class
A spy for Location that 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()
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
}
Properties
| Property | Description |
|---|---|
urlChanges: string[]
|
Methods
|
setInitialPath() | |||
|---|---|---|---|
setInitialPath(url: string)Parameters
|
|
setBaseHref() | |||
|---|---|---|---|
setBaseHref(url: string)Parameters
|
|
path() |
|---|
path(): stringParametersThere are no parameters. Returns
|
|
getState() |
|---|
getState(): unknownParametersThere are no parameters. Returns
|
|
isCurrentPathEqualTo() | ||||||
|---|---|---|---|---|---|---|
isCurrentPathEqualTo(path: string, query: string = ): booleanParameters
Returns
|
|
simulateUrlPop() | |||
|---|---|---|---|
simulateUrlPop(pathname: string)Parameters
|
|
simulateHashChange() | |||
|---|---|---|---|
simulateHashChange(pathname: string)Parameters
|
|
prepareExternalUrl() | |||
|---|---|---|---|
prepareExternalUrl(url: string): stringParameters
Returns
|
|
go() | |||||||||
|---|---|---|---|---|---|---|---|---|---|
go(path: string, query: string = , state: any = null)Parameters
|
|
replaceState() | |||||||||
|---|---|---|---|---|---|---|---|---|---|
replaceState(path: string, query: string = , state: any = null)Parameters
|
|
forward() |
|---|
forward()ParametersThere are no parameters.
|
|
back() |
|---|
back()ParametersThere are no parameters.
|
|
historyGo() | |||
|---|---|---|---|
historyGo(relativePosition: number = 0): voidParameters
Returns
|
|
onUrlChange() | |||
|---|---|---|---|
onUrlChange(fn: (url: string, state: unknown) => void)Parameters
|
|
subscribe() | |||||||||
|---|---|---|---|---|---|---|---|---|---|
subscribe(onNext: (value: any) => void, onThrow?: (error: any) => void, onReturn?: () => void): SubscriptionLikeParameters
Returns
|
|
normalize() | |||
|---|---|---|---|
normalize(url: string): stringParameters
Returns
|
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://angular.io/api/common/testing/SpyLocation