mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-12-16 01:41:14 +08:00
cbc5e823f0
* fix: card title template * fix: template:badge,collapse * fix: comment refactor template * fix: ribbonTests * feat: descriptions refactor template * feat: empty refactor template * feat: list refactor template * feat: menu refactor template * feat: confirm add question icon * feat: pageHeader and statistic refactor template * feat: popconfirm refactor template * feat: popver refactor template * feat: result refactor template * feat: step refactor template * feat: switch refactor template * feat: table refactor template * feat: transfer refactor template * feat: optimized code * fix: pageheader * refactor(module: empty): remove empty image constant images Co-authored-by: ElderJames <shunjiey@hotmail.com>
154 lines
4.9 KiB
C#
154 lines
4.9 KiB
C#
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<BadgeRibbon>();
|
|
cut.MarkupMatches(@"
|
|
<div class=""ant-ribbon-wrapper"">
|
|
<div class=""ant-ribbon ant-ribbon-placement-end"">
|
|
<div class=""ant-ribbon-corner""></div>
|
|
</div>
|
|
</div>
|
|
");
|
|
}
|
|
|
|
[Fact(DisplayName = "Works with `start` & `end` placement")]
|
|
public void TestRibbonPlacement()
|
|
{
|
|
var cut = Context.RenderComponent<BadgeRibbon>(p =>
|
|
{
|
|
p.Add(x => x.Placement, "start");
|
|
p.AddChildContent("<div />");
|
|
}
|
|
);
|
|
cut.MarkupMatches(@"
|
|
<div class=""ant-ribbon-wrapper"">
|
|
<div />
|
|
<div class=""ant-ribbon ant-ribbon-placement-start"">
|
|
<div class=""ant-ribbon-corner"">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
");
|
|
|
|
cut = Context.RenderComponent<BadgeRibbon>(p =>
|
|
{
|
|
p.Add(x => x.Placement, "end");
|
|
p.AddChildContent("<div />");
|
|
}
|
|
);
|
|
cut.MarkupMatches(@"
|
|
<div class=""ant-ribbon-wrapper"">
|
|
<div />
|
|
<div class=""ant-ribbon ant-ribbon-placement-end"">
|
|
<div class=""ant-ribbon-corner"">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
");
|
|
}
|
|
|
|
[Fact(DisplayName = "Works with preset color")]
|
|
public void TestRibbonPresetColor()
|
|
{
|
|
var cut = Context.RenderComponent<BadgeRibbon>(p =>
|
|
{
|
|
p.Add(x => x.Color, "green");
|
|
p.AddChildContent("<div />");
|
|
}
|
|
);
|
|
cut.MarkupMatches(@"
|
|
<div class=""ant-ribbon-wrapper"">
|
|
<div />
|
|
<div class=""ant-ribbon ant-ribbon-placement-end ant-ribbon-color-green"">
|
|
<div class=""ant-ribbon-corner"">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
");
|
|
}
|
|
|
|
[Fact(DisplayName = "Works with preset color")]
|
|
public void TestRibbonCustomColor()
|
|
{
|
|
var color = "#888";
|
|
|
|
var cut = Context.RenderComponent<BadgeRibbon>(p =>
|
|
{
|
|
p.Add(x => x.Color, color);
|
|
p.AddChildContent("<div />");
|
|
}
|
|
);
|
|
|
|
cut.MarkupMatches($@"
|
|
<div class=""ant-ribbon-wrapper"">
|
|
<div />
|
|
<div class=""ant-ribbon ant-ribbon-placement-end"" style=""background: {color}"">
|
|
<div class=""ant-ribbon-corner"" style=""color: {color}"">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
");
|
|
}
|
|
|
|
[Fact(DisplayName = "Works with string")]
|
|
public void TestRibbonText()
|
|
{
|
|
var cut = Context.RenderComponent<BadgeRibbon>(p =>
|
|
{
|
|
p.Add(x => x.Text, "unicorn");
|
|
p.AddChildContent("<div />");
|
|
}
|
|
);
|
|
|
|
cut.MarkupMatches(@"
|
|
<div class=""ant-ribbon-wrapper"">
|
|
<div />
|
|
<div class=""ant-ribbon ant-ribbon-placement-end"">
|
|
unicorn
|
|
<div class=""ant-ribbon-corner"">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
");
|
|
}
|
|
|
|
[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<BadgeRibbon>(p =>
|
|
{
|
|
p.Add(x => x.TextTemplate, fragment);
|
|
p.AddChildContent("<div />");
|
|
}
|
|
);
|
|
|
|
cut.MarkupMatches(@"
|
|
<div class=""ant-ribbon-wrapper"">
|
|
<div />
|
|
<div class=""ant-ribbon ant-ribbon-placement-end"">
|
|
<span class=""cool"">Hello</span>
|
|
<div class=""ant-ribbon-corner"">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
");
|
|
}
|
|
}
|
|
}
|