Skip to content

Commit

Permalink
Added tests for the latest bugs #114 #110
Browse files Browse the repository at this point in the history
  • Loading branch information
stavroskasidis committed Mar 17, 2022
1 parent aa742f1 commit 180ea08
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
8 changes: 4 additions & 4 deletions TestApps/BlazorContextMenu.TestAppsCommon/CommonIndex.razor
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@
</ContextMenu>

<ContextMenu Id="menu5" AutoHideEvent="AutoHideEvent.MouseUp" >
<Item Id="menu4-item1" OnClick="OnClick">Item 1</Item>
<Item Id="menu4-item2" OnClick="OnClick">Item 2</Item>
<Item Id="menu5-item1" OnClick="OnClick">Item 1</Item>
<Item Id="menu5-item2" OnClick="OnClick">Item 2</Item>
</ContextMenu>

<ContextMenu Id="menu6" >
<Item Id="menu4-item1" OnClick="OnClick"><ItemChild>Item 1</ItemChild></Item>
<Item Id="menu4-item2" OnClick="OnClick"><ItemChild>Item 2</ItemChild></Item>
<Item Id="menu6-item1" OnClick="OnClick"><ItemChild>Item 1</ItemChild></Item>
<Item Id="menu6-item2" OnClick="OnClick"><ItemChild>Item 2</ItemChild></Item>
</ContextMenu>

<div>
Expand Down
4 changes: 3 additions & 1 deletion TestApps/BlazorContextMenu.TestAppsCommon/ItemChild.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@ChildContent
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1,5" stroke-linecap="round" stroke-linejoin="round" class="feather mr-4 inline-block feather-eye"><!--!--><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"></path><circle cx="12" cy="12" r="3"></circle></svg>

@ChildContent

@code {
[Parameter] public RenderFragment ChildContent { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,5 +412,22 @@ public async Task Menu5_TriggerAndMouseDownOnHeader_MenuStaysOpen()
var display = menuElement.GetCssValue("display");
Assert.Equal(expectedDisplay, display);
}

[Fact]
public async Task Menu6_TriggerAndClickOutside_MenuCloses()
{
//Arrange
var expectedDisplay = "none";

//Act
await OpenContextMenuAt("test14-trigger", MouseButtonTrigger.Right);
var headerElement = Browser.FindElement(By.Id("header"));
headerElement.Click();

//Assert
var menuElement = Browser.FindElement(By.Id("menu6"));
var display = menuElement.GetCssValue("display");
Assert.Equal(expectedDisplay, display);
}
}
}

0 comments on commit 180ea08

Please sign in to comment.