Comparison

spec/util_datamapper_spec.lua @ 11436:5df9ffc25bb4

util.datamapper: Add 'unparse' for turning tables into XML
author Kim Alvefur <zash@zash.se>
date Sun, 07 Mar 2021 00:57:36 +0100
parent 11435:a1fa6202fa13
child 11437:87a684df4b65
comparison
equal deleted inserted replaced
11435:a1fa6202fa13 11436:5df9ffc25bb4
51 describe("parse", function() 51 describe("parse", function()
52 it("works", function() 52 it("works", function()
53 assert.same(d, map.parse(s, x)); 53 assert.same(d, map.parse(s, x));
54 end); 54 end);
55 end); 55 end);
56
57 describe("unparse", function()
58 it("works", function()
59 local u = map.unparse(s, d);
60 assert.equal("message", u.name);
61 assert.same(x.attr, u.attr);
62 assert.equal(#x.tags, #u.tags)
63 assert.equal(x:get_child_text("body"), u:get_child_text("body"));
64 assert.equal(x:get_child_text("delay", "urn:xmpp:delay"), u:get_child_text("delay", "urn:xmpp:delay"));
65 assert.same(x:get_child("delay", "urn:xmpp:delay").attr, u:get_child("delay", "urn:xmpp:delay").attr);
66 end);
67 end);
56 end) 68 end)