|
3 | 3 | // See the LICENSE file in the project root for more information. |
4 | 4 | // Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone |
5 | 5 |
|
| 6 | +using System.Globalization; |
| 7 | + |
6 | 8 | namespace UnitTest.Components; |
7 | 9 |
|
8 | 10 | public class TimePickerTest : BootstrapBlazorTestBase |
@@ -98,4 +100,46 @@ public async Task OnClickConfirm_Ok() |
98 | 100 | await cut.InvokeAsync(() => btn.Click()); |
99 | 101 | Assert.True(confirm); |
100 | 102 | } |
| 103 | + |
| 104 | + [Fact] |
| 105 | + public void TimePickerCell_StyleName_CultureInvariant() |
| 106 | + { |
| 107 | + // Save original culture |
| 108 | + var originalCulture = CultureInfo.CurrentCulture; |
| 109 | + var originalUICulture = CultureInfo.CurrentUICulture; |
| 110 | + |
| 111 | + try |
| 112 | + { |
| 113 | + // Set culture to Turkish which uses comma as decimal separator |
| 114 | + var turkishCulture = new CultureInfo("tr-TR"); |
| 115 | + CultureInfo.CurrentCulture = turkishCulture; |
| 116 | + CultureInfo.CurrentUICulture = turkishCulture; |
| 117 | + |
| 118 | + var cut = Context.RenderComponent<TimePickerCell>(pb => |
| 119 | + { |
| 120 | + pb.Add(a => a.ViewMode, TimePickerCellViewMode.Hour); |
| 121 | + pb.Add(a => a.Value, TimeSpan.FromHours(2.5)); |
| 122 | + }); |
| 123 | + |
| 124 | + // Call OnHeightCallback to set internal height |
| 125 | + cut.InvokeAsync(() => cut.Instance.OnHeightCallback(36.59375)); |
| 126 | + |
| 127 | + // The StyleName property should use dots, not commas, even in Turkish culture |
| 128 | + var styleElement = cut.Find("ul.time-spinner-list"); |
| 129 | + var style = styleElement.GetAttribute("style"); |
| 130 | + |
| 131 | + // CSS should use dots for decimal values, not commas |
| 132 | + Assert.Contains(".", style); |
| 133 | + Assert.DoesNotContain(",", style); |
| 134 | + |
| 135 | + // Should contain valid translateY with dot decimal separator |
| 136 | + Assert.Matches(@"transform:\s*translateY\(-?\d+\.\d*px\);", style); |
| 137 | + } |
| 138 | + finally |
| 139 | + { |
| 140 | + // Restore original culture |
| 141 | + CultureInfo.CurrentCulture = originalCulture; |
| 142 | + CultureInfo.CurrentUICulture = originalUICulture; |
| 143 | + } |
| 144 | + } |
101 | 145 | } |
0 commit comments