test(theme): verify bUnit 2.7.2 with patched DOM parser

This commit is contained in:
Joseph Doherty
2026-11-13 14:41:17 -05:00
parent 1118e0418e
commit 9bda64ec4b
23 changed files with 1298 additions and 2 deletions
@@ -0,0 +1,31 @@
using Bunit;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Rendering;
using Xunit;
public sealed class BunitCompatibilityTests : BunitContext
{
[Fact]
public void Render_query_click_rerender_and_authorization_are_available()
{
var auth = this.AddAuthorization();
auth.SetAuthorized("synthetic-user");
auth.SetRoles("Viewer");
var cut = Render<Probe>();
Assert.Equal("Count 0", cut.Find("button").TextContent);
cut.Find("button").Click();
Assert.Equal("Count 1", cut.Find("button").TextContent);
Assert.Single(cut.FindAll("button"));
}
public sealed class Probe : ComponentBase
{
private int count;
protected override void BuildRenderTree(RenderTreeBuilder b)
{
b.OpenElement(0, "button");
b.AddAttribute(1, "onclick", EventCallback.Factory.Create(this, () => count++));
b.AddContent(2, $"Count {count}");
b.CloseElement();
}
}
}