diff options
author | Kim Alvefur <zash@zash.se> | 2018-07-08 19:13:14 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-07-08 19:13:14 +0200 |
commit | b27447e37d1cd78a82dce30bb5ced506ff0cdb6f (patch) | |
tree | f6f4287c1be0723607c6345861090786f5cdc57c /spec/util_stanza_spec.lua | |
parent | 3247d46c823fc8ab113fb66bd405b1762a16909c (diff) | |
download | prosody-b27447e37d1cd78a82dce30bb5ced506ff0cdb6f.tar.gz prosody-b27447e37d1cd78a82dce30bb5ced506ff0cdb6f.zip |
util.stanza: Brief tests for :remove_children
Diffstat (limited to 'spec/util_stanza_spec.lua')
-rw-r--r-- | spec/util_stanza_spec.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/util_stanza_spec.lua b/spec/util_stanza_spec.lua index 36bf213f..8abc6096 100644 --- a/spec/util_stanza_spec.lua +++ b/spec/util_stanza_spec.lua @@ -235,4 +235,26 @@ describe("util.stanza", function() 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); |