Skip to content

Commit

Permalink
Merge pull request #107 from danheron/feature/set-current-day
Browse files Browse the repository at this point in the history
Allow setting of CurrentDay during initialization
  • Loading branch information
danheron authored Apr 26, 2024
2 parents 50b97ea + 480e7f2 commit d927d52
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<MudCalendar @bind-CurrentDay="@_currentDay" />

@code {

public static string __description__ = "CurrentDay Tests";

private DateTime _currentDay = new DateTime(2024, 2, 12);

}
10 changes: 10 additions & 0 deletions Heron.MudCalendar.UnitTests/Components/CalendarTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -384,4 +384,14 @@ public void ClockType()
comp.SetParam(x => x.Use24HourClock, false);
comp.FindAll("td.mud-cal-time-cell")[18].TextContent.Trim().ToLower().Should().Be("6 pm");
}

[Test]
public void CurrentDayTest()
{
var cut = Context.RenderComponent<CalendarCurrentDayTest>();
var comp = cut.FindComponent<MudCalendar>();

// Check that current month is Feb 2024
comp.FindAll(".mud-cal-month-dropzone")[0].Attributes["identifier"]!.TextContent.Should().Be("29/01/2024");
}
}
5 changes: 4 additions & 1 deletion Heron.MudCalendar/Components/MudCalendar.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,10 @@ private DateTime? PickerDate

protected override void OnInitialized()
{
CurrentDay = DateTime.Today;
if (CurrentDay == default)
{
CurrentDay = DateTime.Today;
}
}

protected override void OnParametersSet()
Expand Down

0 comments on commit d927d52

Please sign in to comment.