From fae6904046e4927b5fb21cd0271455873e340c15 Mon Sep 17 00:00:00 2001 From: Egil Hansen Date: Mon, 29 Apr 2024 13:38:15 +0000 Subject: [PATCH] tests: validate hx-vals, hx-headers, hx-on works --- .../Components/Pages/Home.razor | 9 +++++ .../Components/Pages/HxHeaders.razor | 2 ++ .../Components/Pages/HxOn.razor | 26 +++++++++++++++ .../Components/Pages/HxVals.razor | 6 ++++ test/Htmxor.Tests/DemoTestCases/HxValsTest.cs | 33 +++++++++++++++++++ 5 files changed, 76 insertions(+) create mode 100644 test/Htmxor.TestApp/Components/Pages/HxHeaders.razor create mode 100644 test/Htmxor.TestApp/Components/Pages/HxOn.razor create mode 100644 test/Htmxor.TestApp/Components/Pages/HxVals.razor create mode 100644 test/Htmxor.Tests/DemoTestCases/HxValsTest.cs diff --git a/test/Htmxor.TestApp/Components/Pages/Home.razor b/test/Htmxor.TestApp/Components/Pages/Home.razor index a1065ab..14b8840 100644 --- a/test/Htmxor.TestApp/Components/Pages/Home.razor +++ b/test/Htmxor.TestApp/Components/Pages/Home.razor @@ -133,5 +133,14 @@ Htmxor. Redirect using Nav Man + + hx-vals-escaped + + + hx-on + + + hx-headers-escaped + \ No newline at end of file diff --git a/test/Htmxor.TestApp/Components/Pages/HxHeaders.razor b/test/Htmxor.TestApp/Components/Pages/HxHeaders.razor new file mode 100644 index 0000000..97cf077 --- /dev/null +++ b/test/Htmxor.TestApp/Components/Pages/HxHeaders.razor @@ -0,0 +1,2 @@ +@page "/hx-headers-escaped" + \ No newline at end of file diff --git a/test/Htmxor.TestApp/Components/Pages/HxOn.razor b/test/Htmxor.TestApp/Components/Pages/HxOn.razor new file mode 100644 index 0000000..cc02741 --- /dev/null +++ b/test/Htmxor.TestApp/Components/Pages/HxOn.razor @@ -0,0 +1,26 @@ +@page "/hx-on" +
Click
+ + + + + + + + + + + + diff --git a/test/Htmxor.TestApp/Components/Pages/HxVals.razor b/test/Htmxor.TestApp/Components/Pages/HxVals.razor new file mode 100644 index 0000000..f061980 --- /dev/null +++ b/test/Htmxor.TestApp/Components/Pages/HxVals.razor @@ -0,0 +1,6 @@ +@page "/hx-vals-escaped" + \ No newline at end of file diff --git a/test/Htmxor.Tests/DemoTestCases/HxValsTest.cs b/test/Htmxor.Tests/DemoTestCases/HxValsTest.cs new file mode 100644 index 0000000..bc1bdfe --- /dev/null +++ b/test/Htmxor.Tests/DemoTestCases/HxValsTest.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Text; +using System.Threading.Tasks; + +namespace Htmxor.DemoTestCases; + +public class HxValsTest : TestAppTestBase +{ + public HxValsTest(TestAppFixture fixture) : base(fixture) + { + } + + [Fact] + public async Task HxVals_correctly_escaped_by_renderer() + { + await Host.Scenario(s => + { + s.Get.Url("/hx-vals-escaped"); + + s.StatusCodeShouldBe(HttpStatusCode.OK); + s.ContentShouldBeHtml(FullPageContent($$""" + + """)); + }); + } +}