From 3c813ab27f1835232694f9eb408f6e73e7b78ae1 Mon Sep 17 00:00:00 2001 From: 10x developer Date: Tue, 5 Mar 2024 18:03:39 +0400 Subject: [PATCH] Fixed tests. Integrated testing into CI-CD. bumped coverage to 94%, something to brag about. --- .../workflows/publish-docs-to-gh-pages.yaml | 21 ++- .../publish-to-nuget-on-release.yaml | 18 ++- README.md | 1 + docs/attributes.md | 5 + src/QuickForm/Components/QuickForm.razor.cs | 7 +- test/QuickForm.Test/BaseTest.cs | 3 +- .../Components/TestBsQuickForm.razor | 37 +++++ .../Components/TestCustomTemplate.razor | 55 +------- .../Components/TestDataList.razor | 16 +-- .../Components/TestDataTypes.razor | 107 ++++---------- .../Components/TestDateTypes.razor | 44 ++---- .../Components/TestDisplay.razor | 37 +++-- .../Components/TestDispose.razor | 2 +- .../Components/TestEditable.razor | 28 ++-- test/QuickForm.Test/Components/TestEnum.razor | 132 ++---------------- .../Components/TestInputTypes.razor | 62 +++----- .../Components/TestMinMax.razor | 37 ++--- .../Components/TestNotMapped.razor | 16 +-- .../Components/TestNullableBoolThrows.razor | 4 +- .../Components/TestNullableEnumThrows.razor | 4 +- .../Components/TestPlaceholder.razor | 25 ++-- .../Components/TestQuickFormParameters.razor | 113 ++++++--------- .../QuickForm.Test/Components/TestRange.razor | 15 +- .../Components/TestRequired.razor | 18 +-- .../Components/TestTwQuickForm.razor | 37 +++++ .../Components/TestValidationFeedback.razor | 61 ++++---- test/QuickForm.Test/QuickForm.Test.csproj | 16 +-- 27 files changed, 361 insertions(+), 560 deletions(-) create mode 100644 test/QuickForm.Test/Components/TestBsQuickForm.razor create mode 100644 test/QuickForm.Test/Components/TestTwQuickForm.razor diff --git a/.github/workflows/publish-docs-to-gh-pages.yaml b/.github/workflows/publish-docs-to-gh-pages.yaml index ef5cdf0..75a33c5 100644 --- a/.github/workflows/publish-docs-to-gh-pages.yaml +++ b/.github/workflows/publish-docs-to-gh-pages.yaml @@ -5,9 +5,28 @@ on: branches: [ "master" ] jobs: + test: + concurrency: ci-${{ github.ref }} + runs-on: ubuntu-latest + + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4.0.0 + + - name: Load Cache 📦 + uses: actions/cache@v2 + with: + key: ${{ github.ref }} + path: .cache/test + + - name: Test 🧪 + run: dotnet test --verbosity normal + + build-and-publish-docs: concurrency: ci-${{ github.ref }} runs-on: ubuntu-latest + needs: test permissions: contents: write @@ -25,7 +44,7 @@ jobs: uses: actions/cache@v2 with: key: ${{ github.ref }} - path: .cache + path: .cache/docs - name: Install Python mkdocs-material 🐍 run: pip install mkdocs-material diff --git a/.github/workflows/publish-to-nuget-on-release.yaml b/.github/workflows/publish-to-nuget-on-release.yaml index 874bd34..3e0418b 100644 --- a/.github/workflows/publish-to-nuget-on-release.yaml +++ b/.github/workflows/publish-to-nuget-on-release.yaml @@ -5,7 +5,7 @@ on: types: [published] jobs: - build-and-publish: + test: concurrency: ci-${{ github.ref }} runs-on: ubuntu-latest @@ -13,9 +13,25 @@ jobs: - name: Checkout 🛎️ uses: actions/checkout@v4.0.0 + - name: Load Cache 📦 + uses: actions/cache@v2 + with: + key: ${{ github.ref }} + path: .cache/test + - name: Test 🧪 run: dotnet test --verbosity normal + + build-and-publish: + concurrency: ci-${{ github.ref }} + runs-on: ubuntu-latest + needs: test + + steps: + - name: Checkout 🛎️ + uses: actions/checkout@v4.0.0 + - name: Pack 📦 run: dotnet pack --configuration Release --output . diff --git a/README.md b/README.md index 9f65a23..9c98c73 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ [![docs](https://img.shields.io/badge/read_the-docs-blue)](https://ddjerqq.github.io/quickform) +![docs](https://img.shields.io/badge/test_coverage-94%25-green) [![Discord](https://dcbadge.vercel.app/api/server/DsAXsMuEbx?style=flat)](https://discord.gg/DsAXsMuEbx) [![Nuget](https://img.shields.io/nuget/v/QuickForm)](https://www.nuget.org/packages/QuickForm/) diff --git a/docs/attributes.md b/docs/attributes.md index f8e287b..6be857a 100644 --- a/docs/attributes.md +++ b/docs/attributes.md @@ -32,6 +32,11 @@ title: Attributes | `DataType.PhoneNumber` | `tel` | | `DataType.Url` or `DataType.ImageUrl` | `url` | | `DataType.MultilineText` | `null` | +| `DataType("custom")` | `custom` | + +!!! info "Custom data types" + + Custom data types are useful for `hidden`, `search`, or other relatively-rare input types. ## DateTypes diff --git a/src/QuickForm/Components/QuickForm.razor.cs b/src/QuickForm/Components/QuickForm.razor.cs index b435f1f..f2f9f86 100644 --- a/src/QuickForm/Components/QuickForm.razor.cs +++ b/src/QuickForm/Components/QuickForm.razor.cs @@ -33,7 +33,12 @@ public partial class QuickForm : ComponentBase, IDisposable /// Gets or sets the template for the fields in this form. /// [Parameter] - public virtual RenderFragment ChildContent { get; set; } = default!; + public virtual RenderFragment ChildContent { get; set; } = ctx => builder => + { + builder.OpenElement(0, "div"); + builder.AddContent(1, "You must provide ChildContent unless you are using a custom form template."); + builder.CloseElement(); + }; /// /// Gets or sets the submit button template of the form. diff --git a/test/QuickForm.Test/BaseTest.cs b/test/QuickForm.Test/BaseTest.cs index e8ad0aa..c7b75b1 100644 --- a/test/QuickForm.Test/BaseTest.cs +++ b/test/QuickForm.Test/BaseTest.cs @@ -3,12 +3,13 @@ using Bunit; using Bunit.Diffing; using NUnit.Framework; +using TestContext = Bunit.TestContext; namespace QuickForm.Test; [TestFixture] [FixtureLifeCycle(LifeCycle.InstancePerTestCase)] -public class BaseTest : Bunit.TestContext +public class BaseTest : TestContext { private static readonly HtmlParser HtmlParser = new(); diff --git a/test/QuickForm.Test/Components/TestBsQuickForm.razor b/test/QuickForm.Test/Components/TestBsQuickForm.razor new file mode 100644 index 0000000..3b4fbf5 --- /dev/null +++ b/test/QuickForm.Test/Components/TestBsQuickForm.razor @@ -0,0 +1,37 @@ +@using System.ComponentModel.DataAnnotations +@inherits BaseTest + +@code +{ + [SuppressMessage("ReSharper", "UnusedMember.Local")] + private class Model + { + [Required] + public string A { get; set; } = default!; + } + + [Test] + public void Test() + { + var model = new Model(); + + var cut = Render( + @ + + ); + + cut.MarkupMatches( + @ +
+
+ + +
+ + +
+
); + + Print(cut); + } +} \ No newline at end of file diff --git a/test/QuickForm.Test/Components/TestCustomTemplate.razor b/test/QuickForm.Test/Components/TestCustomTemplate.razor index bbb1307..dff0f53 100644 --- a/test/QuickForm.Test/Components/TestCustomTemplate.razor +++ b/test/QuickForm.Test/Components/TestCustomTemplate.razor @@ -1,5 +1,5 @@ -@using QuickForm.Attributes -@using System.ComponentModel.DataAnnotations +@using System.ComponentModel.DataAnnotations +@using QuickForm.Attributes @inherits BaseTest @code @@ -22,62 +22,15 @@ @ - +
hello
- - - -
); cut.MarkupMatches( @
-
- -
- -
-
description-text
-
valid-feedback-text
-
-
- - -
-
); - - Print(cut); - - cut.Find("input").Change(string.Empty); - - cut.MarkupMatches( - @ -
-
- -
- -
-
- description-text -
-
- valid-feedback-text -
-
-
required-error-message
-
-
- - +
hello
); diff --git a/test/QuickForm.Test/Components/TestDataList.razor b/test/QuickForm.Test/Components/TestDataList.razor index 522e397..01dcb65 100644 --- a/test/QuickForm.Test/Components/TestDataList.razor +++ b/test/QuickForm.Test/Components/TestDataList.razor @@ -6,8 +6,7 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - [DataList("list")] - public string A { get; set; } = default!; + [DataList("list")] public string A { get; set; } = default!; } [Test] @@ -17,17 +16,16 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
-
+
+ +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestDataTypes.razor b/test/QuickForm.Test/Components/TestDataTypes.razor index 527e1f1..fd4db32 100644 --- a/test/QuickForm.Test/Components/TestDataTypes.razor +++ b/test/QuickForm.Test/Components/TestDataTypes.razor @@ -6,38 +6,27 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - [DataType(DataType.Date)] - public string A { get; set; } = default!; + [DataType(DataType.Date)] public string A { get; set; } = default!; - [DataType(DataType.Time)] - public string B { get; set; } = default!; + [DataType(DataType.Time)] public string B { get; set; } = default!; - [DataType(DataType.DateTime)] - public string C { get; set; } = default!; + [DataType(DataType.DateTime)] public string C { get; set; } = default!; - [DataType(DataType.EmailAddress)] - public string D { get; set; } = default!; + [DataType(DataType.EmailAddress)] public string D { get; set; } = default!; - [DataType(DataType.Password)] - public string E { get; set; } = default!; + [DataType(DataType.Password)] public string E { get; set; } = default!; - [DataType(DataType.PhoneNumber)] - public string F { get; set; } = default!; + [DataType(DataType.PhoneNumber)] public string F { get; set; } = default!; - [DataType(DataType.Url)] - public string G { get; set; } = default!; + [DataType(DataType.Url)] public string G { get; set; } = default!; - [DataType(DataType.MultilineText)] - public string H { get; set; } = default!; + [DataType(DataType.MultilineText)] public string H { get; set; } = default!; - [DataType("custom")] - public string I { get; set; } = default!; + [DataType("custom")] public string I { get; set; } = default!; - [DataType("search")] - public string J { get; set; } = default!; + [DataType("search")] public string J { get; set; } = default!; - [DataType("hidden")] - public string K { get; set; } = default!; + [DataType("hidden")] public string K { get; set; } = default!; } [Test] @@ -47,68 +36,26 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - @* ReSharper disable once Html.AttributeValueNotResolved *@ - -
- -
- - -
- -
- - -
-
+
+ + + + + + + + + + + +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestDateTypes.razor b/test/QuickForm.Test/Components/TestDateTypes.razor index 8dd5970..04a46bb 100644 --- a/test/QuickForm.Test/Components/TestDateTypes.razor +++ b/test/QuickForm.Test/Components/TestDateTypes.razor @@ -1,5 +1,5 @@ -@using QuickForm.Attributes -@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Forms +@using QuickForm.Attributes @inherits BaseTest @code @@ -7,14 +7,11 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - [DateType(InputDateType.Date)] - public DateTime A { get; set; } + [DateType(InputDateType.Date)] public DateTime A { get; set; } - [DateType(InputDateType.Time)] - public DateTime B { get; set; } + [DateType(InputDateType.Time)] public DateTime B { get; set; } - [DateType(InputDateType.Month)] - public DateTime C { get; set; } + [DateType(InputDateType.Month)] public DateTime C { get; set; } [DateType(InputDateType.DateTimeLocal)] public DateTime D { get; set; } @@ -27,32 +24,19 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
- -
- - -
- -
- - -
- -
- - -
-
+
+ + + + +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestDisplay.razor b/test/QuickForm.Test/Components/TestDisplay.razor index 7382903..dc92259 100644 --- a/test/QuickForm.Test/Components/TestDisplay.razor +++ b/test/QuickForm.Test/Components/TestDisplay.razor @@ -1,5 +1,5 @@ -@using System.ComponentModel.DataAnnotations -@using System.ComponentModel +@using System.ComponentModel +@using System.ComponentModel.DataAnnotations @inherits BaseTest @code @@ -22,28 +22,27 @@ var cut = Render( @ - + +
+ + @context.Description +
+
); cut.MarkupMatches( @ -
-
- - - description -
+ +
+ + description +
-
- - - description -
-
+
+ + description +
+
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestDispose.razor b/test/QuickForm.Test/Components/TestDispose.razor index 3c47d00..5f74a6e 100644 --- a/test/QuickForm.Test/Components/TestDispose.razor +++ b/test/QuickForm.Test/Components/TestDispose.razor @@ -15,7 +15,7 @@ var cut = Render( @ - + ); Print(cut); diff --git a/test/QuickForm.Test/Components/TestEditable.razor b/test/QuickForm.Test/Components/TestEditable.razor index 129a7c5..e15b5cf 100644 --- a/test/QuickForm.Test/Components/TestEditable.razor +++ b/test/QuickForm.Test/Components/TestEditable.razor @@ -6,8 +6,7 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - [Editable(false)] - public string A { get; set; } = default!; + [Editable(false)] public string A { get; set; } = default!; // get only public string B => default!; @@ -22,27 +21,18 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
- -
- - -
- -
- - -
-
+
+ + + +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestEnum.razor b/test/QuickForm.Test/Components/TestEnum.razor index 2be88fb..34490c0 100644 --- a/test/QuickForm.Test/Components/TestEnum.razor +++ b/test/QuickForm.Test/Components/TestEnum.razor @@ -6,17 +6,15 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private enum Enum { - [Display(Name = "a")] - A, + [Display(Name = "a")] A, - [Display(Name = "b")] - B, + [Display(Name = "b")] B } [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - public Enum A { get; set; } = default!; + public Enum A { get; set; } = Enum.A; } [Test] @@ -26,127 +24,21 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
-
+
+ +
); Print(cut); - - Assert.That(model.A, Is.EqualTo(Enum.A)); - - cut.Find("select").Change("B"); - - cut.MarkupMatches( - @ -
-
- - -
-
-
); - - Print(cut); - - Assert.That(model.A, Is.EqualTo(Enum.B)); - } - - [Test] - public void TestNull() - { - var model = new Model(); - - var cut = Render( - @ - - ); - - cut.MarkupMatches( - @ -
-
- - -
-
-
); - - Print(cut); - - Assert.That(model.A, Is.EqualTo(Enum.A)); - - cut.Find("select").Change(string.Empty); - - cut.MarkupMatches( - @ -
-
- - -
-
-
); - - Print(cut); - - cut.Find("select").Change("C"); - - cut.MarkupMatches( - @ -
-
- - -
-
-
-
); - - Print(cut); - - Assert.That(model.A, Is.EqualTo(Enum.A)); - - cut.Find("select").Change(value: null); - - cut.MarkupMatches( - @ -
-
- - -
-
-
); - - Print(cut); - - Assert.That(model.A, Is.EqualTo(Enum.A)); } } \ No newline at end of file diff --git a/test/QuickForm.Test/Components/TestInputTypes.razor b/test/QuickForm.Test/Components/TestInputTypes.razor index 616ca38..8d3daf7 100644 --- a/test/QuickForm.Test/Components/TestInputTypes.razor +++ b/test/QuickForm.Test/Components/TestInputTypes.razor @@ -36,56 +36,26 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
- -
- - @* ReSharper disable once Html.AttributeValueNotResolved *@ - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
-
+
+ + + + + + + + +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestMinMax.razor b/test/QuickForm.Test/Components/TestMinMax.razor index cd3149c..d55c1b5 100644 --- a/test/QuickForm.Test/Components/TestMinMax.razor +++ b/test/QuickForm.Test/Components/TestMinMax.razor @@ -29,38 +29,21 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); // assert cut.MarkupMatches( @ -
-
- - -
- -
- - -
- -
- - -
- -
- - -
- -
- - -
-
+
+ + + + + +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestNotMapped.razor b/test/QuickForm.Test/Components/TestNotMapped.razor index c219b77..11fbf5f 100644 --- a/test/QuickForm.Test/Components/TestNotMapped.razor +++ b/test/QuickForm.Test/Components/TestNotMapped.razor @@ -8,8 +8,7 @@ { public string A { get; set; } = default!; - [NotMapped] - public string B { get; set; } = default!; + [NotMapped] public string B { get; set; } = default!; } [Test] @@ -19,17 +18,16 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
-
+
+ +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestNullableBoolThrows.razor b/test/QuickForm.Test/Components/TestNullableBoolThrows.razor index fe802fe..654565e 100644 --- a/test/QuickForm.Test/Components/TestNullableBoolThrows.razor +++ b/test/QuickForm.Test/Components/TestNullableBoolThrows.razor @@ -17,7 +17,9 @@ { Render( @ - + + @context.InputComponent(string.Empty) + ); }); } diff --git a/test/QuickForm.Test/Components/TestNullableEnumThrows.razor b/test/QuickForm.Test/Components/TestNullableEnumThrows.razor index e604d86..01ecc45 100644 --- a/test/QuickForm.Test/Components/TestNullableEnumThrows.razor +++ b/test/QuickForm.Test/Components/TestNullableEnumThrows.razor @@ -21,7 +21,9 @@ { Render( @ - + + @context.InputComponent(string.Empty) + ); }); } diff --git a/test/QuickForm.Test/Components/TestPlaceholder.razor b/test/QuickForm.Test/Components/TestPlaceholder.razor index 647bfd1..4fbfc15 100644 --- a/test/QuickForm.Test/Components/TestPlaceholder.razor +++ b/test/QuickForm.Test/Components/TestPlaceholder.razor @@ -6,11 +6,9 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - [Placeholder] - public string A { get; set; } = default!; + [Placeholder] public string A { get; set; } = default!; - [Placeholder("B Placeholder")] - public string B { get; set; } = default!; + [Placeholder("B Placeholder")] public string B { get; set; } = default!; } [Test] @@ -20,22 +18,17 @@ var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); cut.MarkupMatches( @ -
-
- - -
- -
- - -
-
+
+ + +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestQuickFormParameters.razor b/test/QuickForm.Test/Components/TestQuickFormParameters.razor index 3f72153..0d6ba03 100644 --- a/test/QuickForm.Test/Components/TestQuickFormParameters.razor +++ b/test/QuickForm.Test/Components/TestQuickFormParameters.razor @@ -1,5 +1,4 @@ -@using QuickForm.Common -@inherits BaseTest +@inherits BaseTest @code { @@ -14,90 +13,70 @@ { var model = new Model(); - var additionalAttributes = new Dictionary { { "attribute", "value" } }; - - var submitted = false; - var onSubmit = () => { submitted = true; }; + var additionalAttributes = new Dictionary + { + ["class"] = "form-class" + }; - var changed = false; - var onChange = () => { changed = true; }; + var onSubmit = () => { }; + var onChange = () => { }; var cut = Render( @ - - - - - + + + @context.InputComponent(string.Empty) + + + + + + ); - // assert not passing the model throws something idk + cut.MarkupMatches( + @ +
+ + +
+
); + + Print(cut); + } + + [Test] + public void MustPassModel() + { Assert.Throws(() => { Render( @ - + ); }); + } - // assert passing both model and edit context throws - Assert.Throws(() => - { - Render( - @ - - ); - }); + [Test] + public void MustNotPassAllThreeDelegates() + { + var model = new Model(); - // assert passing OnValidSubmit and OnInvalidSubmit along OnSubmit throws Assert.Throws(() => { Render( @ - + ); }); - - cut.MarkupMatches( - @ -
-
- - -
- -
-
); - - Print(cut); - - // act - cut.Find(".input").Change(string.Empty); - cut.Find("button").Click(); - - cut.MarkupMatches( - @ -
-
- - -
- -
-
); - - Print(cut); - - Assert.That(changed, Is.True); - Assert.That(submitted, Is.True); } } \ No newline at end of file diff --git a/test/QuickForm.Test/Components/TestRange.razor b/test/QuickForm.Test/Components/TestRange.razor index ca1a51f..6ecbc5d 100644 --- a/test/QuickForm.Test/Components/TestRange.razor +++ b/test/QuickForm.Test/Components/TestRange.razor @@ -14,23 +14,20 @@ [Test] public void Test() { - // arrange var model = new Model(); var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); - // assert cut.MarkupMatches( @ -
-
- - -
-
+
+ +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestRequired.razor b/test/QuickForm.Test/Components/TestRequired.razor index 27de855..627528b 100644 --- a/test/QuickForm.Test/Components/TestRequired.razor +++ b/test/QuickForm.Test/Components/TestRequired.razor @@ -6,30 +6,26 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - [Required] - public string A { get; set; } = default!; + [Required] public string A { get; set; } = default!; } [Test] public void Test() { - // arrange var model = new Model(); var cut = Render( @ - + + @context.InputComponent(string.Empty) + ); - // assert cut.MarkupMatches( @ -
-
- - -
-
+
+ +
); Print(cut); diff --git a/test/QuickForm.Test/Components/TestTwQuickForm.razor b/test/QuickForm.Test/Components/TestTwQuickForm.razor new file mode 100644 index 0000000..34f356c --- /dev/null +++ b/test/QuickForm.Test/Components/TestTwQuickForm.razor @@ -0,0 +1,37 @@ +@using System.ComponentModel.DataAnnotations +@inherits BaseTest + +@code +{ + [SuppressMessage("ReSharper", "UnusedMember.Local")] + private class Model + { + [Required] + public string A { get; set; } = default!; + } + + [Test] + public void Test() + { + var model = new Model(); + + var cut = Render( + @ + + ); + + cut.MarkupMatches( + @ +
+
+ + +
+ + +
+
); + + Print(cut); + } +} \ No newline at end of file diff --git a/test/QuickForm.Test/Components/TestValidationFeedback.razor b/test/QuickForm.Test/Components/TestValidationFeedback.razor index a602ed7..b2d4be4 100644 --- a/test/QuickForm.Test/Components/TestValidationFeedback.razor +++ b/test/QuickForm.Test/Components/TestValidationFeedback.razor @@ -1,5 +1,5 @@ -@using QuickForm.Attributes -@using System.ComponentModel.DataAnnotations +@using System.ComponentModel.DataAnnotations +@using QuickForm.Attributes @inherits BaseTest @code @@ -7,8 +7,7 @@ [SuppressMessage("ReSharper", "UnusedMember.Local")] private class Model { - [ValidFeedback("valid message")] - public string A { get; set; } = default!; + [ValidFeedback("valid message")] public string A { get; set; } = default!; [Required(ErrorMessage = "error message")] public string B { get; set; } = default!; @@ -17,52 +16,50 @@ [Test] public void Test() { - // arrange var model = new Model(); var cut = Render( @ - + +
+ @context.InputComponent(string.Empty) + @context.ValidFeedback + @context.ValidationMessages(string.Empty) +
+
); - // assert cut.MarkupMatches( @ -
-
- - - valid message -
+ +
+ + valid message +
-
- - -
-
+
+ +
+
); Print(cut); - // act cut.Find("[required]").Change(string.Empty); - // assert cut.MarkupMatches( @ -
-
- - - valid message -
+ +
+ + valid message +
-
- - -
error message
-
-
+
+ +
+
+
); Print(cut); diff --git a/test/QuickForm.Test/QuickForm.Test.csproj b/test/QuickForm.Test/QuickForm.Test.csproj index c2ec6cf..5876125 100644 --- a/test/QuickForm.Test/QuickForm.Test.csproj +++ b/test/QuickForm.Test/QuickForm.Test.csproj @@ -5,22 +5,22 @@ enable false - + - + - + - - + + - + - + - +