Skip to content

Commit 0e4e36a

Browse files
committed
Refactor test
1 parent 1318b6f commit 0e4e36a

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

test/mudbrick/content_stream_test.exs

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,13 @@ defmodule Mudbrick.ContentStreamTest do
2525
b\
2626
""")
2727

28-
[apostrophe, tj, leading | _] = content_stream.value.operations
29-
30-
assert Object.from(leading) |> to_string() == "12.0 TL"
31-
assert Object.from(tj) |> to_string() == "<00A5> Tj"
32-
assert Object.from(apostrophe) |> to_string() == "<00B4> '"
28+
assert content_stream.value.operations
29+
|> render(3) ==
30+
"""
31+
12.0 TL
32+
<00A5> Tj
33+
<00B4> '\
34+
"""
3335
end
3436

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

71-
[show_text_operation | _] = content_stream.value.operations
72-
73-
assert Object.from(show_text_operation) |> to_string() == """
74-
<001100550174> Tj\
75-
"""
73+
assert content_stream.value.operations
74+
|> render(1) ==
75+
"""
76+
<001100550174> Tj\
77+
"""
7678
end
7779
end
80+
81+
defp render(ops, n) do
82+
ops
83+
|> Enum.take(n)
84+
|> Enum.reverse()
85+
|> Enum.map_join("\n", fn op ->
86+
Object.from(op) |> to_string()
87+
end)
88+
end
7889
end

0 commit comments

Comments
 (0)