27 lines
1003 B
C#
27 lines
1003 B
C#
using Bunit;
|
|
using Duempelkas.App.Components;
|
|
using Xunit;
|
|
|
|
namespace Duempelkas.Tests;
|
|
|
|
public class BookingDateInputTests
|
|
{
|
|
[Fact]
|
|
public void DateIsValidatedOnLeavingField_WithoutInterruptingNativeCalendar()
|
|
{
|
|
using var context = new BunitContext();
|
|
var value = "2025-12-31";
|
|
var field = context.Render<BookingDateInput>(p => p
|
|
.Add(x => x.Value, value).Add(x => x.ValueChanged, next => value = next));
|
|
field.Find("input").Input("2026-01-01");
|
|
Assert.Equal("2025-12-31", value);
|
|
field.Find("input").Blur();
|
|
Assert.Equal("2026-01-01", value);
|
|
field.Render(p => p.Add(x => x.Value, value));
|
|
// The browser owns the edited value; avoid resetting its calendar by writing it back.
|
|
Assert.Equal("2025-12-31", field.Find("input").GetAttribute("value"));
|
|
field.Render(p => p.Add(x => x.Value, "2027-02-03"));
|
|
Assert.Equal("2027-02-03", field.Find("input").GetAttribute("value"));
|
|
}
|
|
}
|