diff options
| author | ruki <[email protected]> | 2025-11-15 19:42:39 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-15 19:42:39 +0800 |
| commit | 0a21a3d88e6126b5bb691d393bfc7499810e3d4a (patch) | |
| tree | 4cf545394fb010d40106759205528fe6a9c1d38a /tests/modules/xml/test.lua | |
| parent | cda90e424674c41c3447d4ebc3709dd290ccf512 (diff) | |
update tests
Diffstat (limited to 'tests/modules/xml/test.lua')
| -rw-r--r-- | tests/modules/xml/test.lua | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/modules/xml/test.lua b/tests/modules/xml/test.lua index 21a4e7745..e7266c919 100644 --- a/tests/modules/xml/test.lua +++ b/tests/modules/xml/test.lua @@ -143,3 +143,15 @@ function test_find_xpath(t) t:are_equal(xml.text_of(value), "bar") end +function test_find_update(t) + local doc = xml.decode("<root><item id='a'>foo</item><item id='b'/></root>") + local target = xml.find(doc, "//item[@id='a']") + t:are_not_equal(target, nil) + target.attrs.lang = "en" + target.children = {xml.text("bar")} + local new_item = xml.new({name = "item", attrs = {id = "c"}, children = {xml.text("baz")}}) + table.insert(doc.children, new_item) + local encoded = xml.encode(doc) + t:are_equal(encoded, '<root><item id="a" lang="en">bar</item><item id="b"/><item id="c">baz</item></root>') +end + |
