39 lines
1.1 KiB
Plaintext
39 lines
1.1 KiB
Plaintext
namespace Tests
|
|
|
|
@suite
|
|
class XmlObjectTests extends Rooibos.BaseTestSuite
|
|
|
|
@describe("XmlObject")
|
|
|
|
@it("creates valid XML")
|
|
function _()
|
|
xml = new XmlObject()
|
|
xml.Comment("This is a person.")
|
|
if xml.Node("Person", { "name": `John "Joker" Doe`, "age": 30 })
|
|
xml.Comment("This is the address.")
|
|
xml.EmptyNode("Address", { "street": "123 Main St", "city": "Anytown", "state": "NY" })
|
|
if xml.Node("Metadata")
|
|
xml.TextNode("Data", "Some data")
|
|
xml.End()
|
|
end if
|
|
xml.End()
|
|
end if
|
|
|
|
expected = `<?xml version="1.0" encoding="UTF-8"?>
|
|
<!-- This is a person. -->
|
|
<Person age="30" name="John "Joker" Doe">
|
|
<!-- This is the address. -->
|
|
<Address city="Anytown" state="NY" street="123 Main St" />
|
|
<Metadata>
|
|
<Data>Some data</Data>
|
|
</Metadata>
|
|
</Person>
|
|
`
|
|
|
|
m.assertEqual(xml.ToXmlString(), expected)
|
|
end function
|
|
|
|
end class
|
|
|
|
end namespace
|