using Bunit; using Microsoft.AspNetCore.Components; using Xunit; namespace AntDesign.Tests.Badge { public class RibbonTests : AntDesignTestBase { [Fact(DisplayName = "Works with empty params")] public void TestRibbonEmpty() { var cut = Context.RenderComponent(); cut.MarkupMatches(@"
"); } [Fact(DisplayName = "Works with `start` & `end` placement")] public void TestRibbonPlacement() { var cut = Context.RenderComponent(p => { p.Add(x => x.Placement, "start"); p.AddChildContent("
"); } ); cut.MarkupMatches(@"
"); cut = Context.RenderComponent(p => { p.Add(x => x.Placement, "end"); p.AddChildContent("
"); } ); cut.MarkupMatches(@"
"); } [Fact(DisplayName = "Works with preset color")] public void TestRibbonPresetColor() { var cut = Context.RenderComponent(p => { p.Add(x => x.Color, "green"); p.AddChildContent("
"); } ); cut.MarkupMatches(@"
"); } [Fact(DisplayName = "Works with preset color")] public void TestRibbonCustomColor() { var color = "#888"; var cut = Context.RenderComponent(p => { p.Add(x => x.Color, color); p.AddChildContent("
"); } ); cut.MarkupMatches($@"
"); } [Fact(DisplayName = "Works with string")] public void TestRibbonText() { var cut = Context.RenderComponent(p => { p.Add(x => x.Text, "unicorn"); p.AddChildContent("
"); } ); cut.MarkupMatches(@"
unicorn
"); } [Fact(DisplayName = "Works with RenderFragment")] public void TestRibbonRenderFragment() { RenderFragment fragment = builder => { builder.OpenElement(0, "span"); builder.AddAttribute(0, "class", "cool"); builder.AddContent(0, "Hello"); builder.CloseElement(); }; var cut = Context.RenderComponent(p => { p.Add(x => x.TextTemplate, fragment); p.AddChildContent("
"); } ); cut.MarkupMatches(@"
Hello
"); } } }