Add user progress dashboard
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using QuestionsApi.Services;
|
||||
using Xunit;
|
||||
|
||||
namespace QuestionsApi.Tests;
|
||||
|
||||
public sealed class DashboardTests
|
||||
{
|
||||
[Fact]
|
||||
public void PercentageRoundsToNearestWholeNumber()
|
||||
{
|
||||
Assert.Equal(67, DashboardStore.Percentage(2, 3));
|
||||
Assert.Equal(0, DashboardStore.Percentage(0, 0));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StreakIncludesYesterdayWhenUserHasNotStudiedToday()
|
||||
{
|
||||
var today = new DateTime(2026, 7, 18, 0, 0, 0, DateTimeKind.Utc);
|
||||
var dates = new[] { today.AddDays(-1), today.AddDays(-2), today.AddDays(-3), today.AddDays(-5) };
|
||||
Assert.Equal(3, DashboardStore.CalculateCurrentStreak(dates, today));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void StreakStopsAtFirstMissingDay()
|
||||
{
|
||||
var today = new DateTime(2026, 7, 18, 0, 0, 0, DateTimeKind.Utc);
|
||||
var dates = new[] { today, today.AddDays(-1), today.AddDays(-3) };
|
||||
Assert.Equal(2, DashboardStore.CalculateCurrentStreak(dates, today));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user