Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitry-sidorov committed Nov 29, 2024
1 parent b6d004b commit 6e842e3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ defmodule BudgetTrackerWeb.AccountsLive.Components.AccountCard do

def handle_event(@income_event, _unsigned_params, socket) do
IO.puts("[LIVE COMPONENT] Add income event!")
socket.assigns.id |> dbg()

# socket = assign(socket, visible: true)
# socket = assign(socket, debit_account_id: unsigned_params["payload"])
{:noreply, socket}
end

def handle_event(@payment_event, _unsigned_params, socket) do
IO.puts("[LIVE COMPONENT] Add payment event!")
socket.assigns.id |> dbg()
# socket = assign(socket, debit_account_id: unsigned_params["payload"])
{:noreply, socket}
end

def handle_event(@delete_event, _unsigned_params, socket) do
IO.puts("[LIVE COMPONENT] Delete account event!")
socket.assigns.id |> dbg()
# socket = assign(socket, debit_account_id: unsigned_params["payload"])
{:noreply, socket}
end
Expand All @@ -45,8 +41,6 @@ defmodule BudgetTrackerWeb.AccountsLive.Components.AccountCard do
attr :on_delete_callback_name, :string, required: true

def render(assigns) do
assigns.event_names |> dbg()

~H"""
<div>
<.card class="box-content flex items-center border-1 border-black h-36 w-fit rounded-xl bg-slate-200">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
>
+1 Income
</.button>
<.button
color="info"
class="h-12 w-36 rounded-lg"
phx-value-payload={@debit_account_id}
>
<.button color="info" class="h-12 w-36 rounded-lg" phx-value-payload={@debit_account_id}>
+1 Payment
</.button>
</div>
<div class="mr-4 cursor-pointer" phx-click="delete_debit_account" phx-value-payload={@debit_account_id}>
<div
class="mr-4 cursor-pointer"
phx-click="delete_debit_account"
phx-value-payload={@debit_account_id}
>
<.delete_icon />
</div>
</.card>
4 changes: 0 additions & 4 deletions lib/budget_tracker_web/live/categories_live/show.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ defmodule BudgetTrackerWeb.CategoriesLive.Show do
end

def handle_event("edit", unsigned_params, socket) do
unsigned_params |> dbg()
{:noreply, socket}
end

def handle_event("delete", unsigned_params, socket) do
unsigned_params |> dbg()
{:noreply, socket}
end

Expand All @@ -47,8 +45,6 @@ defmodule BudgetTrackerWeb.CategoriesLive.Show do
end

def render(assigns) do
assigns.categories |> dbg()

~H"""
<div class="flex flex-col gap-4">
<.button class="w-48" color="primary" phx-click={show_modal(@create_category_modal)}>
Expand Down
32 changes: 24 additions & 8 deletions test/budget_tracker/operation_categories_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -17,40 +17,56 @@ defmodule BudgetTracker.OperationCategoriesTest do

test "get_operation_category!/1 returns the operation_category with given id" do
operation_category = operation_category_fixture()
assert OperationCategories.get_operation_category!(operation_category.id) == operation_category

assert OperationCategories.get_operation_category!(operation_category.id) ==
operation_category
end

test "create_operation_category/1 with valid data creates a operation_category" do
valid_attrs = %{title: "some title", is_primary: true}

assert {:ok, %OperationCategory{} = operation_category} = OperationCategories.create_operation_category(valid_attrs)
assert {:ok, %OperationCategory{} = operation_category} =
OperationCategories.create_operation_category(valid_attrs)

assert operation_category.title == "some title"
assert operation_category.is_primary == true
end

test "create_operation_category/1 with invalid data returns error changeset" do
assert {:error, %Ecto.Changeset{}} = OperationCategories.create_operation_category(@invalid_attrs)
assert {:error, %Ecto.Changeset{}} =
OperationCategories.create_operation_category(@invalid_attrs)
end

test "update_operation_category/2 with valid data updates the operation_category" do
operation_category = operation_category_fixture()
update_attrs = %{title: "some updated title", is_primary: false}

assert {:ok, %OperationCategory{} = operation_category} = OperationCategories.update_operation_category(operation_category, update_attrs)
assert {:ok, %OperationCategory{} = operation_category} =
OperationCategories.update_operation_category(operation_category, update_attrs)

assert operation_category.title == "some updated title"
assert operation_category.is_primary == false
end

test "update_operation_category/2 with invalid data returns error changeset" do
operation_category = operation_category_fixture()
assert {:error, %Ecto.Changeset{}} = OperationCategories.update_operation_category(operation_category, @invalid_attrs)
assert operation_category == OperationCategories.get_operation_category!(operation_category.id)

assert {:error, %Ecto.Changeset{}} =
OperationCategories.update_operation_category(operation_category, @invalid_attrs)

assert operation_category ==
OperationCategories.get_operation_category!(operation_category.id)
end

test "delete_operation_category/1 deletes the operation_category" do
operation_category = operation_category_fixture()
assert {:ok, %OperationCategory{}} = OperationCategories.delete_operation_category(operation_category)
assert_raise Ecto.NoResultsError, fn -> OperationCategories.get_operation_category!(operation_category.id) end

assert {:ok, %OperationCategory{}} =
OperationCategories.delete_operation_category(operation_category)

assert_raise Ecto.NoResultsError, fn ->
OperationCategories.get_operation_category!(operation_category.id)
end
end

test "change_operation_category/1 returns a operation_category changeset" do
Expand Down
4 changes: 3 additions & 1 deletion test/budget_tracker/operations_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ defmodule BudgetTracker.OperationsTest do
operation = operation_fixture()
update_attrs = %{type: "some updated type", amount: 456.7}

assert {:ok, %Operation{} = operation} = Operations.update_operation(operation, update_attrs)
assert {:ok, %Operation{} = operation} =
Operations.update_operation(operation, update_attrs)

assert operation.type == "some updated type"
assert operation.amount == 456.7
end
Expand Down
3 changes: 2 additions & 1 deletion test/budget_tracker_web/controllers/error_html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ defmodule BudgetTrackerWeb.ErrorHTMLTest do
end

test "renders 500.html" do
assert render_to_string(BudgetTrackerWeb.ErrorHTML, "500", "html", []) == "Internal Server Error"
assert render_to_string(BudgetTrackerWeb.ErrorHTML, "500", "html", []) ==
"Internal Server Error"
end
end

0 comments on commit 6e842e3

Please sign in to comment.