From 3322ba6449d99b15981db10627b1498e2959cf87 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 8 Jul 2018 19:13:14 +0200 Subject: util.stanza: Brief tests for :remove_children --- spec/util_stanza_spec.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'spec') 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); -- cgit v1.2.3