I have a function which looks for place in the url and if found, the function will remove it and update location.href. How to write a test?
export class Auth0IdentityService extends IdentityService {
constructor() {}
removePlaces(): void {
const url = new URL(window.location.href)
if ((url.searchParams.get("place")) {
url.searchParams.delete("place");
window.location.href = url.href;
}
}
}
`
My it block is:
it('should remove place from url', async () => {
const spy = spyOnProperty(window.location, 'href', 'get').and.returnValue("http://localhost:3000/?place=xxxx");
component.removePlaces()
expect (window.location.href).toBe ("http://localhost:3000/?place=xxxx")
})
`
It end up with error message "href is not declared configurable".