Skip to content

Commit

Permalink
increased code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
joao4all committed Oct 9, 2023
1 parent ae0ce7f commit adb4369
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion COMET.Web.Common.Tests/Components/LoginTestFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace COMET.Web.Common.Tests.Components

using NUnit.Framework;


using TestContext = Bunit.TestContext;

[TestFixture]
Expand Down Expand Up @@ -73,7 +74,37 @@ public void Teardown()
}

[Test]
public async Task VerifyFocusingAndBluring()
public async Task VerifyErrorsShown()
{
var renderer = this.context.RenderComponent<Login>();
var errorsElement = renderer.Find(".validation-errors");
var numberOfRequiredFieldsInFirstLoginTry = renderer.Instance.FieldsFocusedStatus.Count - 1;

Assert.That(errorsElement.InnerHtml, Is.Empty);

await renderer.Find("button").ClickAsync(new MouseEventArgs());
Assert.That(errorsElement.ChildElementCount, Is.EqualTo(numberOfRequiredFieldsInFirstLoginTry));

// Username input field
await renderer.Find("input").FocusAsync(new FocusEventArgs());

Assert.Multiple(() =>
{
Assert.That(renderer.Instance.FieldsFocusedStatus["UserName"], Is.True);
Assert.That(errorsElement.ChildElementCount, Is.EqualTo(numberOfRequiredFieldsInFirstLoginTry - 1));
});

await renderer.Find("input").BlurAsync(new FocusEventArgs());

Assert.Multiple(() =>
{
Assert.That(renderer.Instance.FieldsFocusedStatus["UserName"], Is.False);
Assert.That(errorsElement.ChildElementCount, Is.EqualTo(numberOfRequiredFieldsInFirstLoginTry));
});
}

[Test]
public void VerifyFocusingAndBluring()
{
var renderer = this.context.RenderComponent<Login>();

Expand Down

0 comments on commit adb4369

Please sign in to comment.