From 029165c1f24ed0d87d38b241f4f1040b5bde59e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Wo=CC=88ginger?= Date: Sat, 30 Mar 2024 18:29:16 +0100 Subject: [PATCH] add another test asserting the levels --- lib/radiator/outline.ex | 3 ++- test/radiator/outline_test.exs | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/lib/radiator/outline.ex b/lib/radiator/outline.ex index bfe9b8a2..4493b062 100644 --- a/lib/radiator/outline.ex +++ b/lib/radiator/outline.ex @@ -212,7 +212,8 @@ defmodule Radiator.Outline do content: content, parent_id: binaray_uuid_to_ecto_uuid(parent_id), prev_id: binaray_uuid_to_ecto_uuid(prev_id), - level: level + level: level, + episode_id: episode_id } end) diff --git a/test/radiator/outline_test.exs b/test/radiator/outline_test.exs index b3b45abe..7188404c 100644 --- a/test/radiator/outline_test.exs +++ b/test/radiator/outline_test.exs @@ -349,6 +349,34 @@ defmodule Radiator.OutlineTest do node.level end) end + + test "associated the correct level", %{ + node_1: node_1, + node_2: node_2, + node_3: node_3, + node_4: node_4, + node_5: node_5, + node_6: node_6, + nested_node_1: nested_node_1, + nested_node_2: nested_node_2, + parent_node: parent_node + } do + {:ok, tree} = Outline.get_node_tree(parent_node.episode_id) + assert_level_for_node(tree, parent_node, 0) + assert_level_for_node(tree, node_1, 1) + assert_level_for_node(tree, node_2, 1) + assert_level_for_node(tree, node_3, 1) + assert_level_for_node(tree, node_4, 1) + assert_level_for_node(tree, node_5, 1) + assert_level_for_node(tree, node_6, 1) + assert_level_for_node(tree, nested_node_1, 2) + assert_level_for_node(tree, nested_node_2, 2) + end + end + + defp assert_level_for_node(tree, node, level) do + node = Enum.filter(tree, fn n -> n.uuid == node.uuid end) |> List.first() + assert node.level == level end defp complex_node_fixture(_) do