Comparison

spec/util_datamapper_spec.lua @ 11480:0aa2971380e9

util.datamapper: Add test coverage of unwrapped arrays of objects Should the xml name/ns go on the array or the items schema? The later apparently.
author Kim Alvefur <zash@zash.se>
date Wed, 24 Mar 2021 00:34:22 +0100
parent 11476:83e127eb91f9
child 11487:b104c10ffce7
comparison
equal deleted inserted replaced
11479:377a9eaf7bef 11480:0aa2971380e9
55 properties = { 55 properties = {
56 to = {type = "string"; xml = {attribute = true; name = "id"}}; 56 to = {type = "string"; xml = {attribute = true; name = "id"}};
57 reactions = {type = "array"; items = {type = "string"; xml = {name = "reaction"}}}; 57 reactions = {type = "array"; items = {type = "string"; xml = {name = "reaction"}}};
58 }; 58 };
59 }; 59 };
60 stanza_ids = {
61 type = "array";
62 items = {
63 xml = {name = "stanza-id"; namespace = "urn:xmpp:sid:0"};
64 type = "object";
65 properties = {
66 id = {xml = {attribute = true}; type = "string"};
67 by = {xml = {attribute = true}; type = "string"};
68 };
69 };
70 };
60 }; 71 };
61 }; 72 };
62 73
63 x = xml.parse [[ 74 x = xml.parse [[
64 <message xmlns="jabber:client" xml:lang="en" to="a@test" from="b@test" type="chat" id="1"> 75 <message xmlns="jabber:client" xml:lang="en" to="a@test" from="b@test" type="chat" id="1">
66 <delay xmlns='urn:xmpp:delay' from='test' stamp='2021-03-07T15:59:08+00:00'>Becasue</delay> 77 <delay xmlns='urn:xmpp:delay' from='test' stamp='2021-03-07T15:59:08+00:00'>Becasue</delay>
67 <UNRELATED xmlns='http://jabber.org/protocol/chatstates'/> 78 <UNRELATED xmlns='http://jabber.org/protocol/chatstates'/>
68 <active xmlns='http://jabber.org/protocol/chatstates'/> 79 <active xmlns='http://jabber.org/protocol/chatstates'/>
69 <fallback xmlns='urn:xmpp:fallback:0'/> 80 <fallback xmlns='urn:xmpp:fallback:0'/>
70 <origin-id xmlns='urn:xmpp:sid:0' id='qgkmMdPB'/> 81 <origin-id xmlns='urn:xmpp:sid:0' id='qgkmMdPB'/>
82 <stanza-id xmlns='urn:xmpp:sid:0' id='abc1' by='muc'/>
83 <stanza-id xmlns='urn:xmpp:sid:0' id='xyz2' by='host'/>
71 <reactions id='744f6e18-a57a-11e9-a656-4889e7820c76' xmlns='urn:xmpp:reactions:0'> 84 <reactions id='744f6e18-a57a-11e9-a656-4889e7820c76' xmlns='urn:xmpp:reactions:0'>
72 <reaction>👋</reaction> 85 <reaction>👋</reaction>
73 <reaction>🐢</reaction> 86 <reaction>🐢</reaction>
74 </reactions> 87 </reactions>
75 </message> 88 </message>
84 body = "Hello"; 97 body = "Hello";
85 delay = {from = "test"; stamp = "2021-03-07T15:59:08+00:00"; reason = "Becasue"}; 98 delay = {from = "test"; stamp = "2021-03-07T15:59:08+00:00"; reason = "Becasue"};
86 state = "active"; 99 state = "active";
87 fallback = true; 100 fallback = true;
88 origin_id = "qgkmMdPB"; 101 origin_id = "qgkmMdPB";
102 stanza_ids = {{id = "abc1"; by = "muc"}; {id = "xyz2"; by = "host"}};
89 react = { 103 react = {
90 to = "744f6e18-a57a-11e9-a656-4889e7820c76"; 104 to = "744f6e18-a57a-11e9-a656-4889e7820c76";
91 reactions = { 105 reactions = {
92 "👋", 106 "👋",
93 "🐢", 107 "🐢",