From 5eb232106f834eeb7bfe0da4cd55ae3b35df73ec Mon Sep 17 00:00:00 2001 From: Zearin Date: Sun, 21 May 2023 12:09:37 -0400 Subject: [PATCH] test(looping): Add test for #179 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Issue 179: > bug: “`loopContent.map is not a function (via TypeError)`” #179 --- test/looping-test.js | 27 +++++++++++++++++++-- test/stubs/looping/issue-179-iterables.webc | 24 ++++++++++++++++++ 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 test/stubs/looping/issue-179-iterables.webc diff --git a/test/looping-test.js b/test/looping-test.js index a2d9f1d..31bee3c 100644 --- a/test/looping-test.js +++ b/test/looping-test.js @@ -99,6 +99,29 @@ test("webc:for issue #139", async t => { 3`); }); +// looping over iterables that are not Objects or Arrays +test("webc:for issue #179", async t => { + let component = new WebC(); + + component.setInputPath("./test/stubs/looping/issue-179-iterables.webc"); + + let { html } = await component.compile(); + + t.is(html.trim(), `
+
one
+
1
+
two
+
2
+
three
+
3
+
+`); +}); + test("script webc:setup feeds data for looping", async t => { let component = new WebC(); @@ -119,11 +142,11 @@ test("nesting webc:for over component hierarchy", async t => { component.setInputPath("./test/stubs/looping/complex/entry-point.webc"); let { html } = await component.compile({data:{contacts}}); - + t.true(html.indexOf(``) > -1) t.true(html.indexOf(`
  • Ross - 1
  • `) > -1) t.true(html.indexOf(`
    `) > -1) t.true(html.indexOf(`
    Chandler
    `) > -1) t.true(html.indexOf(`border: 1px solid green;`) > -1) - + }) diff --git a/test/stubs/looping/issue-179-iterables.webc b/test/stubs/looping/issue-179-iterables.webc new file mode 100644 index 0000000..50aa1b2 --- /dev/null +++ b/test/stubs/looping/issue-179-iterables.webc @@ -0,0 +1,24 @@ + +
    + +
    +