Software /
code /
prosody
Changeset
9000:4d64ff0719a6
util.stanza: Brief tests for :remove_children
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 08 Jul 2018 19:13:14 +0200 |
parents | 8999:a2a4c225a3f8 |
children | 9001:23070882f3d4 |
files | spec/util_stanza_spec.lua |
diffstat | 1 files changed, 22 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/spec/util_stanza_spec.lua Sun Jul 08 19:12:17 2018 +0200 +++ b/spec/util_stanza_spec.lua Sun Jul 08 19:13:14 2018 +0200 @@ -235,4 +235,26 @@ assert.falsy(st.is_stanza({})); end); end); + + describe("#remove_children", function () + it("should work", function () + local s = st.stanza("x", {xmlns="test"}) + :tag("y", {xmlns="test"}):up() + :tag("z", {xmlns="test2"}):up() + :tag("x", {xmlns="test2"}):up() + + s:remove_children("x"); + assert.falsy(s:get_child("x")) + assert.truthy(s:get_child("z","test2")); + assert.truthy(s:get_child("x","test2")); + + s:remove_children(nil, "test2"); + assert.truthy(s:get_child("y")) + assert.falsy(s:get_child(nil,"test2")); + + s:remove_children(); + assert.falsy(s.tags[1]); + end); + end); + end);