diff --git a/src/Htmx.Tests/Giraffe.Htmx.Tests.fsproj b/src/Htmx.Tests/Giraffe.Htmx.Tests.fsproj
index 768b74c..a9d2f4e 100644
--- a/src/Htmx.Tests/Giraffe.Htmx.Tests.fsproj
+++ b/src/Htmx.Tests/Giraffe.Htmx.Tests.fsproj
@@ -13,7 +13,9 @@
+
+
runtime; build; native; contentfiles; analyzers; buildtransitive
@@ -25,4 +27,8 @@
+
+
+
+
diff --git a/src/Htmx.Tests/Tests.fs b/src/Htmx.Tests/Tests.fs
index b908e37..29c002e 100644
--- a/src/Htmx.Tests/Tests.fs
+++ b/src/Htmx.Tests/Tests.fs
@@ -1,8 +1,75 @@
-module Tests
+module Giraffe.Htmx.Tests
open System
+open Giraffe.Htmx
+open Microsoft.AspNetCore.Http
+open NSubstitute
open Xunit
-[]
-let ``My test`` () =
- Assert.True(true)
+/// Tests for the IHeaderDictionary extension properties
+module IHeaderDictionaryExtensions =
+
+ []
+ let ``HxBoosted succeeds when the header is not present`` () =
+ let ctx = Substitute.For ()
+ ctx.Request.Headers.ReturnsForAnyArgs (HeaderDictionary ()) |> ignore
+ Option.isNone ctx.Request.Headers.HxBoosted |> Assert.True
+
+ []
+ let ``HxBoosted succeeds when the header is present and true`` () =
+ let ctx = Substitute.For ()
+ let dic = HeaderDictionary ()
+ dic.Add ("HX-Boosted", "true")
+ ctx.Request.Headers.ReturnsForAnyArgs dic |> ignore
+ Option.isSome ctx.Request.Headers.HxBoosted |> Assert.True
+ Option.get ctx.Request.Headers.HxBoosted |> Assert.True
+
+ []
+ let ``HxBoosted succeeds when the header is present and false`` () =
+ let ctx = Substitute.For ()
+ let dic = HeaderDictionary ()
+ dic.Add ("HX-Boosted", "false")
+ ctx.Request.Headers.ReturnsForAnyArgs dic |> ignore
+ Option.isSome ctx.Request.Headers.HxBoosted |> Assert.True
+ Option.get ctx.Request.Headers.HxBoosted |> Assert.False
+
+ []
+ let ``HxCurrentUrl succeeds when the header is not present`` () =
+ let ctx = Substitute.For ()
+ ctx.Request.Headers.ReturnsForAnyArgs (HeaderDictionary ()) |> ignore
+ Option.isNone ctx.Request.Headers.HxCurrentUrl |> Assert.True
+
+ []
+ let ``HxCurrentUrl succeeds when the header is present`` () =
+ let ctx = Substitute.For ()
+ let dic = HeaderDictionary ()
+ dic.Add ("HX-Current-URL", "http://localhost/test.htm")
+ ctx.Request.Headers.ReturnsForAnyArgs dic |> ignore
+ Option.isSome ctx.Request.Headers.HxCurrentUrl |> Assert.True
+ Assert.Equal (Uri "http://localhost/test.htm", Option.get ctx.Request.Headers.HxCurrentUrl)
+
+ []
+ let ``HxHistoryRestoreRequest succeeds when the header is not present`` () =
+ let ctx = Substitute.For ()
+ ctx.Request.Headers.ReturnsForAnyArgs (HeaderDictionary ()) |> ignore
+ Option.isNone ctx.Request.Headers.HxHistoryRestoreRequest |> Assert.True
+
+ []
+ let ``HxHistoryRestoreRequest succeeds when the header is present and true`` () =
+ let ctx = Substitute.For ()
+ let dic = HeaderDictionary ()
+ dic.Add ("HX-History-Restore-Request", "true")
+ ctx.Request.Headers.ReturnsForAnyArgs dic |> ignore
+ Option.isSome ctx.Request.Headers.HxHistoryRestoreRequest |> Assert.True
+ Option.get ctx.Request.Headers.HxHistoryRestoreRequest |> Assert.True
+
+ []
+ let ``HxHistoryRestoreRequest succeeds when the header is present and false`` () =
+ let ctx = Substitute.For ()
+ let dic = HeaderDictionary ()
+ dic.Add ("HX-History-Restore-Request", "false")
+ ctx.Request.Headers.ReturnsForAnyArgs dic |> ignore
+ Option.isSome ctx.Request.Headers.HxHistoryRestoreRequest |> Assert.True
+ Option.get ctx.Request.Headers.HxHistoryRestoreRequest |> Assert.False
+
+