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
[Test]publicasyncTaskNavLink_Active(){conststringactiveClass="Custom__nav_active_css";varcomp=Context.RenderComponent<MudNavLink>(Parameter(nameof(MudNavLink.ActiveClass),activeClass));comp.Markup.Should().NotContain(activeClass);//this one failscomp.Find(".mud-nav-link").Click();comp.Markup.Should().Contain(activeClass);}
Results in this output:
Did not expect comp.Markup "<div class="mud-nav-item mud-ripple"><a blazor:onclick="1" rel="" class="mud-nav-link Custom__nav_active_css"><div class="...
Expected behavior:
ActiveClass should be part of css depending on the page you are.
Just took a quick look at the source for NavLink and it looks like you have to specify a href attribute on NavLink and set a url in navigation manager to get NavLink to set the active class.
Activity
egil commentedon Oct 31, 2022
Hi @TDroogers, thanks for reaching out.
Just took a quick look at the source for NavLink and it looks like you have to specify a
hrefattribute onNavLinkand set a url in navigation manager to getNavLinkto set the active class.Here are the docs for working with the built-in navigation manager in bUnit: https://bunit.dev/docs/test-doubles/fake-navigation-manager.html
egil commentedon Oct 31, 2022
Ps. ill convert this to a QA discussion since this is not a bug in bUnit.