apexcharts / Blazor-ApexCharts

A blazor wrapper for ApexCharts.js
https://apexcharts.github.io/Blazor-ApexCharts
MIT License
749 stars 88 forks source link

How to write Unit Tests for Apex Charts #479

Open HarshitDubey-Raik opened 1 week ago

HarshitDubey-Raik commented 1 week ago

I am making use of Apex Chart. But could you please tell how to write unit test for the same?

Following is my code for reference

<MudGrid Class="pt-5">
    <MudItem md="4" sm="12" xs="12">
        <MudPaper Outlined="true" Height="30vh">
            <ApexChart Title="Work Load" TItem="LoadDto" OnDataPointSelection="WorkLoadClicked" Options="donutOptions" Height="@_heightFull">
                @if (loadallCounts is not null)
                {
                    <ApexPointSeries TItem="LoadDto"
                                     Items="overallCounts.Where(c => c.IsPending == false)"
                                     SeriesType="SeriesType.Donut"
                                     XValue="@(e => (WorkType)e.WorkType)"
                                     YAggregate="@(e => e.Sum(x => x.NumberOfWorkers))"
                                     OrderBy="e => e.X"
                                     ShowDataLabels />
                }
            </ApexChart>
        </MudPaper>
    </MudItem>
</MudGrid>

@code {
private IEnumerable<WorkLoadCountsDto>? loadallCounts;

  private void WorkLoadClicked()
  {
      /*Code Content*/
  }
}

I am making use of Bunit to write Unit Test.