using Bunit; using Marathon.UI.Components; using Marathon.UI.Tests.Support; namespace Marathon.UI.Tests.Components; public sealed class OddsCellTests : MarathonTestContext { [Fact] public void Formats_decimal_to_two_places() { var cut = RenderComponent(p => p.Add(c => c.Rate, 1.8m)); cut.Find(".m-odds__value").TextContent.Trim().Should().Be("1.80"); } [Fact] public void Renders_em_dash_when_rate_is_null() { var cut = RenderComponent(p => { p.Add(c => c.Rate, (decimal?)null); p.Add(c => c.EmptyPlaceholder, "—"); }); cut.Find(".m-odds__value").TextContent.Trim().Should().Be("—"); } [Fact] public void Marks_up_when_rate_increased() { var cut = RenderComponent(p => { p.Add(c => c.Rate, 1.95m); p.Add(c => c.Previous, 1.85m); p.Add(c => c.ShowTrend, true); }); cut.Find(".m-odds").GetAttribute("data-trend").Should().Be("rising"); cut.Find(".m-odds__delta").TextContent.Should().Contain("▲"); } [Fact] public void Marks_down_when_rate_decreased() { var cut = RenderComponent(p => { p.Add(c => c.Rate, 1.70m); p.Add(c => c.Previous, 1.85m); p.Add(c => c.ShowTrend, true); }); cut.Find(".m-odds").GetAttribute("data-trend").Should().Be("falling"); cut.Find(".m-odds__delta").TextContent.Should().Contain("▼"); } [Fact] public void Hides_delta_glyph_when_show_trend_false() { var cut = RenderComponent(p => { p.Add(c => c.Rate, 1.85m); p.Add(c => c.ShowTrend, false); }); cut.FindAll(".m-odds__delta").Should().BeEmpty(); } }