Sync attrs/hdrs with upstream
This commit is contained in:
+53
-21
@@ -1,6 +1,7 @@
|
||||
module ViewEngine
|
||||
|
||||
open Expecto
|
||||
open Giraffe.Htmx
|
||||
open Giraffe.ViewEngine
|
||||
open Giraffe.ViewEngine.Htmx
|
||||
|
||||
@@ -129,6 +130,14 @@ let hxEvent =
|
||||
Expect.equal (AfterRequest.ToHxOnString()) "after:request" "AfterRequest hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "AfterSettle" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string AfterSettle) "afterSettle" "AfterSettle event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal (AfterSettle.ToHxOnString()) "after:settle" "AfterSettle hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "AfterSseMessage" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string AfterSseMessage) "afterSseMessage" "AfterSseMessage event name not correct"
|
||||
@@ -184,6 +193,15 @@ let hxEvent =
|
||||
Expect.equal (BeforeInit.ToHxOnString()) "before:init" "BeforeInit hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "BeforeProcess" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string BeforeProcess) "beforeProcess" "BeforeProcess event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal
|
||||
(BeforeProcess.ToHxOnString()) "before:process" "BeforeProcess hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "BeforeRestoreHistory" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal
|
||||
@@ -205,6 +223,15 @@ let hxEvent =
|
||||
(BeforeRequest.ToHxOnString()) "before:request" "BeforeRequest hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "BeforeResponse" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string BeforeResponse) "beforeResponse" "BeforeResponse event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal
|
||||
(BeforeResponse.ToHxOnString()) "before:response" "BeforeResponse hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "BeforeSseMessage" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string BeforeSseMessage) "beforeSseMessage" "BeforeSseMessage event name not correct"
|
||||
@@ -279,6 +306,15 @@ let hxEvent =
|
||||
(FinallyRequest.ToHxOnString()) "finally:request" "FinallyRequest hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "ResponseError" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string ResponseError) "responseError" "ResponseError event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal
|
||||
(ResponseError.ToHxOnString()) "response:error" "ResponseError hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
]
|
||||
|
||||
/// Tests for the HxHeaders module
|
||||
@@ -572,7 +608,7 @@ let attributes =
|
||||
}
|
||||
test "_hxOnHxEvent succeeds" {
|
||||
strong [ _hxOnHxEvent BeforeSwap "changeStuff()" ] []
|
||||
|> shouldRender """<strong hx-on::before:swap="changeStuff()"></strong>"""
|
||||
|> shouldRender """<strong hx-on:htmx:before:swap="changeStuff()"></strong>"""
|
||||
}
|
||||
test "_hxPatch succeeds" {
|
||||
div [ _hxPatch "/arrrgh" ] [] |> shouldRender """<div hx-patch="/arrrgh"></div>"""
|
||||
@@ -598,6 +634,18 @@ let attributes =
|
||||
test "_hxSelectOob succeeds" {
|
||||
section [ _hxSelectOob "#oob" ] [] |> shouldRender """<section hx-select-oob="#oob"></section>"""
|
||||
}
|
||||
testList "_hxStatus" [
|
||||
test "succeeds for a full code with no action" {
|
||||
div [ _hxStatus "403" HxSwap.After "" ] [] |> shouldRender """<div hx-status:403="swap:after"></div>"""
|
||||
}
|
||||
test "succeeds for a two-digit range with action" {
|
||||
span [ _hxStatus "41" HxSwap.Before "target:main" ] []
|
||||
|> shouldRender """<span hx-status:41x="swap:before target:main"></span>"""
|
||||
}
|
||||
test "succeeds for a one-digit range with no action" {
|
||||
p [ _hxStatus "5" HxSwap.None "" ] [] |> shouldRender """<p hx-status:5xx="swap:none"></p>"""
|
||||
}
|
||||
]
|
||||
test "_hxSwap succeeds" {
|
||||
del [ _hxSwap "innerHTML" ] [] |> shouldRender """<del hx-swap="innerHTML"></del>"""
|
||||
}
|
||||
@@ -864,15 +912,7 @@ let hxEventObs =
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal
|
||||
(AfterProcessNode.ToHxOnString()) "after:init" "AfterProcessNode hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "AfterSettle" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string AfterSettle) "afterSettle" "AfterSettle event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal (AfterSettle.ToHxOnString()) "after:swap" "AfterSettle hx-on event name not correct"
|
||||
(AfterProcessNode.ToHxOnString()) "after:process" "AfterProcessNode hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "BeforeCleanupElement" [
|
||||
@@ -912,7 +952,7 @@ let hxEventObs =
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal
|
||||
(BeforeProcessNode.ToHxOnString()) "before:init" "BeforeProcessNode hx-on event name not correct"
|
||||
(BeforeProcessNode.ToHxOnString()) "before:process" "BeforeProcessNode hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "BeforeSend" [
|
||||
@@ -1049,14 +1089,6 @@ let hxEventObs =
|
||||
"PushedIntoHistory hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "ResponseError" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string ResponseError) "responseError" "ResponseError event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal (ResponseError.ToHxOnString()) "error" "ResponseError hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "SendError" [
|
||||
test "ToString succeeds" {
|
||||
Expect.equal (string SendError) "sendError" "SendError event name not correct"
|
||||
@@ -1144,7 +1176,7 @@ let hxEventObs =
|
||||
Expect.equal (string XhrAbort) "xhr:abort" "XhrAbort event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal (XhrAbort.ToHxOnString()) "xhr:abort" "XhrAbort hx-on event name not correct"
|
||||
Expect.equal (XhrAbort.ToHxOnString()) "error" "XhrAbort hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "XhrLoadEnd" [
|
||||
@@ -1152,7 +1184,7 @@ let hxEventObs =
|
||||
Expect.equal (string XhrLoadEnd) "xhr:loadend" "XhrLoadEnd event name not correct"
|
||||
}
|
||||
test "ToHxOnString succeeds" {
|
||||
Expect.equal (XhrLoadEnd.ToHxOnString()) "xhr:loadend" "XhrLoadEnd hx-on event name not correct"
|
||||
Expect.equal (XhrLoadEnd.ToHxOnString()) "finally:request" "XhrLoadEnd hx-on event name not correct"
|
||||
}
|
||||
]
|
||||
testList "XhrLoadStart" [
|
||||
|
||||
Reference in New Issue
Block a user