29 lines
856 B
Elixir
29 lines
856 B
Elixir
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
|