< Summary

Information
Class: Pomodoro.Web.Components.HistoryTabs
Assembly: Pomodoro.Web
File(s): /home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Components/HistoryTabs.razor
Line coverage
100%
Covered lines: 29
Uncovered lines: 0
Coverable lines: 29
Total lines: 64
Line coverage: 100%
Branch coverage
100%
Covered branches: 24
Total branches: 24
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
BuildRenderTree(...)100%1212100%
get_ActiveTab()100%11100%
get_OnTabChanged()100%11100%
OnDailyTabClick()100%22100%
OnWeeklyTabClick()100%22100%
OnKeyDown()100%88100%

File(s)

/home/runner/work/Pomodoro/Pomodoro/src/Pomodoro.Web/Components/HistoryTabs.razor

#LineLine coverage
 1@using Microsoft.AspNetCore.Components
 2@using Pomodoro.Web.Models
 3
 4<div class="history-tabs" role="tablist">
 5    <button class="history-tab @(ActiveTab == HistoryTab.Daily ? Constants.UI.HistoryTabActiveClass : "")"
 6            @onclick="OnDailyTabClick"
 7            @onkeydown="OnKeyDown"
 8            aria-selected="@(ActiveTab == HistoryTab.Daily ? "true" : "false")"
 9            role="tab"
 10            tabindex="@(ActiveTab == HistoryTab.Daily ? "0" : "-1")"
 11            id="daily-tab">
 12412        @Constants.History.DailyTabLabel
 13    </button>
 14    <button class="history-tab @(ActiveTab == HistoryTab.Weekly ? Constants.UI.HistoryTabActiveClass : "")"
 15            @onclick="OnWeeklyTabClick"
 16            @onkeydown="OnKeyDown"
 17            aria-selected="@(ActiveTab == HistoryTab.Weekly ? "true" : "false")"
 18            role="tab"
 19            tabindex="@(ActiveTab == HistoryTab.Weekly ? "0" : "-1")"
 20            id="weekly-tab">
 12421        @Constants.History.WeeklyTabLabel
 22    </button>
 23</div>
 24
 25@code {
 26    [Parameter]
 88127    public HistoryTab ActiveTab { get; set; }
 28
 29    [Parameter]
 11630    public EventCallback<HistoryTab> OnTabChanged { get; set; }
 31
 32    protected void OnDailyTabClick()
 333    {
 334        if (ActiveTab != HistoryTab.Daily)
 235        {
 236            ActiveTab = HistoryTab.Daily;
 237            OnTabChanged.InvokeAsync(HistoryTab.Daily);
 238        }
 339    }
 40
 41    protected void OnWeeklyTabClick()
 442    {
 443        if (ActiveTab != HistoryTab.Weekly)
 444        {
 445            ActiveTab = HistoryTab.Weekly;
 446            OnTabChanged.InvokeAsync(HistoryTab.Weekly);
 447        }
 448    }
 49
 50    protected async Task OnKeyDown(KeyboardEventArgs e)
 351    {
 352        if (e.Key == Constants.Keys.ArrowLeft || e.Key == Constants.Keys.ArrowRight)
 253        {
 54            // Switch to the other tab
 255            var newTab = ActiveTab == HistoryTab.Daily ? HistoryTab.Weekly : HistoryTab.Daily;
 56
 257            if (ActiveTab != newTab)
 258            {
 259                ActiveTab = newTab;
 260                await OnTabChanged.InvokeAsync(newTab);
 261            }
 262        }
 363    }
 64}