From 1cf8c972d2b61d71d7f79c269030fe0b4bc1ae2c Mon Sep 17 00:00:00 2001 From: Sergio Arbeo Date: Fri, 13 Dec 2024 20:22:22 +0100 Subject: [PATCH] Remove isExpanded attribute and related tests --- .../lvn.swiftui.gen/core_components.ex | 11 +- .../swiftui/core_components_test.exs | 459 ++++++++---------- 2 files changed, 215 insertions(+), 255 deletions(-) diff --git a/priv/templates/lvn.swiftui.gen/core_components.ex b/priv/templates/lvn.swiftui.gen/core_components.ex index 3a8cd10b7..45a47866f 100644 --- a/priv/templates/lvn.swiftui.gen/core_components.ex +++ b/priv/templates/lvn.swiftui.gen/core_components.ex @@ -416,14 +416,11 @@ defmodule <%= inspect context.web_module %>.CoreComponents.<%= inspect context.m <%%= render_slot(@inner_block, f) %> <%% else %> <%%= for section <- @section do %> -
- - <%%= Map.get(section, :header) %> - +
+ + <%%= render_slot(section) %> - - <%%= Map.get(section, :footer) %> - +
<%% end %> <%% end %> diff --git a/test/live_view_native/swiftui/core_components_test.exs b/test/live_view_native/swiftui/core_components_test.exs index 1411ceecb..325617fd6 100644 --- a/test/live_view_native/swiftui/core_components_test.exs +++ b/test/live_view_native/swiftui/core_components_test.exs @@ -54,9 +54,9 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - """ + ~X""" + + """ end test "TextFieldLink" do @@ -67,16 +67,16 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - - test-label - - - - """ + ~X""" + + + test-label + + test-label + + + + """ end test "DatePicker" do @@ -87,13 +87,13 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - - - """ + ~X""" + + + test-label + + + """ end test "MultiDatePicker" do @@ -104,14 +104,14 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - test-label - - - """ + ~X""" + + + test-label + test-label + + + """ end test "Picker" do @@ -122,16 +122,16 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - - a - - - - """ + ~X""" + + + test-label + + a + + + + """ end test "Slider" do @@ -142,14 +142,14 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - test-label - - - """ + ~X""" + + + test-label + test-label + + + """ end test "Stepper" do @@ -160,14 +160,14 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - - - - """ + ~X""" + + + test-label + + + + """ end test "TextEditor" do @@ -178,14 +178,14 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - - - - """ + ~X""" + + + test-label + + + + """ end test "TextField" do @@ -196,11 +196,11 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - test-label - - """ + ~X""" + + test-label + + """ end test "TextField with placeholder" do @@ -211,11 +211,11 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - test-placeholder - - """ + ~X""" + + test-placeholder + + """ end test "SecureField" do @@ -226,11 +226,11 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - test-label - - """ + ~X""" + + test-label + + """ end test "SecureField with placeholder" do @@ -241,11 +241,11 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - test-placeholder - - """ + ~X""" + + test-placeholder + + """ end test "Toggle" do @@ -256,14 +256,14 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - test-label - - - - """ + ~X""" + + + test-label + + + + """ end end @@ -278,30 +278,24 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - Error! - - """ - + ~X""" + + Error! + + """ end - end describe "header/1" do - end describe "modal/1" do - end describe "flash/1" do - end describe "flash_group/1" do - end describe "simple_form/1" do @@ -312,17 +306,17 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do assigns = %{form: form} template = ~LVN""" - <.simple_form for={@form}> - - """ + <.simple_form for={@form}> + + """ assert t2h(template) == - ~X""" - -
-
-
- """ + ~X""" + +
+
+
+ """ end test "can render form with an input" do @@ -332,25 +326,31 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do assigns = %{form: form} template = ~LVN""" - <.simple_form for={@form}> - <.input field={@form[:email]} label="Email"/> - - """ + <.simple_form for={@form}> + <.input field={@form[:email]} label="Email"/> + + """ assert t2h(template) == - ~X""" - -
- - Email - -
-
- """ + ~X""" + +
+ + Email + +
+
+ """ end test "can render multiple sections in order" do - params = %{"email" => "test@example.com", "first_name" => "Gloria", "last_name" => "Fuertes", "more_info" => "More info here"} + params = %{ + "email" => "test@example.com", + "first_name" => "Gloria", + "last_name" => "Fuertes", + "more_info" => "More info here" + } + form = to_form(params, as: "user") assigns = %{form: form} @@ -371,65 +371,37 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - trim(~X""" - -
-
- Name - - First name - - - Last name - -
-
- - Email - - We will contact you here. -
-
- Extra info - - More info - - We will use this for... -
-
-
- """) + trim(~X""" + +
+
+ + + First name + + + Last name + +
+
+ + Email + + +
+
+ + + More info + + +
+
+
+ """) end - test "can give a isExpanded value to Section" do - params = %{"email" => "test@example.com"} - form = to_form(params, as: "user") - - assigns = %{expand?: false, form: form} - - template = ~LVN""" - <.simple_form for={@form}> - <:section is_expanded={@expand?}> - <.input field={@form[:email]} label="Email"/> - - - """ - - assert t2h(template) == - trim(~X""" - -
-
- - Email - -
-
-
- """) - end - - test "can render sectionn with footer" do + test "can render section with footer" do params = %{"email" => "test@example.com"} form = to_form(params, as: "user") @@ -444,20 +416,18 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - trim(~X""" - -
-
- - Email - - - A footer - -
-
-
- """) + trim(~X""" + +
+
+ + Email + + +
+
+
+ """) end test "can render section with header" do @@ -475,23 +445,21 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - trim(~X""" - -
-
- - A header - - - Email - -
-
-
- """) + trim(~X""" + +
+
+ + + Email + +
+
+
+ """) end - test "can render section without attributes" do + test "can render section" do params = %{"email" => "test@example.com"} form = to_form(params, as: "user") @@ -506,17 +474,17 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - -
-
- - Email - -
-
-
- """ + ~X""" + +
+
+ + Email + +
+
+
+ """ end end @@ -529,17 +497,15 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - """ - + ~X""" + + """ end end describe "table" do - end describe "list/1" do @@ -555,18 +521,18 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do """ assert t2h(template) == - ~X""" - - - Foo - Foo - - - Bar - Bar - - - """ + ~X""" + + + Foo + Foo + + + Bar + Bar + + + """ end end @@ -575,25 +541,22 @@ defmodule LiveViewNative.SwiftUI.CoreComponentsTest do assigns = %{} template = ~LVN""" - <.icon name="star"/> - """ + <.icon name="star"/> + """ assert t2h(template) == - ~X""" - - """ + ~X""" + + """ end end describe "image/1" do - end describe "translate_error/1" do - end describe "translate_errors/1" do - end end