Skip to content

Commit

Permalink
Ensure test module can run
Browse files Browse the repository at this point in the history
  • Loading branch information
bcardarella committed Nov 1, 2024
1 parent a1a02b7 commit 07605ff
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 19 deletions.
4 changes: 2 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ defmodule LiveViewNative.SwiftUI.MixProject do
{:makeup_json, "~> 0.1.0", only: [:docs, :test]},
{:makeup_eex, ">= 0.1.1"},
{:floki, ">= 0.30.0", only: :test},
{:live_view_native, "~> 0.3.1"},
{:live_view_native, github: "liveview-native/live_view_native", override: true},
{:live_view_native_stylesheet, "~> 0.3.1", only: :test},
{:live_view_native_live_form, "~> 0.3.1", only: :test},
{:live_view_native_live_form, github: "liveview-native/liveview-native-live-form", only: :test},
{:gettext, "~> 0.20", only: :test},
{:live_view_native_test, github: "liveview-native/live_view_native_test", branch: "main", only: :test},
{:nimble_parsec, "~> 1.3"}
Expand Down
8 changes: 4 additions & 4 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"earmark_parser": {:hex, :earmark_parser, "1.4.41", "ab34711c9dc6212dda44fcd20ecb87ac3f3fce6f0ca2f28d4a00e4154f8cd599", [:mix], [], "hexpm", "a81a04c7e34b6617c2792e291b5a2e57ab316365c2644ddc553bb9ed863ebefa"},
"ex_doc": {:hex, :ex_doc, "0.34.2", "13eedf3844ccdce25cfd837b99bea9ad92c4e511233199440488d217c92571e8", [:mix], [{:earmark_parser, "~> 1.4.39", [hex: :earmark_parser, repo: "hexpm", optional: false]}, {:makeup_c, ">= 0.1.0", [hex: :makeup_c, repo: "hexpm", optional: true]}, {:makeup_elixir, "~> 0.14 or ~> 1.0", [hex: :makeup_elixir, repo: "hexpm", optional: false]}, {:makeup_erlang, "~> 0.1 or ~> 1.0", [hex: :makeup_erlang, repo: "hexpm", optional: false]}, {:makeup_html, ">= 0.1.0", [hex: :makeup_html, repo: "hexpm", optional: true]}], "hexpm", "5ce5f16b41208a50106afed3de6a2ed34f4acfd65715b82a0b84b49d995f95c1"},
"expo": {:hex, :expo, "1.1.0", "f7b9ed7fb5745ebe1eeedf3d6f29226c5dd52897ac67c0f8af62a07e661e5c75", [:mix], [], "hexpm", "fbadf93f4700fb44c331362177bdca9eeb8097e8b0ef525c9cc501cb9917c960"},
"floki": {:hex, :floki, "0.36.2", "a7da0193538c93f937714a6704369711998a51a6164a222d710ebd54020aa7a3", [:mix], [], "hexpm", "a8766c0bc92f074e5cb36c4f9961982eda84c5d2b8e979ca67f5c268ec8ed580"},
"floki": {:hex, :floki, "0.36.3", "1102f93b16a55bc5383b85ae3ec470f82dee056eaeff9195e8afdf0ef2a43c30", [:mix], [], "hexpm", "fe0158bff509e407735f6d40b3ee0d7deb47f3f3ee7c6c182ad28599f9f6b27a"},
"gettext": {:hex, :gettext, "0.26.1", "38e14ea5dcf962d1fc9f361b63ea07c0ce715a8ef1f9e82d3dfb8e67e0416715", [:mix], [{:expo, "~> 0.5.1 or ~> 1.0", [hex: :expo, repo: "hexpm", optional: false]}], "hexpm", "01ce56f188b9dc28780a52783d6529ad2bc7124f9744e571e1ee4ea88bf08734"},
"jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"},
"live_view_native": {:hex, :live_view_native, "0.3.1", "da64f1507e772b6cf8be99c85c6b300a03d64c46ceabc9f00b1f97962cc49e2d", [:mix], [{:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.7.0", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20.10", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0.4", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: false]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.5", [hex: :plug_cowboy, repo: "hexpm", optional: false]}, {:sourceror, "~> 1.5", [hex: :sourceror, repo: "hexpm", optional: false]}, {:text_diff, "~> 0.1", [hex: :text_diff, repo: "hexpm", optional: false]}], "hexpm", "fd526dd025f58393a2d648c9ec22383464037f7effe5d62061029743e7572a86"},
"live_view_native_live_form": {:hex, :live_view_native_live_form, "0.3.1", "5cf84867bdc9bfd9341147cfed9355abd1a9bd87ffd10295ba15bc15de7df70e", [:mix], [{:live_view_native, "~> 0.3.1", [hex: :live_view_native, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.20.4", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}], "hexpm", "5a7405463bc12d73dd87a9a9081217cfa4d188545807fcd152c0570f5eb6061a"},
"live_view_native": {:git, "https://github.com/liveview-native/live_view_native.git", "c3ec1775e636d47b94130e080ce61cca31c0f0f8", []},
"live_view_native_live_form": {:git, "https://github.com/liveview-native/liveview-native-live-form.git", "55c66279e07081ca07d76b9965368209833bab7d", []},
"live_view_native_stylesheet": {:hex, :live_view_native_stylesheet, "0.3.1", "71a1cee29ec3fe0003949250035ec905e6e7c706928e94ff8823be8108267e1b", [:mix], [{:live_view_native, "~> 0.3.1", [hex: :live_view_native, repo: "hexpm", optional: false]}, {:nimble_parsec, "~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "ca2a9a47b34be56099d6c1523a2cb69274ba2a5ecff441cacb4b885483fb39b3"},
"live_view_native_test": {:git, "https://github.com/liveview-native/live_view_native_test.git", "539ae931fa3936f3ee2f73ffa11f7100fe6554db", [branch: "main"]},
"makeup": {:hex, :makeup, "1.1.2", "9ba8837913bdf757787e71c1581c21f9d2455f4dd04cfca785c70bbfff1a76a3", [:mix], [{:nimble_parsec, "~> 1.2.2 or ~> 1.3", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "cce1566b81fbcbd21eca8ffe808f33b221f9eee2cbc7a1706fc3da9ff18e6cac"},
Expand All @@ -32,7 +32,7 @@
"plug_cowboy": {:hex, :plug_cowboy, "2.7.2", "fdadb973799ae691bf9ecad99125b16625b1c6039999da5fe544d99218e662e4", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "245d8a11ee2306094840c000e8816f0cbed69a23fc0ac2bcf8d7835ae019bb2f"},
"plug_crypto": {:hex, :plug_crypto, "2.1.0", "f44309c2b06d249c27c8d3f65cfe08158ade08418cf540fd4f72d4d6863abb7b", [:mix], [], "hexpm", "131216a4b030b8f8ce0f26038bc4421ae60e4bb95c5cf5395e1421437824c4fa"},
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
"sourceror": {:hex, :sourceror, "1.6.0", "9907884e1449a4bd7dbaabe95088ed4d9a09c3c791fb0103964e6316bc9448a7", [:mix], [], "hexpm", "e90aef8c82dacf32c89c8ef83d1416fc343cd3e5556773eeffd2c1e3f991f699"},
"sourceror": {:hex, :sourceror, "1.7.0", "62c34f4e3a109d837edd652730219b6332745e0ec7db34d5d350a5cdf30b376a", [:mix], [], "hexpm", "3dd2b1bd780fd0df48089f48480a54fd065bf815b63ef8046219d7784e7435f3"},
"telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
"text_diff": {:hex, :text_diff, "0.1.0", "1caf3175e11a53a9a139bc9339bd607c47b9e376b073d4571c031913317fecaa", [:mix], [], "hexpm", "d1ffaaecab338e49357b6daa82e435f877e0649041ace7755583a0ea3362dbd7"},
"websock": {:hex, :websock, "0.5.3", "2f69a6ebe810328555b6fe5c831a851f485e303a7c8ce6c5f675abeb20ebdadc", [:mix], [], "hexpm", "6105453d7fac22c712ad66fab1d45abdf049868f253cf719b625151460b8b453"},
Expand Down
50 changes: 37 additions & 13 deletions test/live_view_native/swiftui/core_components_test.exs
Original file line number Diff line number Diff line change
@@ -1,19 +1,43 @@
defmodule LiveViewNative.SwiftUI.CoreComponentsTest do
use ExUnit.Case

File.read!("priv/templates/lvn.swiftui.gen/core_components.ex")
|> EEx.eval_string([
context: %{
web_module: LiveViewNativeTest,
module_suffix: SwiftUI
},
assigns: %{
live_form?: true,
gettext: true,
version: Application.spec(:live_view_native_swiftui)[:vsn]
}
])
|> Code.eval_string()
import LiveViewNativeTest.CoreComponents.SwiftUI

Check warning on line 4 in test/live_view_native/swiftui/core_components_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

unused import LiveViewNativeTest.CoreComponents.SwiftUI

import LiveViewNative.Component, only: [sigil_LVN: 2]

Check warning on line 6 in test/live_view_native/swiftui/core_components_test.exs

View workflow job for this annotation

GitHub Actions / Build and test

unused import LiveViewNative.Component
import LiveViewNative.Template.Parser, only: [parse_document!: 1]

defmacro sigil_X({:<<>>, _, [binary]}, []) when is_binary(binary) do
Macro.escape(parse_sorted!(binary))
end

defmacro sigil_x(term, []) do
quote do
unquote(__MODULE__).parse_sorted!(unquote(term))
end
end

def t2h(template) do
template
|> Phoenix.LiveViewTest.rendered_to_string()
|> parse_sorted!()
end

@doc """
Parses LVN templates into Floki format with sorted attributes.
"""
def parse_sorted!(value) do
value
|> parse_document!()
|> Enum.map(&normalize_attribute_order/1)
end

defp normalize_attribute_order({node_type, attributes, content}),
do: {node_type, Enum.sort(attributes), Enum.map(content, &normalize_attribute_order/1)}

defp normalize_attribute_order(values) when is_list(values),
do: Enum.map(values, &normalize_attribute_order/1)

defp normalize_attribute_order(value), do: value

describe "input/1" do

Expand Down
14 changes: 14 additions & 0 deletions test/support/components/core_components.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
File.read!("priv/templates/lvn.swiftui.gen/core_components.ex")
|> EEx.eval_string([
context: %{
web_module: LiveViewNativeTest,
module_suffix: SwiftUI
},
assigns: %{
live_form?: true,
gettext: true,
version: Application.spec(:live_view_native_swiftui)[:vsn]
}
])
|> Code.eval_string()
|> IO.inspect()

0 comments on commit 07605ff

Please sign in to comment.