Add TunitModifications with first modifier unite_with_next

This commit is contained in:
Thelonius Kort
2023-03-28 14:48:26 +02:00
parent b92503d643
commit 3a2af2adb4
4 changed files with 172 additions and 2 deletions

View File

@ -0,0 +1,83 @@
defmodule Outlook.InternalTreeTest do
use Outlook.DataCase
# import Outlook.InternalTreeTestHelpers
describe "internal_tree" do
alias Outlook.InternalTree
alias Outlook.InternalTree.{InternalNode,TranslationUnit}
def tree() do
[
%InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "rRIib2h8tyix",
content: [
%TranslationUnit{status: :untranslated, nid: "GuU9v6xeSS7e", content: "Joe Biden a.", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "bzCLsYGNe2PG", content: "k.", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "GyRUrzwH9LcP", content: "a. ", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "y2yb38U4hkya", content: "Crash Test Dummy.", eph: %{}}
],
eph: %{sibling_with: :block}
}
]
end
test "unite_with_next unites with next in simple case" do
assert InternalTree.modify_tunits(tree(), "unite_with_next", ["bzCLsYGNe2PG"]) == [
%InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "rRIib2h8tyix",
content: [
%TranslationUnit{status: :untranslated, nid: "GuU9v6xeSS7e", content: "Joe Biden a.", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "bzCLsYGNe2PG", content: "k.a. ", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "y2yb38U4hkya", content: "Crash Test Dummy.", eph: %{}}
],
eph: %{sibling_with: :block}
}
]
end
test "unite_with_next unites all with next in complex case" do
assert InternalTree.modify_tunits(tree(), "unite_with_next", ["GuU9v6xeSS7e","bzCLsYGNe2PG","GyRUrzwH9LcP"]) == [
%InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "rRIib2h8tyix",
content: [
%TranslationUnit{
status: :untranslated,
nid: "GuU9v6xeSS7e",
content: "Joe Biden a.k.a. Crash Test Dummy.",
eph: %{}
}
],
eph: %{sibling_with: :block}
}
]
end
test "unite_with_next ignores id if there is no next tunit" do
assert InternalTree.modify_tunits(tree(), "unite_with_next", ["y2yb38U4hkya"]) == [
%InternalNode{
name: "p",
attributes: %{},
type: :element,
nid: "rRIib2h8tyix",
content: [
%TranslationUnit{status: :untranslated, nid: "GuU9v6xeSS7e", content: "Joe Biden a.", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "bzCLsYGNe2PG", content: "k.", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "GyRUrzwH9LcP", content: "a. ", eph: %{}},
%TranslationUnit{status: :untranslated, nid: "y2yb38U4hkya", content: "Crash Test Dummy.", eph: %{}}
],
eph: %{sibling_with: :block}
}
]
end
end
end