1 defmodule Pleroma.XmlBuilderTest do
3 alias Pleroma.XmlBuilder
5 test "Build a basic xml string from a tuple" do
6 data = {:feed, %{xmlns: "http://www.w3.org/2005/Atom"}, "Some content"}
8 expected_xml = "<feed xmlns=\"http://www.w3.org/2005/Atom\">Some content</feed>"
10 assert XmlBuilder.to_xml(data) == expected_xml
13 test "returns a complete document" do
14 data = {:feed, %{xmlns: "http://www.w3.org/2005/Atom"}, "Some content"}
17 "<?xml version=\"1.0\" encoding=\"UTF-8\"?><feed xmlns=\"http://www.w3.org/2005/Atom\">Some content</feed>"
19 assert XmlBuilder.to_doc(data) == expected_xml
22 test "Works without attributes" do
28 expected_xml = "<feed>Some content</feed>"
30 assert XmlBuilder.to_xml(data) == expected_xml
33 test "It works with nested tuples" do
38 {:lament, %{configuration: "puzzle"}, "pinhead"}
43 ~s[<feed><guy>brush</guy><lament configuration="puzzle">pinhead</lament></feed>]
45 assert XmlBuilder.to_xml(data) == expected_xml
48 test "Represents NaiveDateTime as iso8601" do
49 assert XmlBuilder.to_xml(~N[2000-01-01 13:13:33]) == "2000-01-01T13:13:33"
52 test "Uses self-closing tags when no content is giving" do
58 expected_xml = ~s[<link rel="self" />]
59 assert XmlBuilder.to_xml(data) == expected_xml