84 lines
3.0 KiB
Elixir
84 lines
3.0 KiB
Elixir
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
|