Skip to content

Commit

Permalink
tree can have more than one parent node
Browse files Browse the repository at this point in the history
  • Loading branch information
electronicbites committed Apr 1, 2024
1 parent 029165c commit 9b67716
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion test/radiator/outline_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,33 @@ defmodule Radiator.OutlineTest do
assert_level_for_node(tree, nested_node_1, 2)
assert_level_for_node(tree, nested_node_2, 2)
end

test "tree can have more than one parent node", %{
parent_node: parent_node
} do
episode_id = parent_node.episode_id

other_parent_node =
node_fixture(
parent_id: nil,
prev_id: parent_node.uuid,
episode_id: episode_id,
content: "also a parent"
)

third_parent_node =
node_fixture(
parent_id: nil,
prev_id: other_parent_node.uuid,
episode_id: episode_id,
content: "even another root element"
)

{:ok, tree} = Outline.get_node_tree(parent_node.episode_id)
assert_level_for_node(tree, parent_node, 0)
assert_level_for_node(tree, other_parent_node, 0)
assert_level_for_node(tree, third_parent_node, 0)
end
end

defp assert_level_for_node(tree, node, level) do
Expand All @@ -381,7 +408,14 @@ defmodule Radiator.OutlineTest do

defp complex_node_fixture(_) do
episode = PodcastFixtures.episode_fixture()
parent_node = node_fixture(episode_id: episode.id, parent_id: nil, prev_id: nil)

parent_node =
node_fixture(
episode_id: episode.id,
parent_id: nil,
prev_id: nil,
content: "root of all evil"
)

node_1 =
node_fixture(
Expand Down

0 comments on commit 9b67716

Please sign in to comment.