I have a child component whose template consists of a button element with 'routerlink' on it which helps in navigating when that button is clicked. The button doesn't have '(click)' handler. Just the routerlink.
Now I'm writing unit test in Jasmine for this component where I want to check if the correct page is loaded or the component calls the router with proper URL(of the next page) when that button is clicked. Essentially the button looks something like this:
<button routerLink="/a/b/c" id="JustAButton">
How do I text these events in order:
- Click on the button (note that the button doesn't have a '(click)' associated with it).
- Check if url has changed to '/a/b/c' or something equivalent which makes sure router is called with that url.
I have followed all the different cases mentioned here and here. None of them help. Mainly because I do not have 'router-outlet' in neither the component I am testing nor the component I am loading on that button click. (I tried using dummy component for the second part too)
Any help would be appreciated!
Thanks!