SpyLocation
Class
stable
A spy for Location that allows tests to fire simulated location events.
API
class SpyLocation implements Location { urlChanges: string[]; setInitialPath(url: string): void; setBaseHref(url: string): void; path(): string; getState(): unknown; isCurrentPathEqualTo(path: string, query?: string): boolean; simulateUrlPop(pathname: string): void; simulateHashChange(pathname: string): void; prepareExternalUrl(url: string): string; go(path: string, query?: string, state?: any): void; replaceState(path: string, query?: string, state?: any): void; forward(): void; back(): void; historyGo(relativePosition?: number): void; onUrlChange(fn: (url: string, state: unknown) => void): VoidFunction; subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null | undefined, onReturn?: (() => void) | null | undefined): SubscriptionLike; normalize(url: string): string;}
urlChanges
string[]setInitialPath
void@paramurl
string@returns
voidsetBaseHref
void@paramurl
string@returns
voidpath
string@returns
stringgetState
unknown@returns
unknownisCurrentPathEqualTo
boolean@parampath
string@paramquery
string@returns
booleansimulateUrlPop
void@parampathname
string@returns
voidsimulateHashChange
void@parampathname
string@returns
voidprepareExternalUrl
string@paramurl
string@returns
stringgo
void@parampath
string@paramquery
string@paramstate
any@returns
voidreplaceState
void@parampath
string@paramquery
string@paramstate
any@returns
voidforward
void@returns
voidback
void@returns
voidhistoryGo
void@paramrelativePosition
number@returns
voidonUrlChange
VoidFunction@paramfn
(url: string, state: unknown) => void@returns
VoidFunctionsubscribe
SubscriptionLike@paramonNext
(value: any) => void@paramonThrow
((error: any) => void) | null | undefined@paramonReturn
(() => void) | null | undefined@returns
SubscriptionLikenormalize
string@paramurl
string@returns
stringJump to details