From 02cc7d048bb1bfe4bedf83eabad6a6aa21cdf0a4 Mon Sep 17 00:00:00 2001 From: nelsonic Date: Mon, 14 Aug 2023 09:52:56 +0100 Subject: [PATCH] mix format #145 #356 #345 --- lib/app_web/live/app_live.ex | 10 ++++++++-- test/app/list_items_test.exs | 9 ++++++--- test/app/list_test.exs | 5 ++++- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/lib/app_web/live/app_live.ex b/lib/app_web/live/app_live.ex index 73d59c56..e4c97bc9 100644 --- a/lib/app_web/live/app_live.ex +++ b/lib/app_web/live/app_live.ex @@ -300,7 +300,10 @@ defmodule AppWeb.AppLive do %{"itemId_from" => itemId_from, "itemId_to" => itemId_to}, socket ) do - IO.puts("updateIndexes -> itemId_from: #{itemId_from}, itemId_to: #{itemId_to} | #{Useful.typeof(itemId_to)}") + IO.puts( + "updateIndexes -> itemId_from: #{itemId_from}, itemId_to: #{itemId_to} | #{Useful.typeof(itemId_to)}" + ) + App.ListItem.move_item(itemId_from, itemId_to) {:noreply, socket} end @@ -313,7 +316,10 @@ defmodule AppWeb.AppLive do }, socket ) do - IO.puts("cur_item_id: #{current_item_id}, selected_item_id: #{selected_item_id}") + IO.puts( + "cur_item_id: #{current_item_id}, selected_item_id: #{selected_item_id}" + ) + {:noreply, push_event(socket, "dragover-item", %{ current_item_id: current_item_id, diff --git a/test/app/list_items_test.exs b/test/app/list_items_test.exs index 2b658fcf..052593b8 100644 --- a/test/app/list_items_test.exs +++ b/test/app/list_items_test.exs @@ -66,7 +66,8 @@ defmodule App.ListItemsTest do @valid_attrs %{text: "Buy Bananas", person_id: 0, status: 2} test "get_list_item_position/2 retrieves the position of an item in a list" do {:ok, %{model: item, version: _version}} = - Item.create_item(@valid_attrs) + Item.create_item(@valid_attrs) + {:ok, li1} = App.ListItem.add_item_to_all_list(item) assert li1.position == 1.0 @@ -89,12 +90,14 @@ defmodule App.ListItemsTest do assert length(item_ids) == 0 # Add an new item for the person: - {:ok, %{model: item}} = %{text: "hai", person_id: person_id, status: 2} - |> Item.create_item() + {:ok, %{model: item}} = + %{text: "hai", person_id: person_id, status: 2} + |> Item.create_item() App.ListItem.add_item_to_all_list(item) updated_item_ids = App.ListItem.get_items_on_all_list(person_id) + assert length(updated_item_ids) == length(App.Item.all_items_for_person(person_id)) diff --git a/test/app/list_test.exs b/test/app/list_test.exs index 98dfcfb7..c2865102 100644 --- a/test/app/list_test.exs +++ b/test/app/list_test.exs @@ -57,8 +57,11 @@ defmodule App.ListTest do test "get_list_by_text!/2 returns the list for the person_id by text" do person_id = 4 - {:ok, %{model: all_list}} = %{text: "all", person_id: person_id, status: 2} + + {:ok, %{model: all_list}} = + %{text: "all", person_id: person_id, status: 2} |> App.List.create_list() + list = App.List.get_list_by_text!(person_id, "all") assert list.text == "all" assert list.id == all_list.id