module Giraffe.ViewEngine.Htmx.Tests open Giraffe.ViewEngine open Xunit /// Tests for the HxEncoding module module Encoding = [] let ``Form is correct`` () = Assert.Equal ("application/x-www-form-urlencoded", HxEncoding.Form) [] let ``MultipartForm is correct`` () = Assert.Equal ("multipart/form-data", HxEncoding.MultipartForm) /// Tests for the HxParams module module Params = [] let ``All is correct`` () = Assert.Equal ("*", HxParams.All) [] let ``None is correct`` () = Assert.Equal ("none", HxParams.None) [] let ``With succeeds with empty list`` () = Assert.Equal ("", HxParams.With []) [] let ``With succeeds with one list item`` () = Assert.Equal ("boo", HxParams.With [ "boo" ]) [] let ``With succeeds with multiple list items`` () = Assert.Equal ("foo,bar,baz", HxParams.With [ "foo"; "bar"; "baz" ]) [] let ``Except succeeds with empty list`` () = Assert.Equal ("not ", HxParams.Except []) [] let ``Except succeeds with one list item`` () = Assert.Equal ("not that", HxParams.Except [ "that" ]) [] let ``Except succeeds with multiple list items`` () = Assert.Equal ("not blue,green", HxParams.Except [ "blue"; "green" ]) /// Tests for the HxSwap module module Swap = [] let ``InnerHtml is correct`` () = Assert.Equal ("innerHTML", HxSwap.InnerHtml) [] let ``OuterHtml is correct`` () = Assert.Equal ("outerHTML", HxSwap.OuterHtml) [] let ``BeforeBegin is correct`` () = Assert.Equal ("beforebegin", HxSwap.BeforeBegin) [] let ``BeforeEnd is correct`` () = Assert.Equal ("beforeend", HxSwap.BeforeEnd) [] let ``AfterBegin is correct`` () = Assert.Equal ("afterbegin", HxSwap.AfterBegin) [] let ``AfterEnd is correct`` () = Assert.Equal ("afterend", HxSwap.AfterEnd) [] let ``None is correct`` () = Assert.Equal ("none", HxSwap.None) /// Tests for the HxTrigger module module Trigger = [] let ``Click is correct`` () = Assert.Equal ("click", HxTrigger.Click) [] let ``Load is correct`` () = Assert.Equal ("load", HxTrigger.Load) [] let ``Filter.Alt succeeds`` () = Assert.Equal ("click[altKey]", HxTrigger.Filter.Alt HxTrigger.Click) [] let ``Filter.Ctrl succeeds`` () = Assert.Equal ("click[ctrlKey]", HxTrigger.Filter.Ctrl HxTrigger.Click) [] let ``Filter.Shift succeeds`` () = Assert.Equal ("click[shiftKey]", HxTrigger.Filter.Shift HxTrigger.Click) [] let ``Filter.CtrlAlt succeeds`` () = Assert.Equal ("click[ctrlKey&&altKey]", HxTrigger.Filter.CtrlAlt HxTrigger.Click) [] let ``Filter.CtrlShift succeeds`` () = Assert.Equal ("click[ctrlKey&&shiftKey]", HxTrigger.Filter.CtrlShift HxTrigger.Click) [] let ``Filter.CtrlAltShift succeeds`` () = Assert.Equal ("click[ctrlKey&&altKey&&shiftKey]", HxTrigger.Filter.CtrlAltShift HxTrigger.Click) [] let ``Filter.AltShift succeeds`` () = Assert.Equal ("click[altKey&&shiftKey]", HxTrigger.Filter.AltShift HxTrigger.Click) /// Tests for the HtmxAttrs module module Attributes = /// Pipe-able assertion for a rendered node let shouldRender expected node = Assert.Equal (expected, RenderView.AsString.htmlNode node) [] let ``_hxBoost succeeds`` () = div [ _hxBoost ] [] |> shouldRender """
""" [] let ``_hxConfirm succeeds`` () = button [ _hxConfirm "REALLY?!?" ] [] |> shouldRender """""" [] let ``_hxDelete succeeds`` () = span [ _hxDelete "/this-endpoint" ] [] |> shouldRender """""" [] let ``_hxDisable succeeds`` () = p [ _hxDisable ] [] |> shouldRender """

""" [] let ``_hxEncoding succeeds`` () = form [ _hxEncoding "utf-7" ] [] |> shouldRender """
""" [] let ``_hxExt succeeds`` () = section [ _hxExt "extendme" ] [] |> shouldRender """
""" [] let ``_hxGet succeeds`` () = article [ _hxGet "/the-text" ] [] |> shouldRender """
""" [] let ``_hxHeaders succeeds`` () = figure [ _hxHeaders """{ "X-Special-Header": "some-header" }""" ] [] |> shouldRender """
""" [] let ``_hxHistoryElt succeeds`` () = table [ _hxHistoryElt ] [] |> shouldRender """
""" [] let ``_hxInclude succeeds`` () = a [ _hxInclude ".extra-stuff" ] [] |> shouldRender """""" [] let ``_hxIndicator succeeds`` () = aside [ _hxIndicator "#spinner" ] [] |> shouldRender """""" [] let ``_hxNoBoost succeeds`` () = td [ _hxNoBoost ] [] |> shouldRender """""" [] let ``_hxParams succeeds`` () = br [ _hxParams "[p1,p2]" ] |> shouldRender """
""" [] let ``_hxPatch succeeds`` () = div [ _hxPatch "/arrrgh" ] [] |> shouldRender """
""" [] let ``_hxPost succeeds`` () = hr [ _hxPost "/hear-ye-hear-ye" ] |> shouldRender """
""" [] let ``_hxPreserve succeeds`` () = img [ _hxPreserve ] |> shouldRender """""" [] let ``_hxPrompt succeeds`` () = strong [ _hxPrompt "Who goes there?" ] [] |> shouldRender """""" [] let ``_hxPushUrl succeeds`` () = dl [ _hxPushUrl ] [] |> shouldRender """
""" [] let ``_hxPut succeeds`` () = s [ _hxPut "/take-this" ] [] |> shouldRender """""" [] let ``_hxRequest succeeds`` () = u [ _hxRequest "noHeaders" ] [] |> shouldRender """""" [] let ``_hxSelect succeeds`` () = nav [ _hxSelect "#navbar" ] [] |> shouldRender """""" [] let ``_hxSse succeeds`` () = footer [ _hxSse "connect:/my-events" ] [] |> shouldRender """
""" [] let ``_hxSwap succeeds`` () = del [ _hxSwap "innerHTML" ] [] |> shouldRender """""" [] let ``_hxSwapOob succeeds`` () = li [ _hxSwapOob "true" ] [] |> shouldRender """
  • """ [] let ``_hxTarget succeeds`` () = header [ _hxTarget "#somewhereElse" ] [] |> shouldRender """
    """ [] let ``_hxTrigger succeeds`` () = figcaption [ _hxTrigger "load" ] [] |> shouldRender """
    """ [] let ``_hxVals succeeds`` () = dt [ _hxVals """{ "extra": "values" }""" ] [] |> shouldRender """
    """ [] let ``_hxWs succeeds`` () = ul [ _hxWs "connect:/web-socket" ] [] |> shouldRender """
      """