Fri, 01 Feb 2019 11:22:20 +0000
docs: Add initial documentation
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
1 | --luacheck: std +busted |
93 | 2 | local stanzacmp = require "scansion.stanzacmp"; |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
3 | require "verse"; |
93 | 4 | local st = require "util.stanza"; |
98
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
5 | local xml = require "scansion.xml"; |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
6 | |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
7 | local function parse(...) |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
8 | local n = select("#", ...); |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
9 | local out = {}; |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
10 | for i = 1, n do |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
11 | local v = (select(i, ...)); |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
12 | if type(v) == "string" then |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
13 | out[i] = xml.parse(v); |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
14 | else |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
15 | out[i] = v; |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
16 | end |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
17 | end |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
18 | return table.unpack(out, 1, n); |
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
19 | end |
93 | 20 | |
21 | local function yes(s1, s2) | |
98
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
22 | s1, s2 = parse(s1, s2); |
93 | 23 | if not stanzacmp.stanzas_match(s1, s2) then |
24 | print("s1", s1) | |
25 | print("s2", s2) | |
26 | print("literal", tostring(s1) == tostring(s2)); | |
27 | assert(false, "No match, but they should."); | |
28 | end | |
29 | end | |
30 | ||
31 | local function no(s1, s2) | |
98
88a3e03f4b9f
spec/stanzacmp: Allow passing XML strings to yes()/no() to avoid manual stanza building
Matthew Wild <mwild1@gmail.com>
parents:
95
diff
changeset
|
32 | s1, s2 = parse(s1, s2); |
93 | 33 | if stanzacmp.stanzas_match(s1, s2) then |
34 | print("s1", s1) | |
35 | print("s2", s2) | |
36 | assert(false, "Match, but they should not."); | |
37 | end | |
38 | end | |
39 | ||
40 | describe("stanzacmp", function () | |
41 | it("should work", function () | |
42 | local s1 = st.message({ to = "foo", from = "bar"}); | |
43 | local s2 = st.message({ to = "foo", from = "bar"}); | |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
44 | |
93 | 45 | yes(s1, s2); |
46 | yes(s2, s1); | |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
47 | |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
48 | end); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
49 | |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
50 | it("should allow additional top-level attributes by default", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
51 | local s1 = [[<message to="foo" />]]; |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
52 | local s2 = [[<message to="foo" from="bar" />]]; |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
53 | |
93 | 54 | yes(s1, s2); |
55 | no(s2, s1); | |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
56 | |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
57 | end); |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
58 | |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
59 | it("should work", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
60 | -- Legacy tests, need to be broken up (pain to debug when it goes wrong) |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
61 | local s1 = st.message({ to = "foo", from = "bar"}); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
62 | local s2 = st.message({ to = "foo", from = "bar"}); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
63 | |
93 | 64 | yes(s1, s2); |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
65 | yes(s2, s1); |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
66 | |
93 | 67 | s2:tag("blah", { xmlns = "foobar" }); |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
68 | |
93 | 69 | yes(s1, s2); |
70 | no(s2, s1); | |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
71 | |
93 | 72 | s1:tag("blah", { xmlns = "foobar" }); |
73 | yes(s1, s2); | |
74 | yes(s2, s1); | |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
75 | |
93 | 76 | s1:tag("a"); |
77 | no(s1, s2); | |
78 | s2:tag("a"); | |
79 | yes(s1, s2); | |
80 | s2:up():up(); | |
81 | s2:tag("extension", { xmlns = "blah" }); | |
82 | yes(s1, s2); | |
83 | s2:tag("b"); | |
84 | yes(s1, s2); | |
85 | s1:up():up(); | |
86 | s1:tag("extension", { xmlns = "blah" }); | |
87 | no(s1, s2); | |
88 | s1:tag("b"); | |
89 | yes(s1, s2); | |
90 | s1:tag("c", { n = "1" }); | |
91 | no(s1, s2); | |
92 | end); | |
95
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
93 | it("should allow matching any attribute value with {scansion:any}", function () |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
94 | --[[ |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
95 | <message from="user@localhost/71652fc8-93cb-40c7-8220-47ce80cc417b" type="chat"> |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
96 | <body>Hello Juliet, are you there?</body> |
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
97 | <delay xmlns="urn:xmpp:delay" from="localhost"/> |
95
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
98 | </message> |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
99 | ]] |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
100 | |
95
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
101 | local s01 = st.message({ from = "user@localhost/71652fc8-93cb-40c7-8220-47ce80cc417b", type = "chat" }) |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
102 | :tag("body"):text("Hello Juliet, are you there?"):up() |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
103 | :tag("delay", { xmlns = "urn:xmpp:delay", from = "localhost", stamp = "{scansion:any}" }):up(); |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
104 | |
95
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
105 | --[[ |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
106 | <message to="juliet@localhost" type="chat" from="user@localhost/71652fc8-93cb-40c7-8220-47ce80cc417b"> |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
107 | <body>Hello Juliet, are you there?</body> |
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
108 | <stanza-id xmlns="urn:xmpp:sid:0" by="user@localhost" id="eb9eaf13-384e-47d1-a6c0-303ef4f1ac70"/> |
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
109 | <stanza-id xmlns="urn:xmpp:sid:0" by="juliet@localhost" id="f6c6f61d-0b15-46d6-9f69-bca1640401d1"/> |
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
110 | <delay xmlns="urn:xmpp:delay" stamp="2017-05-07T09:46:21Z" from="localhost"/> |
95
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
111 | </message> |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
112 | ]] |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
113 | |
95
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
114 | local s02 = st.message({ to = "juliet@localhost", from = "user@localhost/71652fc8-93cb-40c7-8220-47ce80cc417b", type = "chat" }) |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
115 | :tag("body"):text("Hello Juliet, are you there?"):up() |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
116 | :tag("stanza-id", { xmlns = "urn:xmpp:sid:0", by = "user@localhost", id = "eb9eaf13-384e-47d1-a6c0-303ef4f1ac70" }):up() |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
117 | :tag("stanza-id", { xmlns = "urn:xmpp:sid:0", by = "juliet@localhost", id = "f6c6f61d-0b15-46d6-9f69-bca1640401d1" }):up() |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
118 | :tag("delay", { xmlns = "urn:xmpp:delay", stamp = "2017-05-07T09:46:21Z", from = "localhost" }):up(); |
100
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
119 | |
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
120 | |
f2b3e8e6690f
stanzacmp tests: Fix some [luacheck] warnings
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
121 | |
95
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
122 | yes(s01, s02); |
a1e7ad9336db
tests: Add test for scansion:any
Matthew Wild <mwild1@gmail.com>
parents:
93
diff
changeset
|
123 | end); |
99
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
124 | |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
125 | it("should match unordered children at the top level", function () |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
126 | yes("<foo><one/><two/></foo>", "<foo><two/><one/></foo>"); |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
127 | end); |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
128 | |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
129 | describe("unordered children", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
130 | it("in the default namespace should match by default", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
131 | yes("<foo><one><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>"); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
132 | end) |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
133 | |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
134 | it("in the default namespace should not match in strict mode", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
135 | no("<foo><one scansion:strict='true'><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>"); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
136 | end) |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
137 | |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
138 | it("in a different namespace should not match", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
139 | no("<foo><one xmlns='foo'><a/><b/></one></foo>", "<foo><one xmlns='foo'><b/><a/></one></foo>"); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
140 | end) |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
141 | end); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
142 | |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
143 | it("should match unordered children within the same namespace by default", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
144 | yes("<foo><one><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>"); |
99
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
145 | end); |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
146 | |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
147 | it("should be possible to disable ordered matching", function () |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
148 | yes("<foo><one scansion:strict='no'><a/><b/></one></foo>", "<foo><one><b/><a/></one></foo>"); |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
98
diff
changeset
|
149 | end); |
101
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
150 | |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
151 | it("should be possible to disable ordered matching at the top level", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
152 | no("<foo scansion:strict='yes'><one/></foo>", "<foo><one/><two/></foo>"); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
153 | end); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
154 | |
101
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
155 | it("should match when there are many children", function () |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
156 | yes([[<s> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
157 | <x> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
158 | <a/> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
159 | <b/> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
160 | <c/> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
161 | </x> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
162 | </s>]] |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
163 | , [[<s> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
164 | <x> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
165 | <a/> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
166 | <b/> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
167 | <c/> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
168 | </x> |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
169 | </s>]]); |
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
100
diff
changeset
|
170 | end); |
151
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
171 | it("should match", function () |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
172 | yes([[<iq type='set' id='{scansion:any}'> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
173 | <query ver='{scansion:any}' xmlns='jabber:iq:roster'> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
174 | <item xmlns='jabber:iq:roster' jid='nurse@localhost' subscription='none'/> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
175 | </query> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
176 | </iq>]], |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
177 | [[<iq type='set' id='ncvDjS1d'> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
178 | <query ver='1' xmlns='jabber:iq:roster'> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
179 | <item xmlns='jabber:iq:roster' jid='nurse@localhost' subscription='none'/> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
180 | </query> |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
181 | </iq>]]); |
8191f165b9dd
stanzacmp: Fix for {scansion:any} in top-level attributes being ignored
Matthew Wild <mwild1@gmail.com>
parents:
101
diff
changeset
|
182 | end); |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
183 | |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
184 | it("should match", function () |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
185 | yes([[<presence from='room@conference.localhost/Romeo'> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
186 | <x xmlns='http://jabber.org/protocol/muc#user'> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
187 | <status code='201' xmlns='http://jabber.org/protocol/muc#user'/> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
188 | <item jid='user@localhost/KeoGLEr3' role='moderator' xmlns='http://jabber.org/protocol/muc#user' affiliation='owner'/> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
189 | <status code='110' xmlns='http://jabber.org/protocol/muc#user'/> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
190 | </x> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
191 | </presence>]], |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
192 | [[<presence to='user@localhost/KeoGLEr3' from='room@conference.localhost/Romeo'> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
193 | <x xmlns='http://jabber.org/protocol/muc#user'> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
194 | <status code='201' xmlns='http://jabber.org/protocol/muc#user'/> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
195 | <item jid='user@localhost/KeoGLEr3' role='moderator' xmlns='http://jabber.org/protocol/muc#user' affiliation='owner'/> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
196 | <status code='110' xmlns='http://jabber.org/protocol/muc#user'/> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
197 | </x> |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
198 | </presence>]]); |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
199 | end); |
93 | 200 | end); |