You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@inherits TestContext@code{
[Fact]
publicvoidPreventNavigation()
{// Arrangevarcut=Render(@<Navigation/>);
varnavigationManager=Services.GetRequiredService<NavigationManager>();
// Assert we're at the starting UriAssert.Equal(newUri(new(navigationManager.BaseUri), "/original-path").AbsoluteUri, navigationManager.Uri);
// Act -> click the button to navigatevarbutton=cut.Find("#clickable");
button.Click();
// Assert the path remains the original path as navigation was preventedAssert.Equal(newUri(new(navigationManager.BaseUri), "/original-path").AbsoluteUri, navigationManager.Uri);
}}
Expected behavior:
I would have expected the test to pass. But both line #83 and line #95 are setting the Uri property before it checks if navigation should be prevented. The History Stack is correct, but I would have expected the FakeNavigationManager to behave more like the WebAssemblyNavigationManager
Version info:
bUnit version: 1.34.0
.NET Runtime and Blazor version: net7.0 (Mcrosoft.NETCore.App 7.0.20)
OS type and version: Windows 11 Version 23H2
Additional context:
The text was updated successfully, but these errors were encountered:
Describe the bug
I would love to try submitting a PR if the maintainers agree this should be changed.
In
FakeNavigationManager.NavigateToCore()
the Uri is being set regardless of whether or not handlers prevented navigation.Example:
Testing this component:
With this test:
Results in this output:
Expected behavior:
I would have expected the test to pass. But both line #83 and line #95 are setting the
Uri
property before it checks if navigation should be prevented. TheHistory
Stack is correct, but I would have expected theFakeNavigationManager
to behave more like theWebAssemblyNavigationManager
Version info:
Additional context:
The text was updated successfully, but these errors were encountered: