diff --git a/test/outlook/internaltree_test.exs b/test/outlook/internaltree_test.exs
new file mode 100644
index 0000000..c82ae1f
--- /dev/null
+++ b/test/outlook/internaltree_test.exs
@@ -0,0 +1,92 @@
+defmodule Outlook.InternalTreeTest do
+ use Outlook.DataCase
+
+ import Outlook.InternalTreeTestHelpers
+
+ describe "internal_tree" do
+ alias Outlook.InternalTree
+ alias Outlook.InternalTree.{InternalNode,Html,Basic,TranslationUnit}
+
+ import Outlook.ArticlesFixtures
+
+ @default_uuid "11111111-1111-1111-1111-111111111111"
+
+ test "partition_text/1 returns correctly dingens..." do
+ tree = [
+ %InternalNode{
+ name: "p",
+ attributes: %{},
+ type: :element,
+ uuid: "8293da39-18e3-4695-8ec5-a3a4a06f006c",
+ content: [
+ %InternalNode{
+ name: "",
+ attributes: %{},
+ type: :text,
+ uuid: "1b62b02f-0be1-4ba1-88a1-0f08f5a5254d",
+ content: "A sentence with many letters ",
+ eph: %{sibling_with: :inline}
+ },
+ %InternalNode{
+ name: "a",
+ attributes: %{href: "dingsda.com"},
+ type: :element,
+ content: [
+ %InternalNode{
+ name: "",
+ attributes: %{},
+ type: :text,
+ uuid: "c6816bfe-a660-436b-84ab-64d92417e321",
+ content: "and many, many ",
+ eph: %{sibling_with: :inline}
+ },
+ %InternalNode{
+ name: "b",
+ attributes: %{},
+ type: :element,
+ content: [
+ %InternalNode{
+ name: "",
+ attributes: %{},
+ type: :text,
+ uuid: "abcd5893-d062-4716-9979-4bf1f65d5e17",
+ content: "words. A",
+ eph: %{sibling_with: :inline}
+ }
+ ],
+ eph: %{sibling_with: :inline}
+ },
+ %InternalNode{
+ name: "",
+ attributes: %{},
+ type: :text,
+ uuid: "d67f41fe-678a-4e27-99da-00d38decde75",
+ content: " sentence",
+ eph: %{sibling_with: :inline}
+ }
+ ],
+ eph: %{sibling_with: :inline}
+ },
+ %InternalNode{
+ name: "",
+ attributes: %{},
+ type: :text,
+ uuid: "6fc0bf77-4dc6-4828-866e-2933d393f4b9",
+ content: " with many letters and many, many words. ",
+ eph: %{sibling_with: :inline}
+ }
+ ],
+ eph: %{sibling_with: :block}
+ }
+ ]
+ assert InternalTree.partition_text(tree) |> unify_uuids_in_tunits() == [
+ %InternalNode{name: "p", attributes: %{}, type: :element, uuid: "8293da39-18e3-4695-8ec5-a3a4a06f006c",
+ content: [
+ %TranslationUnit{status: :untranslated, uuid: @default_uuid,
+ content: "A sentence with many letters and many, many words. "},
+ %TranslationUnit{status: :untranslated, uuid: @default_uuid,
+ content: "A sentence with many letters and many, many words. "}],
+ eph: %{sibling_with: :block}}]
+ end
+ end
+end
diff --git a/test/support/internal_tree_test_helpers.ex b/test/support/internal_tree_test_helpers.ex
new file mode 100644
index 0000000..9e4f33a
--- /dev/null
+++ b/test/support/internal_tree_test_helpers.ex
@@ -0,0 +1,28 @@
+defmodule Outlook.InternalTreeTestHelpers do
+
+ @default_uuid "11111111-1111-1111-1111-111111111111"
+
+ alias Outlook.InternalTree.{InternalNode,TranslationUnit}
+ @doc "Set uuids to default value to make test results predictable."
+ def unify_uuids_in_tunits([ %TranslationUnit{} = node | rest ]) do
+ [
+ %TranslationUnit{node |
+ uuid: @default_uuid,
+ content: String.replace(node.content, ~r/ uuid=""/, "")
+ }
+ | unify_uuids_in_tunits(rest) ]
+ end
+
+ def unify_uuids_in_tunits([ %InternalNode{type: :element} = node | rest ]) do
+ [ %InternalNode{node |
+ content: unify_uuids_in_tunits(node.content)
+ }
+ | unify_uuids_in_tunits(rest) ]
+ end
+
+ def unify_uuids_in_tunits([ %InternalNode{} = node | rest ]) do
+ [ node | unify_uuids_in_tunits(rest) ]
+ end
+
+ def unify_uuids_in_tunits([]), do: []
+end