-
-
Notifications
You must be signed in to change notification settings - Fork 108
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Parameter not read from route #1580
Comments
Hey @JamesNK, the short answer on why it doesn't get the parameter value from the attribute is because there is no Router involved in bUnit, and the way you did this is (currently) more or less the intended way. The long answer is here: https://bunit.dev/docs/providing-input/passing-parameters-to-components.html?q=SupplyParameterFromQuery&tabs=csharp#passing-query-parameters-supplyparameterfromquery-to-a-component Since This whole cascade is handled by the Therefore, as you provided the var cut = RenderComponent<Metrics>(builder =>
{
builder.Add(m => m.ApplicationName, "TestApp");
builder.Add(m => m.MeterName, "Some Value");
}); If you drop the The reasoning behind is that the whole Maybe @egil and I can pick this up tomorrow and discuss this further. At least from a documentation point of view, there is room for improvements. |
Ok. This is what I added to make my test pass: navigationManager.LocationChanged += (sender, e) =>
{
cut.SetParametersAndRender(builder =>
{
builder.Add(m => m.ApplicationName, "TestApp2");
});
}; It's surprising that some parameters are automatically bound from navigation manager and others aren't. |
@JamesNK, I think it is a decent workaround to emulate Do I understand the scenario correctly: A component under test uses In a bUnit test, only
It is, and I dislike that. Prefer not to surprise users. As far as I can tell (or remember), our I think it should be possible to enable this for path parameters too, since our renderer could subscribe to |
Yes |
Describe the bug
I have a page that I'm testing with some routes:
There are also some query string parameters:
I have set a URL in navigation manager:
When the component is rendered I see the
MeterName
parameter has a value, but theApplicationName
is blank.Now, I can fix that by manually setting the parameter value when calling
RenderComponent
:But part of the code I'm testing changes the current page with
NavigateTo
, and I needApplicationName
parameter to pick up its new value when navigation happens.Why isn't
ApplicationName
parameter value getting its value from the@page "/metrics/resource/{ApplicationName}"
page route?The text was updated successfully, but these errors were encountered: