Skip to content

Commit

Permalink
Refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
camelpunch committed Jan 25, 2025
1 parent 858671e commit 7397e98
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/mudbrick/parser/roundtrip_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ defmodule Mudbrick.ParseRoundtripTest do
images = Keyword.get(document_options, :images, %{})

input =
Enum.zip([
pages_options,
if(Enum.empty?(images_options), do: [], else: Stream.cycle(images_options)),
if(Enum.empty?(images), do: [], else: Stream.cycle(Map.keys(images)))
])
Enum.zip([pages_options, cycle(images_options), cycle(Map.keys(images))])
|> Enum.reduce(doc, fn {page_options, image_options, image_identifier}, context ->
context
|> page(page_options)
Expand Down Expand Up @@ -188,4 +184,7 @@ defmodule Mudbrick.ParseRoundtripTest do

assert parsed == input
end

defp cycle([]), do: []
defp cycle(enumerable), do: Stream.cycle(enumerable)
end

0 comments on commit 7397e98

Please sign in to comment.