X-Git-Url: https://git.enpas.org/?a=blobdiff_plain;f=tests%2Ftest_util_stanza.lua;h=fce26f3a7267da0575495e0962edf47341a2f96c;hb=b85f75e110d99b890fc22186cb2ad4d0c8f1d0a5;hp=897dab953e9fd086d12857cf93ba2a1958ec8afc;hpb=1372930c23c4c19342770a20261ef099702f1a0d;p=prosody.git diff --git a/tests/test_util_stanza.lua b/tests/test_util_stanza.lua index 897dab95..fce26f3a 100644 --- a/tests/test_util_stanza.lua +++ b/tests/test_util_stanza.lua @@ -1,7 +1,27 @@ +-- Prosody IM +-- Copyright (C) 2008-2010 Matthew Wild +-- Copyright (C) 2008-2010 Waqas Hussain +-- +-- This project is MIT/X11 licensed. Please see the +-- COPYING file in the source package for more information. +-- + + +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.last_add, "Deserialized stanza is missing last_add for adding child tags"); + assert_is(stanza2 and stanza.name, "deserialize returns a stanza"); + 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