Skip to content

Commit

Permalink
Fix test when xml attribute order changed
Browse files Browse the repository at this point in the history
The order should not matter and is also on a deprecated function.
  • Loading branch information
wkirschbaum committed Apr 20, 2024
1 parent 0bfb716 commit 730796f
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions test/xml_builder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ defmodule XmlBuilderTest do
test "element with attributes" do
warning =
capture_io(:stderr, fn ->
assert doc(:person, %{occupation: "Developer", city: "Montreal"}) ==
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person city="Montreal" occupation="Developer"/>|
assert doc(:person, %{occupation: "Developer", city: "Montreal"}) in [
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person city="Montreal" occupation="Developer"/>|,
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person occupation="Developer" city="Montreal"/>|
]

assert doc(:person, %{}) == ~s|<?xml version="1.0" encoding="UTF-8"?>\n<person/>|
end)
Expand All @@ -174,11 +176,15 @@ defmodule XmlBuilderTest do
test "element with attributes and content" do
warning =
capture_io(:stderr, fn ->
assert doc(:person, %{occupation: "Developer", city: "Montreal"}, "Josh") ==
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person city="Montreal" occupation="Developer">Josh</person>|
assert doc(:person, %{occupation: "Developer", city: "Montreal"}, "Josh") in [
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person city="Montreal" occupation="Developer">Josh</person>|,
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person occupation="Developer" city="Montreal">Josh</person>|
]

assert doc(:person, %{occupation: "Developer", city: "Montreal"}, nil) ==
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person city="Montreal" occupation="Developer"/>|
assert doc(:person, %{occupation: "Developer", city: "Montreal"}, nil) in [
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person city="Montreal" occupation="Developer"/>|,
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person occupation="Developer" city="Montreal"/>|
]

assert doc(:person, %{}, "Josh") ==
~s|<?xml version="1.0" encoding="UTF-8"?>\n<person>Josh</person>|
Expand Down

0 comments on commit 730796f

Please sign in to comment.