class
final
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 }
Property | Description |
---|---|
urlChanges: string[] |
setInitialPath() | |||
---|---|---|---|
|
url | string |
setBaseHref() | |||
---|---|---|---|
|
url | string |
path() |
---|
|
getState() |
---|
|
isCurrentPathEqualTo() | ||||||
---|---|---|---|---|---|---|
|
path | string | |
query | string | Optional. Default is |
boolean
simulateUrlPop() | |||
---|---|---|---|
|
pathname | string |
simulateHashChange() | |||
---|---|---|---|
|
pathname | string |
prepareExternalUrl() | |||
---|---|---|---|
|
url | string |
string
go() | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
path | string | |
query | string | Optional. Default is |
state | any | Optional. Default is |
replaceState() | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
path | string | |
query | string | Optional. Default is |
state | any | Optional. Default is |
forward() |
---|
|
back() |
---|
|
historyGo() | |||
---|---|---|---|
|
relativePosition | number | Optional. Default is |
void
onUrlChange() | |||
---|---|---|---|
|
fn | (url: string, state: unknown) => void |
subscribe() | |||||||||
---|---|---|---|---|---|---|---|---|---|
|
onNext | (value: any) => void | |
onThrow | (error: any) => void | Optional. Default is |
onReturn | () => void | Optional. Default is |
SubscriptionLike
normalize() | |||
---|---|---|---|
|
url | string |
string
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v12.angular.io/api/common/testing/SpyLocation