aboutsummaryrefslogtreecommitdiffstats
path: root/spec/util_stanza_spec.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2020-04-12 17:03:05 +0200
committerKim Alvefur <zash@zash.se>2020-04-12 17:03:05 +0200
commitf0ac29acf0d1d6cd947ac2e20dc6bcbbbddf76f6 (patch)
tree2eea1e91bb889155b5f1efda5c82a5b75c0561d8 /spec/util_stanza_spec.lua
parent608d6dd75669b3b8bcc526b91dad865ae89af79a (diff)
downloadprosody-f0ac29acf0d1d6cd947ac2e20dc6bcbbbddf76f6.tar.gz
prosody-f0ac29acf0d1d6cd947ac2e20dc6bcbbbddf76f6.zip
util.stanza: Add method returning stanza with added indentation
Adds indentation and line breaks to stanzas, to make stanzas easier to read for humans.
Diffstat (limited to 'spec/util_stanza_spec.lua')
-rw-r--r--spec/util_stanza_spec.lua8
1 files changed, 8 insertions, 0 deletions
diff --git a/spec/util_stanza_spec.lua b/spec/util_stanza_spec.lua
index d38a609f..efe3e47e 100644
--- a/spec/util_stanza_spec.lua
+++ b/spec/util_stanza_spec.lua
@@ -459,4 +459,12 @@ describe("util.stanza", function()
assert.equal("true", s2.attr["my-awesome-ns\1bar"]);
end);
end);
+
+ describe("indent", function ()
+ local s = st.stanza("foo"):text("\n"):tag("bar"):tag("baz"):up():text_tag("cow", "moo");
+ assert.equal("<foo>\n\t<bar>\n\t\t<baz/>\n\t\t<cow>moo</cow>\n\t</bar>\n</foo>", tostring(s:indent()));
+ assert.equal("<foo>\n <bar>\n <baz/>\n <cow>moo</cow>\n </bar>\n</foo>", tostring(s:indent(1, " ")));
+ assert.equal("<foo>\n\t\t<bar>\n\t\t\t<baz/>\n\t\t\t<cow>moo</cow>\n\t\t</bar>\n\t</foo>", tostring(s:indent(2, "\t")));
+ end);
+
end);