Software /
code /
prosody
Comparison
spec/util_stanza_spec.lua @ 10717:05e4645fc9b3
util.stanza: Add method returning stanza with added indentation
Adds indentation and line breaks to stanzas, to make stanzas easier to
read for humans.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 12 Apr 2020 17:03:05 +0200 |
parent | 10503:e25a1a9a6e7e |
child | 11083:4d12a6785531 |
comparison
equal
deleted
inserted
replaced
10716:29575fe64860 | 10717:05e4645fc9b3 |
---|---|
457 assert.equal(0, #s2); | 457 assert.equal(0, #s2); |
458 assert.equal(0, #s2.tags); | 458 assert.equal(0, #s2.tags); |
459 assert.equal("true", s2.attr["my-awesome-ns\1bar"]); | 459 assert.equal("true", s2.attr["my-awesome-ns\1bar"]); |
460 end); | 460 end); |
461 end); | 461 end); |
462 | |
463 describe("indent", function () | |
464 local s = st.stanza("foo"):text("\n"):tag("bar"):tag("baz"):up():text_tag("cow", "moo"); | |
465 assert.equal("<foo>\n\t<bar>\n\t\t<baz/>\n\t\t<cow>moo</cow>\n\t</bar>\n</foo>", tostring(s:indent())); | |
466 assert.equal("<foo>\n <bar>\n <baz/>\n <cow>moo</cow>\n </bar>\n</foo>", tostring(s:indent(1, " "))); | |
467 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"))); | |
468 end); | |
469 | |
462 end); | 470 end); |