spec/stanzacmp_spec.lua

changeset 153
f83ea6e5c3d8
parent 151
8191f165b9dd
child 170
db73c4c317ce
equal deleted inserted replaced
152:ba8219ac7484 153:f83ea6e5c3d8
43 local s2 = st.message({ to = "foo", from = "bar"}); 43 local s2 = st.message({ to = "foo", from = "bar"});
44 44
45 yes(s1, s2); 45 yes(s1, s2);
46 yes(s2, s1); 46 yes(s2, s1);
47 47
48 s1.attr.to = nil; 48 end);
49
50 it("should allow additional top-level attributes by default", function ()
51 local s1 = [[<message to="foo" />]];
52 local s2 = [[<message to="foo" from="bar" />]];
49 53
50 yes(s1, s2); 54 yes(s1, s2);
51 no(s2, s1); 55 no(s2, s1);
52 56
53 s1.attr.to = "foo"; 57 end);
54 yes(s1, s2); 58
59 it("should work", function ()
60 -- Legacy tests, need to be broken up (pain to debug when it goes wrong)
61 local s1 = st.message({ to = "foo", from = "bar"});
62 local s2 = st.message({ to = "foo", from = "bar"});
63
64 yes(s1, s2);
65 yes(s2, s1);
55 66
56 s2:tag("blah", { xmlns = "foobar" }); 67 s2:tag("blah", { xmlns = "foobar" });
57 68
58 yes(s1, s2); 69 yes(s1, s2);
59 no(s2, s1); 70 no(s2, s1);
113 124
114 it("should match unordered children at the top level", function () 125 it("should match unordered children at the top level", function ()
115 yes("<foo><one/><two/></foo>", "<foo><two/><one/></foo>"); 126 yes("<foo><one/><two/></foo>", "<foo><two/><one/></foo>");
116 end); 127 end);
117 128
118 it("should not match unordered children", function () 129 describe("unordered children", function ()
119 no("<foo><one><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>"); 130 it("in the default namespace should match by default", function ()
131 yes("<foo><one><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>");
132 end)
133
134 it("in the default namespace should not match in strict mode", function ()
135 no("<foo><one scansion:strict='true'><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>");
136 end)
137
138 it("in a different namespace should not match", function ()
139 no("<foo><one xmlns='foo'><a/><b/></one></foo>", "<foo><one xmlns='foo'><b/><a/></one></foo>");
140 end)
141 end);
142
143 it("should match unordered children within the same namespace by default", function ()
144 yes("<foo><one><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>");
120 end); 145 end);
121 146
122 it("should be possible to disable ordered matching", function () 147 it("should be possible to disable ordered matching", function ()
123 yes("<foo><one scansion:strict='no'><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>"); 148 yes("<foo><one scansion:strict='no'><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>");
149 end);
150
151 it("should be possible to disable ordered matching at the top level", function ()
152 no("<foo scansion:strict='yes'><one/></foo>", "<foo><one/><two/></foo>");
124 end); 153 end);
125 154
126 it("should match when there are many children", function () 155 it("should match when there are many children", function ()
127 yes([[<s> 156 yes([[<s>
128 <x> 157 <x>
149 <query ver='1' xmlns='jabber:iq:roster'> 178 <query ver='1' xmlns='jabber:iq:roster'>
150 <item xmlns='jabber:iq:roster' jid='nurse@localhost' subscription='none'/> 179 <item xmlns='jabber:iq:roster' jid='nurse@localhost' subscription='none'/>
151 </query> 180 </query>
152 </iq>]]); 181 </iq>]]);
153 end); 182 end);
183
184 it("should match", function ()
185 yes([[<presence from='room@conference.localhost/Romeo'>
186 <x xmlns='http://jabber.org/protocol/muc#user'>
187 <status code='201' xmlns='http://jabber.org/protocol/muc#user'/>
188 <item jid='user@localhost/KeoGLEr3' role='moderator' xmlns='http://jabber.org/protocol/muc#user' affiliation='owner'/>
189 <status code='110' xmlns='http://jabber.org/protocol/muc#user'/>
190 </x>
191 </presence>]],
192 [[<presence to='user@localhost/KeoGLEr3' from='room@conference.localhost/Romeo'>
193 <x xmlns='http://jabber.org/protocol/muc#user'>
194 <status code='201' xmlns='http://jabber.org/protocol/muc#user'/>
195 <item jid='user@localhost/KeoGLEr3' role='moderator' xmlns='http://jabber.org/protocol/muc#user' affiliation='owner'/>
196 <status code='110' xmlns='http://jabber.org/protocol/muc#user'/>
197 </x>
198 </presence>]]);
199 end);
154 end); 200 end);

mercurial