From 2da7ff240ebb34082ecb1b9cc6025358e9176e1c Mon Sep 17 00:00:00 2001 From: bgraham123 <121888320+bgraham123@users.noreply.github.com> Date: Sun, 31 Mar 2024 10:06:25 -0400 Subject: [PATCH] refactor: Update TextArea.razor.cs (#3716) * refactor: Update TextArea.razor.cs Updated TextAreaInfo to be a public class so that JSInterop calls can be setup for unit tests. Closes #3714 * refactor: Update TextArea.razor.cs Remove TextAreaInfo class from TextArea.razor.cs and define in new file with namespace AntDesign.Internal * refactor: Create TextAreaInfo.cs Remove TextAreaInfo class from TextArea.razor.cs and define in new file with namespace AntDesign.Internal * refactor: Update TextArea.razor.cs Add AntDesign.Internal using statement for TextAreaInfo class * refactor: Update TextAreaTests.razor Use the AntDesign.Internal namespace for TextAreaInfo --- components/input/TextArea.razor.cs | 11 +------ components/input/TextAreaInfo.cs | 17 +++++++++++ .../AntDesign.Tests/Input/TextAreaTests.razor | 30 +++++++++---------- 3 files changed, 33 insertions(+), 25 deletions(-) create mode 100644 components/input/TextAreaInfo.cs diff --git a/components/input/TextArea.razor.cs b/components/input/TextArea.razor.cs index 1b40ec7e..5ba4bf8b 100644 --- a/components/input/TextArea.razor.cs +++ b/components/input/TextArea.razor.cs @@ -1,6 +1,7 @@ using System.Diagnostics; using System.Text.Json; using System.Threading.Tasks; +using AntDesign.Internal; using AntDesign.JsInterop; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; @@ -325,15 +326,5 @@ namespace AntDesign StateHasChanged(); } } - - internal class TextAreaInfo - { - public double ScrollHeight { get; set; } - public double LineHeight { get; set; } - public double PaddingTop { get; set; } - public double PaddingBottom { get; set; } - public double BorderTop { get; set; } - public double BorderBottom { get; set; } - } } } diff --git a/components/input/TextAreaInfo.cs b/components/input/TextAreaInfo.cs new file mode 100644 index 00000000..fafcc96e --- /dev/null +++ b/components/input/TextAreaInfo.cs @@ -0,0 +1,17 @@ +namespace AntDesign.Internal +{ + public class TextAreaInfo + { + public double ScrollHeight { get; set; } + + public double LineHeight { get; set; } + + public double PaddingTop { get; set; } + + public double PaddingBottom { get; set; } + + public double BorderTop { get; set; } + + public double BorderBottom { get; set; } + } +} diff --git a/tests/AntDesign.Tests/Input/TextAreaTests.razor b/tests/AntDesign.Tests/Input/TextAreaTests.razor index 1b797164..0a01571c 100644 --- a/tests/AntDesign.Tests/Input/TextAreaTests.razor +++ b/tests/AntDesign.Tests/Input/TextAreaTests.razor @@ -1,6 +1,6 @@ @inherits AntDesignTestBase @code { - AntDesign.TextArea.TextAreaInfo _textAreaInfo = new AntDesign.TextArea.TextAreaInfo + AntDesign.Internal.TextAreaInfo _textAreaInfo = new AntDesign.Internal.TextAreaInfo { LineHeight = 10, PaddingTop = 1, @@ -20,7 +20,7 @@ { //Arrange JSCommonMock(); - JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) + JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) .SetResult(_textAreaInfo); string value = "0123456789"; var cut = Render( @@ -38,7 +38,7 @@ { //Arrange JSCommonMock(); - JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) + JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) .SetResult(_textAreaInfo); string value = "0123456789"; var cut = Render( @@ -57,7 +57,7 @@ { //Arrange JSCommonMock(); - JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) + JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) .SetResult(_textAreaInfo); string value = "0123456789"; var cut = Render(@); @@ -72,7 +72,7 @@ { //Arrange JSCommonMock(); - JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) + JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) .SetResult(_textAreaInfo); string value = ""; string newValue = "newValue"; @@ -92,7 +92,7 @@ { //Arrange JSCommonMock(); - JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) + JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) .SetResult(_textAreaInfo); var cut = Render(@); //Act @@ -106,7 +106,7 @@ { //Arrange JSCommonMock(); - JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) + JSInterop.Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) .SetResult(_textAreaInfo); var cut = Render(@); //Act @@ -120,7 +120,7 @@ { JSCommonMock(); JSInterop - .Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) + .Setup(JSInteropConstants.InputComponentHelper.GetTextAreaInfo, _ => true) .SetResult(_textAreaInfo); var cut = Render