1 Error tests
These tests should each produce an error message.
1.1 No arguments
Expected error: No arguments provided.
{{< accordion >}}1.2 Both positional and label kwargs
Expected error: Use either a positional argument or named arguments (label), not both.
{{< accordion yaml-simple label="mixed" header="This is a header" body="This is body content" >}}1.3 Invalid label - space
Expected error: Label contains invalid characters.
{{< accordion label="inline simple" header="Header" body="Body" >}}1.4 Invalid label - special characters
Expected error: Label contains invalid characters.
{{< accordion label="inline?simple" header="Header" body="Body" >}}1.5 YAML label not found in metadata
Expected error: Accordion entry not found in yaml metadata.
{{< accordion nonexistent >}}1.6 YAML empty metadata for label
Expected error: Missing ‘header’ and ‘body’.
{{< accordion yaml-empty >}}1.7 YAML item missing header
Expected error: Item 1 is missing ‘header’.
{{< accordion yaml-missing-header >}}1.8 YAML item missing body
Expected error: Item 1 is missing ‘body’.
{{< accordion yaml-missing-body >}}1.9 YAML item missing both header and body
Expected error: Item 1 is missing ‘header’ and ‘body’.
{{< accordion yaml-missing-both >}}1.10 YAML multiple items with partial missing
Expected error: Item 3 is missing ‘body’ (items 1, 2, 4 should render).
{{< accordion yaml-many-items >}}1.11 Inline label with no metadata entry
Expected error: Accordion entry not found in yaml metadata.
{{< accordion label="inline-empty" >}}1.12 Inline missing body
Expected error: ‘body’ kwarg is missing.
{{< accordion header="Click here to view contents" >}}1.13 Inline missing header
Expected error: ‘header’ kwarg is missing.
{{< accordion body="This content is defined inline" >}}1.14 Inline header/body mixed with items
Expected error: Use either ‘header’/‘body’ or ‘items’, not both.
{{< accordion header="Header" body="Body" items='[{"header":"H","body":"B"}]' >}}1.15 Inline bad JSON in items
Expected error: Missing ‘header’ and ‘body’.
{{< accordion items='not valid json' >}}1.16 Inline JSON item missing header
Expected error: Item 2 is missing ‘header’.
{{< accordion items='[{"header":"Item 1","body":"Body 1"},{"body":"Body 2"}]' >}}1.17 Inline JSON item missing body
Expected error: Item 1 is missing ‘body’.
{{< accordion items='[{"header":"Item 1"},{"header":"Item 2","body":"Body 2"}]' >}}2 Success tests
These tests should each render a working accordion.
2.1 YAML simple single item
{{< accordion yaml-simple >}}2.2 YAML same label reused
{{< accordion yaml-simple >}}2.3 YAML collapsed state
{{< accordion yaml-collapsed >}}2.4 YAML custom id
{{< accordion yaml-custom-id >}}2.5 YAML id conflict
{{< accordion yaml-id-conflict >}}2.6 YAML markdown formatting
{{< accordion yaml-markdown >}}2.7 YAML multiline markdown
{{< accordion yaml-multiline-markdown >}}This is multiline content.
This is bold and italic.
- List item 1
- List item 2
| Col1 | Col2 |
|---|---|
| A | B |
2.8 YAML HTML formatting
{{< accordion yaml-html >}}2.9 YAML multiline HTML
{{< accordion yaml-multiline-html >}}This is a paragraph.
- HTML list item 1
- HTML list item 2
2.10 Inline simple
{{< accordion header="Click here to view contents" body="This content is defined inline" >}}2.11 Inline double quoted hyphenated label
{{< accordion label="\"my-accordion\"" header="Click to expand" body="This is the content of the accordion." >}}2.12 Inline collapsed false
{{< accordion header="This starts expanded" body="Expanded content by default." collapsed="false" >}}2.13 Inline with custom id
{{< accordion header="Custom item id" body="Custom ids are useful when you need anchor links." id="custom-item-1" >}}2.14 Inline multi items via JSON
{{< accordion items='[{"header":"Inline Item 1","body":"Content for item 1."},{"header":"Inline Item 2","body":"Content for item 2.","collapsed":false}]' >}}2.15 Inline multi with custom id via JSON
{{< accordion items='[{"header":"Item A","body":"Body A","id":"item-a"},{"header":"Item B","body":"Body B"}]' >}}2.16 Inline markdown formatting
{{< accordion header="**Bold header**" body="This is **bold** and *italic*" >}}2.17 Inline HTML formatting
{{< accordion header="<b>HTML bold header</b>" body="This is <b>bold</b> and <i>italic</i>" >}}2.18 Inline JSON items with markdown
{{< accordion items='[{"header":"**Bold JSON header**","body":"This is **bold** and *italic*."},{"header":"Second item","body":"- List item 1\n- List item 2"}]' >}}- List item 1
- List item 2
2.19 Inline JSON items with HTML
{{< accordion items='[{"header":"<b>HTML JSON header</b>","body":"This is <b>bold</b> and <i>italic</i>."},{"header":"Second item","body":"<ul><li>Item 1</li><li>Item 2</li></ul>"}]' >}}- Item 1
- Item 2