From b29e3bf980b77cf90c3841198e43bac1a24ea364 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Thu, 24 Oct 2024 15:05:33 -0400 Subject: [PATCH] tests: Add unmounting multiple items in a list --- tests/array.test.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/tests/array.test.js b/tests/array.test.js index b737575..062d27a 100644 --- a/tests/array.test.js +++ b/tests/array.test.js @@ -348,3 +348,47 @@ test("unmount from custom component indirection", () => { name: 'body', }); }); + +test("unmount two custom elements", () => { + const elem = document.createElement("body"); + const arr = OArray(); + mount(elem, arr); + + const Comp = () => { + arr.splice(0); + + return "hello world"; + }; + + const Comp2 = () => { + return "hello world"; + }; + + arr.push(h(Comp), h(Comp2)); + + assert.deepEqual(elem.tree(), { + name: 'body', + }); +}); + +test("unmount two custom elements inverted", () => { + const elem = document.createElement("body"); + const arr = OArray(); + mount(elem, arr); + + const Comp = () => { + return "hello world"; + }; + + const Comp2 = () => { + arr.splice(0); + + return "hello world"; + }; + + arr.push(h(Comp), h(Comp2)); + + assert.deepEqual(elem.tree(), { + name: 'body', + }); +});