From d20ea9b87e6e4071aca1a6895041d9e82ebb8691 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 6 Mar 2021 23:14:23 +0100 Subject: util.datamapper: Invent extension for using tag name as value Useful for certain enum-like uses where the element name is the relevant information, e.g. chat states. --- spec/util_datamapper_spec.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'spec') diff --git a/spec/util_datamapper_spec.lua b/spec/util_datamapper_spec.lua index 2ef828f2..2a149b1c 100644 --- a/spec/util_datamapper_spec.lua +++ b/spec/util_datamapper_spec.lua @@ -27,15 +27,20 @@ describe("util.datampper", function() xml = {namespace = "urn:xmpp:delay"; name = "delay"}; properties = {stamp = attr(); from = attr(); reason = {type = "string"; xml = {text = true}}}; }; + state = { + type = "string"; + xml = {x_name_is_value = true; namespace = "http://jabber.org/protocol/chatstates"}; + }; }; }; x = xml.parse [[ - - Hello - Becasue - - ]]; + + Hello + Becasue + + + ]]; d = { to = "a@test"; @@ -45,6 +50,7 @@ describe("util.datampper", function() lang = "en"; body = "Hello"; delay = {from = "test"; stamp = "2021-03-07T15:59:08+00:00"; reason = "Becasue"}; + state = "active"; }; end); -- cgit v1.2.3