aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_util_stanza.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-01-09 19:19:06 +0000
committerMatthew Wild <mwild1@gmail.com>2009-01-09 19:19:06 +0000
commitfa0e1edd87a3224e998fd4bad37c03c9d2bfe027 (patch)
tree3915120b658649a92eb47bb1663677607fa0e083 /tests/test_util_stanza.lua
parent962ab41be7c3f2377ba4dabf7b9061dcdb1139a7 (diff)
parentbd17ed3f7d3a20cd94ccadbe98bb057f8b8675fc (diff)
downloadprosody-fa0e1edd87a3224e998fd4bad37c03c9d2bfe027.tar.gz
prosody-fa0e1edd87a3224e998fd4bad37c03c9d2bfe027.zip
Automated merge with http://waqas.ath.cx:8000/
Diffstat (limited to 'tests/test_util_stanza.lua')
-rw-r--r--tests/test_util_stanza.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/test_util_stanza.lua b/tests/test_util_stanza.lua
new file mode 100644
index 00000000..f4c4810a
--- /dev/null
+++ b/tests/test_util_stanza.lua
@@ -0,0 +1,20 @@
+
+function preserialize(preserialize, st)
+ local stanza = st.stanza("message", { a = "a" });
+ local stanza2 = preserialize(stanza);
+ assert_is(stanza2 and stanza.name, "preserialize returns a stanza");
+ assert_is_not(stanza2.tags, "Preserialized stanza has no tag list");
+ assert_is_not(stanza2.last_add, "Preserialized stanza has no last_add marker");
+ assert_is_not(getmetatable(stanza2), "Preserialized stanza has no metatable");
+end
+
+function deserialize(deserialize, st)
+ local stanza = st.stanza("message", { a = "a" });
+
+ local stanza2 = deserialize(st.preserialize(stanza));
+ assert_is(stanza2 and stanza.name, "deserialize returns a stanza");
+ assert_is(stanza2.last_add, "Deserialized stanza is missing last_add for adding child tags");
+ assert_table(stanza2.attr, "Deserialized stanza has attributes");
+ assert_equal(stanza2.attr.a, "a", "Deserialized stanza retains attributes");
+ assert_table(getmetatable(stanza2), "Deserialized stanza has metatable");
+end