Skip to content

Commit

Permalink
Use a element instead of button
Browse files Browse the repository at this point in the history
  • Loading branch information
linkdotnet committed Jun 27, 2024
1 parent 99447a7 commit b95f005
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

<AuthorizeView>
<div class="d-flex justify-content-start gap-2">
<button id="edit-blogpost" type="button" class="btn btn-primary d-flex align-items-center gap-2" @onclick="EditBlogPost" aria-label="edit">
<a id="edit-blogpost" type="button" class="btn btn-primary d-flex align-items-center gap-2" href="update/@BlogPostId" aria-label="edit">
<i class="pencil"></i>
<div class="vr"></div><span>Edit</span>
</button>
</a>
<button id="delete-blogpost" type="button" class="btn btn-danger d-flex align-items-center gap-2" @onclick="ShowConfirmDialog" aria-label="delete">
<i class="bin2"></i>
<div class="vr"></div><span>Delete</span>
Expand Down Expand Up @@ -39,9 +39,4 @@
{
ConfirmDialog.Open();
}

private void EditBlogPost()
{
NavigationManager.NavigateTo($"update/{BlogPostId}");
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Threading.Tasks;
using AngleSharp.Html.Dom;
using Blazored.Toast.Services;
using LinkDotNet.Blog.Domain;
using LinkDotNet.Blog.Infrastructure.Persistence;
Expand Down Expand Up @@ -50,14 +51,14 @@ public async Task ShouldNotDeleteBlogPostWhenCancelClicked()
}

[Fact]
public void ShouldGoToEditPageOnEditClick()
public void ShouldGoToEditPageForEdit()
{
const string blogPostId = "2";
var navigationManager = Services.GetRequiredService<NavigationManager>();

var cut = Render<BlogPostAdminActions>(s => s.Add(p => p.BlogPostId, blogPostId));

cut.Find("#edit-blogpost").Click();

navigationManager.Uri.Should().EndWith($"update/{blogPostId}");
var anchor = cut.Find("#edit-blogpost") as IHtmlAnchorElement;
anchor.Should().NotBeNull();
anchor.Href.Should().EndWith($"update/{blogPostId}");
}
}

0 comments on commit b95f005

Please sign in to comment.