I tried to validate the behavior of a tooltip (using ToolTopService
) in bunit.
I failed because I do not now how to correctly trigger the mouse enter event to the element.
The component is configured like this:
<RadzenIcon
MouseEnter="args => this.OnShowTooltip(args, new TooltipOptions { Delay = 300, Duration = 5000 }, myToolTipText)"
MouseLeave="this.OnHideTooltip"
Icon="announcement" IconStyle="IconStyle.Warning"/>
The ToolTipService
is integrated like this:
private void OnShowTooltip(ElementReference elementReference, TooltipOptions options, string text)
{
this.TooltipService.Open(elementReference, text, options);
}
private void OnHideTooltip()
{
this.TooltipService.Close();
}
This is working as expected at runtime. But, I fail to create a BUnit test.
When I try to trigger the event I get an exception information that no event is available.
var icon = userCell.Descendants<HtmlElement>().Single(x => x.ClassList.Contains("rzi-warning"));
icon.TriggerEvent("MouseEnter", EventArgs.Empty);
Bunit.MissingEventHandlerException: The element does not have an event handler for the event 'MouseEnter', nor any other events.
Has anybody already successfully tested the ToolTipService
behavior with BUnit
?