27 xml = {namespace = "urn:xmpp:delay"; name = "delay"}; |
27 xml = {namespace = "urn:xmpp:delay"; name = "delay"}; |
28 properties = {stamp = attr(); from = attr(); reason = {type = "string"; xml = {text = true}}}; |
28 properties = {stamp = attr(); from = attr(); reason = {type = "string"; xml = {text = true}}}; |
29 }; |
29 }; |
30 state = { |
30 state = { |
31 type = "string"; |
31 type = "string"; |
|
32 enum = { |
|
33 "active", |
|
34 "inactive", |
|
35 "gone", |
|
36 "composing", |
|
37 "paused", |
|
38 }; |
32 xml = {x_name_is_value = true; namespace = "http://jabber.org/protocol/chatstates"}; |
39 xml = {x_name_is_value = true; namespace = "http://jabber.org/protocol/chatstates"}; |
33 }; |
40 }; |
34 fallback = { |
41 fallback = { |
35 type = "boolean"; |
42 type = "boolean"; |
36 xml = {x_name_is_value = true; name = "fallback"; namespace = "urn:xmpp:fallback:0"}; |
43 xml = {x_name_is_value = true; name = "fallback"; namespace = "urn:xmpp:fallback:0"}; |
44 |
51 |
45 x = xml.parse [[ |
52 x = xml.parse [[ |
46 <message xmlns="jabber:client" xml:lang="en" to="a@test" from="b@test" type="chat" id="1"> |
53 <message xmlns="jabber:client" xml:lang="en" to="a@test" from="b@test" type="chat" id="1"> |
47 <body>Hello</body> |
54 <body>Hello</body> |
48 <delay xmlns='urn:xmpp:delay' from='test' stamp='2021-03-07T15:59:08+00:00'>Becasue</delay> |
55 <delay xmlns='urn:xmpp:delay' from='test' stamp='2021-03-07T15:59:08+00:00'>Becasue</delay> |
|
56 <UNRELATED xmlns='http://jabber.org/protocol/chatstates'/> |
49 <active xmlns='http://jabber.org/protocol/chatstates'/> |
57 <active xmlns='http://jabber.org/protocol/chatstates'/> |
50 <fallback xmlns='urn:xmpp:fallback:0'/> |
58 <fallback xmlns='urn:xmpp:fallback:0'/> |
51 <origin-id xmlns='urn:xmpp:sid:0' id='qgkmMdPB'/> |
59 <origin-id xmlns='urn:xmpp:sid:0' id='qgkmMdPB'/> |
52 </message> |
60 </message> |
53 ]]; |
61 ]]; |
75 describe("unparse", function() |
83 describe("unparse", function() |
76 it("works", function() |
84 it("works", function() |
77 local u = map.unparse(s, d); |
85 local u = map.unparse(s, d); |
78 assert.equal("message", u.name); |
86 assert.equal("message", u.name); |
79 assert.same(x.attr, u.attr); |
87 assert.same(x.attr, u.attr); |
80 assert.equal(#x.tags, #u.tags) |
88 assert.equal(#x.tags-1, #u.tags) |
81 assert.equal(x:get_child_text("body"), u:get_child_text("body")); |
89 assert.equal(x:get_child_text("body"), u:get_child_text("body")); |
82 assert.equal(x:get_child_text("delay", "urn:xmpp:delay"), u:get_child_text("delay", "urn:xmpp:delay")); |
90 assert.equal(x:get_child_text("delay", "urn:xmpp:delay"), u:get_child_text("delay", "urn:xmpp:delay")); |
83 assert.same(x:get_child("delay", "urn:xmpp:delay").attr, u:get_child("delay", "urn:xmpp:delay").attr); |
91 assert.same(x:get_child("delay", "urn:xmpp:delay").attr, u:get_child("delay", "urn:xmpp:delay").attr); |
84 assert.same(x:get_child("origin-id", "urn:xmpp:sid:0").attr, u:get_child("origin-id", "urn:xmpp:sid:0").attr); |
92 assert.same(x:get_child("origin-id", "urn:xmpp:sid:0").attr, u:get_child("origin-id", "urn:xmpp:sid:0").attr); |
85 end); |
93 end); |