Skip to content

Commit

Permalink
test: add nested list (#139)
Browse files Browse the repository at this point in the history
  • Loading branch information
theisel committed Apr 21, 2024
1 parent ccaf3a0 commit 7582c73
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
59 changes: 59 additions & 0 deletions lab/src/pages/list/nested.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
import Layout from "../../layouts/Default.astro";
import { PortableText } from "astro-portabletext";
const blocks = [
{
_type: "block",
style: "normal",
children: [
{
_type: "span",
text: "1",
},
],
level: 1,
listItem: "bullet",
},
{
_type: "block",
style: "normal",
level: 2,
listItem: "bullet",
children: [
{
_type: "span",
text: "1.1",
},
],
},
{
_type: "block",
style: "normal",
level: 3,
listItem: "bullet",
children: [
{
_type: "span",
text: "1.1.1",
},
],
},
{
_type: "block",
style: "normal",
children: [
{
_type: "span",
text: "2",
},
],
level: 1,
listItem: "bullet",
},
];
---

<Layout>
<PortableText value={blocks} />
</Layout>
9 changes: 9 additions & 0 deletions lab/src/test/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,13 @@ list("unknown", async () => {
assert.is($el.attr("data-portabletext-unknown"), "list");
});

list("nested", async () => {
const $ = await fetchContent("list/nested");

assert.match(
$("body").html().trim(),
/^<ul>\s*<li>\s*1\s*<ul>\s*<li>\s*1\.1\s*<ul>\s*<li>\s*1\.1\.1\s*<\/li>\s*<\/ul>\s*<\/li>\s*<\/ul>\s*<\/li>\s*<li>\s*2\s*<\/li>\s*<\/ul>$/
);
});

list.run();

0 comments on commit 7582c73

Please sign in to comment.