Skip to content

Commit

Permalink
fix and test for sorting nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Jul 16, 2024
1 parent 401673a commit e60d2bd
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/radiator/outline.ex
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ defmodule Radiator.Outline do
{:ok, _new_next_node} = move_node_if(new_next_node, new_parent_id, get_node_id(node))

Map.merge(node_repo_result, %{
node: node,
old_next_id: get_node_id(old_next_node),
old_prev_id: get_node_id(prev_node),
next_id: get_node_id(new_next_node)
Expand Down
30 changes: 27 additions & 3 deletions test/radiator/outline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,33 @@ defmodule Radiator.OutlineTest do
describe "order_child_nodes/1" do
setup :complex_node_fixture

test "get child nodes in correct order", %{parent_node: parent_node} do
assert parent_node |> Outline.order_child_nodes() |> Enum.map(& &1.content) ==
["node_1", "node_2", "node_3", "node_4", "node_5", "node_6"]
test "get child nodes in correct order" do
episode = PodcastFixtures.episode_fixture()
node_1=

Check warning on line 704 in test/radiator/outline_test.exs

View workflow job for this annotation

GitHub Actions / Build & Test

There are spaces around operators most of the time, but not here.
node_fixture(
episode_id: episode.id,
parent_id: nil,
prev_id: nil,
content: "node_1"
)
node_3 =
node_fixture(
episode_id: episode.id,
parent_id: node_1.uuid,
prev_id: nil,
content: "node_3"
)
node_2 =
node_fixture(
episode_id: episode.id,
parent_id: node_1.uuid,
prev_id: node_3.uuid,
content: "node_2"
)
{:ok, %NodeRepoResult{} = _result} = Outline.move_node(node_3.uuid, node_2.uuid, node_1.uuid)

assert node_1 |> Outline.order_child_nodes() |> Enum.map(& &1.content) ==
["node_2", "node_3"]
end
end

Expand Down

0 comments on commit e60d2bd

Please sign in to comment.