I tried to mock the browser url as follows in my test:
window.history.replaceState({}, "Test", "/abc");
However, since the currentPath value is set (in router.js) before the url above is set, currentPath remains "/" even after chaning the location.pathname = "/abc".
let currentPath = isNode ? '' : location.pathname;
It occurs only in unit testing. While loading the application from browser, the currentPath is set as "/abc" (whatever url is loaded) correctly.
Due to this, when I call navigate("/") though with location.pathname = "/abc", the currentPath is still "/".
I tried to mock the browser url as follows in my test:
window.history.replaceState({}, "Test", "/abc");
However, since the currentPath value is set (in router.js) before the url above is set, currentPath remains "/" even after chaning the location.pathname = "/abc".
let currentPath = isNode ? '' : location.pathname;
It occurs only in unit testing. While loading the application from browser, the currentPath is set as "/abc" (whatever url is loaded) correctly.
Due to this, when I call navigate("/") though with location.pathname = "/abc", the currentPath is still "/".
CurrentPath should be "/abc" but it is actually "/". Since, the url and currentPath are same i.e., "/", it is returned and not navigated.
Could we have the check to be as follows?
If we change the code as above, navigation would happen as getWorkingPath ("/abc") is not equal to the navigate url ("/").
Also, please advise how to set currentPath to be "/abc" from my test file so that we can avoid the update above?