diff options
author | Kim Alvefur <zash@zash.se> | 2021-03-12 01:33:15 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2021-03-12 01:33:15 +0100 |
commit | 9d25c9c9acf15902082d7d2520f9e161431ddde2 (patch) | |
tree | d8dcafcf4b439841d2fc566f657bdab25cc8a3fd /spec | |
parent | 465a8b8b1a2f9424d2f8ff9620279d051b741a78 (diff) | |
download | prosody-9d25c9c9acf15902082d7d2520f9e161431ddde2.tar.gz prosody-9d25c9c9acf15902082d7d2520f9e161431ddde2.zip |
util.datamapper: Enumerated elements
E.g. error conditions or chat states.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/util_datamapper_spec.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/spec/util_datamapper_spec.lua b/spec/util_datamapper_spec.lua index 1f03c850..7f5b71de 100644 --- a/spec/util_datamapper_spec.lua +++ b/spec/util_datamapper_spec.lua @@ -29,6 +29,13 @@ describe("util.datampper", function() }; state = { type = "string"; + enum = { + "active", + "inactive", + "gone", + "composing", + "paused", + }; xml = {x_name_is_value = true; namespace = "http://jabber.org/protocol/chatstates"}; }; fallback = { @@ -46,6 +53,7 @@ describe("util.datampper", function() <message xmlns="jabber:client" xml:lang="en" to="a@test" from="b@test" type="chat" id="1"> <body>Hello</body> <delay xmlns='urn:xmpp:delay' from='test' stamp='2021-03-07T15:59:08+00:00'>Becasue</delay> + <UNRELATED xmlns='http://jabber.org/protocol/chatstates'/> <active xmlns='http://jabber.org/protocol/chatstates'/> <fallback xmlns='urn:xmpp:fallback:0'/> <origin-id xmlns='urn:xmpp:sid:0' id='qgkmMdPB'/> @@ -77,7 +85,7 @@ describe("util.datampper", function() local u = map.unparse(s, d); assert.equal("message", u.name); assert.same(x.attr, u.attr); - assert.equal(#x.tags, #u.tags) + assert.equal(#x.tags-1, #u.tags) assert.equal(x:get_child_text("body"), u:get_child_text("body")); assert.equal(x:get_child_text("delay", "urn:xmpp:delay"), u:get_child_text("delay", "urn:xmpp:delay")); assert.same(x:get_child("delay", "urn:xmpp:delay").attr, u:get_child("delay", "urn:xmpp:delay").attr); |