Skip to content

Commit

Permalink
Refactor test
Browse files Browse the repository at this point in the history
  • Loading branch information
camelpunch committed Oct 14, 2024
1 parent 1318b6f commit 0e4e36a
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions test/mudbrick/content_stream_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,13 @@ defmodule Mudbrick.ContentStreamTest do
b\
""")

[apostrophe, tj, leading | _] = content_stream.value.operations

assert Object.from(leading) |> to_string() == "12.0 TL"
assert Object.from(tj) |> to_string() == "<00A5> Tj"
assert Object.from(apostrophe) |> to_string() == "<00B4> '"
assert content_stream.value.operations
|> render(3) ==
"""
12.0 TL
<00A5> Tj
<00B4> '\
"""
end

test "font is assigned to the operator struct when font descendant present" do
Expand Down Expand Up @@ -68,11 +70,20 @@ defmodule Mudbrick.ContentStreamTest do
|> text_position(0, 700)
|> text("CO₂")

[show_text_operation | _] = content_stream.value.operations

assert Object.from(show_text_operation) |> to_string() == """
<001100550174> Tj\
"""
assert content_stream.value.operations
|> render(1) ==
"""
<001100550174> Tj\
"""
end
end

defp render(ops, n) do
ops
|> Enum.take(n)
|> Enum.reverse()
|> Enum.map_join("\n", fn op ->
Object.from(op) |> to_string()
end)
end
end

0 comments on commit 0e4e36a

Please sign in to comment.