ant-design-blazor/tests/AntDesign.Tests/badge/BadgeTests.razor
James Yeung 81ce25c34e
test: add badge tests (#4145)
* add basic test

* fix tests
2024-09-01 19:46:06 +08:00

41 lines
1.4 KiB
C#

@inherits AntDesignTestBase
@code {
[Theory]
[InlineData(BadgeColor.Pink)]
[InlineData(BadgeColor.Red)]
[InlineData(BadgeColor.Yellow)]
[InlineData(BadgeColor.Orange)]
[InlineData(BadgeColor.Cyan)]
[InlineData(BadgeColor.Green)]
[InlineData(BadgeColor.Blue)]
[InlineData(BadgeColor.Purple)]
[InlineData(BadgeColor.Geekblue)]
[InlineData(BadgeColor.Magenta)]
[InlineData(BadgeColor.Volcano)]
[InlineData(BadgeColor.Gold)]
[InlineData(BadgeColor.Lime)]
public void ItShouldRenderBadgeWithColors(string color)
{
var cut = Render<Badge>(@<Badge Color="@color"></Badge> );
cut.MarkupMatches(@<span class="ant-badge ant-badge-status ant-badge-not-a-wrapper" id:ignore>
<span class="ant-badge-status-dot" style="background: @color; "></span>
</span>);
}
[Theory]
[MemberData(nameof(inlineData))]
public void ItShouldRenderBadgeWithPresetColors(PresetColor color)
{
var cut = Render<Badge>(@<Badge PresetColor="@color"></Badge> );
var persetColor = Enum.GetName(typeof(PresetColor), color).ToLowerInvariant();
cut.MarkupMatches(@<span class="ant-badge ant-badge-status ant-badge-not-a-wrapper" id:ignore>
<span class="ant-badge-status-dot ant-badge-status-@persetColor" style=""></span>
</span>
);
}
public static IEnumerable<object[]> inlineData => Enum.GetValues<PresetColor>().Select(x => new object[] { x });
}