SpyLocation

A spy for Locationthat allows tests to fire simulated location events.

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 = '', state: any = null) replaceState(path: string, query: string = '', state: any = null) forward() back() subscribe(onNext: (value: any) => void, onThrow?: ((error: any) => void) | null, onReturn?: (() => void) | null): SubscriptionLike normalize(url: string): string }

属性

属性名类型说明
urlChanges

方法

setInitialPath(url: string)

参数

url

Type: string.

setBaseHref(url: string)

参数

url

Type: string.

path(): string

参数

没有参数。

返回值

string

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

参数

path

Type: string.

query

Type: string.

可选. 默认值是 ''.

返回值

boolean

simulateUrlPop(pathname: string)

参数

pathname

Type: string.

simulateHashChange(pathname: string)

参数

pathname

Type: string.

prepareExternalUrl(url: string): string

参数

url

Type: string.

返回值

string

go(path: string, query: string = '', state: any = null)

参数

path

Type: string.

query

Type: string.

可选. 默认值是 ''.

state

Type: any.

可选. 默认值是 null.

replaceState(path: string, query: string = '', state: any = null)

参数

path

Type: string.

query

Type: string.

可选. 默认值是 ''.

state

Type: any.

可选. 默认值是 null.

forward()

参数

没有参数。

back()

参数

没有参数。

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

参数

onNext

Type: (value: any) => void.

onThrow

Type: ((error: any) => void) | null.

可选. 默认值是 undefined.

onReturn

Type: (() => void) | null.

可选. 默认值是 undefined.

返回值

SubscriptionLike

normalize(url: string): string

参数

url

Type: string.

返回值

string

注解

@Injectable()