test(theme): verify bUnit 2.7.2 with patched DOM parser
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user