Replies: 1 comment
-
Hi @h2df, A few pointers:
var cut = RenderComponent<NavMenu>();
var menuItems = cut.FindComponents<DxMenuItem>();
DxMenuItem firstMenuItem = menuItems.First().Instance;
Assert.Equal("Home", firstMenuItem.Text);
Assert.Equal("/", firstMenuItem.NavigateUrl); This tests that there is a DxMenuItem in the expected position in the component tree with the expected parameter values passed to it. Then you just have to trust that DevExpress does what they promise when you pass the correct values to their components. This way, your tests will not be tied to implementation details of their components, which means your tests won't break if they change how they do navigation, e.g. moving to use Hope this helps! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Trying to create my first bUnit test here and got stuck right away...
I have a component
NavMenu
which uses the DevExpressDxMenuItem
. Here's the simplified code:Here's the (failed) test code:
The idea is to first verify that the item with the text "Home" exists, then clicking on the item should bring the user from "somewhere" back to the homepage.
Running the test won't update the mock
NavigationManager
's Uri. TheHistory
property of the navigation manager also only records one navigation to "somewhere".I can verify that the click event is fired as expected. I can also verify that the JSInterop has received the invocations with specified identifier. So my guess is that the navigation is done in the JS, hence the mock JS runtime won't do anything.
What is the correct way to test my component then? Any suggestion is appreciated. Thanks!
Beta Was this translation helpful? Give feedback.
All reactions