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" }
16 expected_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><feed xmlns=\"http://www.w3.org/2005/Atom\">Some content</feed>"
18 assert XmlBuilder.to_doc(data) == expected_xml
21 test "Works without attributes" do
27 expected_xml = "<feed>Some content</feed>"
29 assert XmlBuilder.to_xml(data) == expected_xml
32 test "It works with nested tuples" do
37 {:lament, %{ configuration: "puzzle" }, "pinhead" }
41 expected_xml = ~s[<feed><guy>brush</guy><lament configuration="puzzle">pinhead</lament></feed>]
43 assert XmlBuilder.to_xml(data) == expected_xml
46 test "Represents NaiveDateTime as iso8601" do
47 assert XmlBuilder.to_xml(~N[2000-01-01 13:13:33]) == "2000-01-01T13:13:33"
50 test "Uses self-closing tags when no content is giving" do
56 expected_xml = ~s[<link rel="self" />]
57 assert XmlBuilder.to_xml(data) == expected_xml