From 7e61cd41cca9a8915b346a79d658bab4829d8ff1 Mon Sep 17 00:00:00 2001 From: sanine Date: Sun, 22 May 2022 12:49:14 -0500 Subject: allow adding children via marigold.h --- test.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'test.lua') diff --git a/test.lua b/test.lua index 81d5d77..2a733a1 100755 --- a/test.lua +++ b/test.lua @@ -64,3 +64,24 @@ test("marigold.h produces a correct basic tag", function() end assert(#(h1.children) == 0) end) + + +test("marigold.h correctly adds children", function() + local h = marigold.h + local div = h('div', "some stuff", { + h('p', "the first paragraph"), + h('p', "the second paragraph"), + }) + + assert(div.tag == 'div') + assert(div.content == "some stuff") + -- still should have nothing in the attributes table + for k, v in ipairs(div.attributes) do + assert(false, string.format("%s, %s", tostring(k), tostring(v))) + end + assert(#div.children == 2) + assert(div.children[1].tag == 'p') + assert(div.children[1].content == 'the first paragraph') + assert(div.children[2].tag == 'p') + assert(div.children[2].content == 'the second paragraph') +end) -- cgit v1.2.1