From f0ac29acf0d1d6cd947ac2e20dc6bcbbbddf76f6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 12 Apr 2020 17:03:05 +0200 Subject: util.stanza: Add method returning stanza with added indentation Adds indentation and line breaks to stanzas, to make stanzas easier to read for humans. --- spec/util_stanza_spec.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'spec') 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("\n\t\n\t\t\n\t\tmoo\n\t\n", tostring(s:indent())); + assert.equal("\n \n \n moo\n \n", tostring(s:indent(1, " "))); + assert.equal("\n\t\t\n\t\t\t\n\t\t\tmoo\n\t\t\n\t", tostring(s:indent(2, "\t"))); + end); + end); -- cgit v1.2.3