Testing component with query param #1107
Replies: 3 comments
-
The code you have in That said, you need to set the current url via the fake navigation manager that is part of bUnit before rendering your component. If you do that, the code in Learn more here: https://bunit.dev/docs/test-doubles/fake-navigation-manager |
Beta Was this translation helpful? Give feedback.
-
I know, I was showing two different ways, the one you see in the Though there is a subtle difference between the two approaches. What I have in the
Thanks for letting me know. Taking a look at that. |
Beta Was this translation helpful? Give feedback.
-
I think that is how blazor works and not related to bUnit. I guess if you want both query string parameters you need to use the navigation manager approach. To test that, look at the fake navigation manager docs page. That should get you there. |
Beta Was this translation helpful? Give feedback.
-
I'm a bit stumped, I did try googling + stackoverflow but can't seem to find a way to test my component with a query param.
If I have the following
then I can always have
var cut = RenderComponent<Hug>(r => r.Add(k => k.Discount, "discount"));
But, if my code looks like so
Then I'm not quite sure how to pass the discount query param for testing.
Beta Was this translation helpful? Give feedback.
All reactions