diff --git a/COMET.Web.Common.Tests/Components/LoginTestFixture.cs b/COMET.Web.Common.Tests/Components/LoginTestFixture.cs index 8b77dc06..ca7e864e 100644 --- a/COMET.Web.Common.Tests/Components/LoginTestFixture.cs +++ b/COMET.Web.Common.Tests/Components/LoginTestFixture.cs @@ -25,6 +25,8 @@ namespace COMET.Web.Common.Tests.Components { + using AngleSharp.Dom; + using Bunit; using COMET.Web.Common.Components; @@ -36,8 +38,9 @@ namespace COMET.Web.Common.Tests.Components using COMET.Web.Common.ViewModels.Components; using Microsoft.AspNetCore.Components.Forms; + using Microsoft.AspNetCore.Components.Web; using Microsoft.Extensions.DependencyInjection; - + using Microsoft.JSInterop; using Moq; using NUnit.Framework; @@ -70,6 +73,36 @@ public void Teardown() this.context.CleanContext(); } + [Test] + public async Task VerifyFocusingAndBluring() + { + var renderer = this.context.RenderComponent(); + + Assert.That(renderer.Instance.FieldsFocusedStatus, Is.EqualTo(new Dictionary() + { + { "SourceAddress", false }, + { "UserName", false }, + { "Password", false } + })); + + Assert.IsFalse(renderer.Instance.FieldsFocusedStatus["UserName"]); + const string fieldToFocusOn = "Username"; + + renderer.Instance.HandleFieldFocus(fieldToFocusOn); + + foreach (var fieldStatus in renderer.Instance.FieldsFocusedStatus) + { + Assert.That(fieldStatus.Value, fieldStatus.Key == fieldToFocusOn ? Is.True : Is.False); + } + + renderer.Instance.HandleFieldBlur(fieldToFocusOn); + + foreach (var fieldStatus in renderer.Instance.FieldsFocusedStatus) + { + Assert.That(fieldStatus.Value, Is.False); + } + } + [Test] public async Task VerifyPerformLogin() { diff --git a/COMET.Web.Common/Components/Login.razor b/COMET.Web.Common/Components/Login.razor index 3cbbe3a5..938e9948 100644 --- a/COMET.Web.Common/Components/Login.razor +++ b/COMET.Web.Common/Components/Login.razor @@ -62,8 +62,6 @@ - -