-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a7874a
commit 3db6d36
Showing
6 changed files
with
115 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
defmodule FrancisHtmxTest do | ||
use ExUnit.Case | ||
alias FrancisHtmx | ||
|
||
describe "htmx/1" do | ||
test "renders html content with htmx loaded and renders assigns" do | ||
body = Req.get!("/", plug: FrancisHtmxTestHandler).body | ||
html = Floki.parse_document!(body) | ||
|
||
assert html | ||
|> Floki.find("script") | ||
|> Floki.attribute("src") == ["https://unpkg.com/htmx.org/dist/htmx.js"] | ||
|
||
assert html | ||
|> Floki.find("body") | ||
|> Floki.find("div") | ||
|> Floki.text() == "test" | ||
end | ||
end | ||
end | ||
|
||
defmodule FrancisHtmxTestHandler do | ||
use Francis | ||
import FrancisHtmx | ||
|
||
htmx(fn _ -> | ||
assigns = %{title: "test"} | ||
|
||
~E""" | ||
<div><%= @title %></div> | ||
""" | ||
end) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
defmodule Support.RouteTester do | ||
@moduledoc """ | ||
Generates test modules with Francis to test routes in isolation | ||
""" | ||
def generate_module(mod, handlers, plugs \\ []) do | ||
ast = | ||
quote context: mod do | ||
defmodule unquote(mod) do | ||
use Francis, plugs: unquote(plugs) | ||
import FrancisHtmx | ||
unquote(handlers) | ||
end | ||
end | ||
|
||
Code.compile_quoted(ast) | ||
mod | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ExUnit.start() |