Skip to content

Commit

Permalink
Unit Test selected item
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander van Delft committed Dec 16, 2024
1 parent 80befdd commit 20837c6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions COMET.Web.Common.Tests/Components/CardView/CardViewTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ namespace COMET.Web.Common.Tests.Components.CardView

using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualStudio.TestPlatform.Common.Utilities;

using NUnit.Framework;

Expand Down Expand Up @@ -278,6 +279,39 @@ public void VerifyComponentRerenders()
});
}

[Test]
public void VerifySelectComponent()
{
var component = this.context.RenderComponent<CardView<TestClass>>(parameters =>
{
parameters
.Add(p => p.Items, this.testClasses)
.Add(p => p.ItemSize, 150)
.Add(p => p.ItemTemplate, NormalTemplate());
});

var cardView = component;

Assert.Multiple(() =>
{
Assert.That(cardView.Instance.AllowSort, Is.True);
Assert.That(cardView.Instance.AllowSearch, Is.True);
Assert.That(cardView.Instance.ItemSize, Is.EqualTo(150));
Assert.That(cardView.Instance.SearchFields, Is.EquivalentTo(new[] { "Id", "Name" }));
Assert.That(cardView.Instance.SortFields, Is.EquivalentTo(new[] { string.Empty, "Id", "Name" }));
});

var firstCardField = component.Find(".card");
firstCardField.Click();

var selectedCardField = component.Find(".selected");

Assert.Multiple(() =>
{
Assert.That(firstCardField.InnerHtml, Is.EqualTo(selectedCardField.InnerHtml));
});
}

/// <summary>
/// Configure the <see cref="BunitJSInterop" /> for DevExpress
/// </summary>
Expand Down

0 comments on commit 20837c6

Please sign in to comment.