Test

Testing the accordion shortcode

Author

Roy Francis

Published

09-Apr-2026

1 Error tests

These tests should each produce an error message.

1.1 No arguments

Expected error: No arguments provided.

{{< accordion >}}

Accordion Error: No arguments provided. Provide contents either as yaml metadata (positional argument) or inline (header/body/items kwargs).

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" >}}

Accordion Error: Use either a positional argument or named arguments (label), not both.

1.3 Invalid label - space

Expected error: Label contains invalid characters.

{{< accordion label="inline simple" header="Header" body="Body" >}}

Accordion Error: 'inline simple': Label contains invalid characters. Only letters, numbers, dashes (-) and underscores (_) are allowed.

1.4 Invalid label - special characters

Expected error: Label contains invalid characters.

{{< accordion label="inline?simple" header="Header" body="Body" >}}

Accordion Error: 'inline?simple': Label contains invalid characters. Only letters, numbers, dashes (-) and underscores (_) are allowed.

1.5 YAML label not found in metadata

Expected error: Accordion entry not found in yaml metadata.

{{< accordion nonexistent >}}

Accordion Error: 'nonexistent': Accordion entry not found in yaml metadata.

1.6 YAML empty metadata for label

Expected error: Missing ‘header’ and ‘body’.

{{< accordion yaml-empty >}}

Accordion Error: 'yaml-empty': Missing 'header' and 'body'.

1.7 YAML item missing header

Expected error: Item 1 is missing ‘header’.

{{< accordion yaml-missing-header >}}
Accordion Error: 'yaml-missing-header': Item 1 is missing 'header'.

1.8 YAML item missing body

Expected error: Item 1 is missing ‘body’.

{{< accordion yaml-missing-body >}}
Accordion Error: 'yaml-missing-body': Item 1 is missing 'body'.

1.9 YAML item missing both header and body

Expected error: Item 1 is missing ‘header’ and ‘body’.

{{< accordion yaml-missing-both >}}
Accordion Error: 'yaml-missing-both': Item 1 is missing 'header' and 'body'.

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 >}}
This is the body content for item 1
This is the body content for item 2
Accordion Error: 'yaml-many-items': Item 3 is missing 'body'.
This is the body content for item 4

1.11 Inline label with no metadata entry

Expected error: Accordion entry not found in yaml metadata.

{{< accordion label="inline-empty" >}}

Accordion Error: 'inline-empty': Accordion entry not found in yaml metadata.

1.12 Inline missing body

Expected error: ‘body’ kwarg is missing.

{{< accordion header="Click here to view contents" >}}

Accordion Error: 'acc-b136d9db': 'body' kwarg is missing.

1.13 Inline missing header

Expected error: ‘header’ kwarg is missing.

{{< accordion body="This content is defined inline" >}}

Accordion Error: 'acc-f8036602': 'header' kwarg is missing.

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"}]' >}}

Accordion Error: 'acc-83a55f5d': Use either 'header'/'body' or 'items', not both.

1.15 Inline bad JSON in items

Expected error: Missing ‘header’ and ‘body’.

{{< accordion items='not valid json' >}}

Accordion Error: 'acc-f0424bc0': Failed to parse 'items' JSON string.

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"}]' >}}
Body 1
Accordion Error: 'acc-142ef9ef': Item 2 is missing 'header'.

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"}]' >}}
Accordion Error: 'acc-46fc3eec': Item 1 is missing 'body'.
Body 2

2 Success tests

These tests should each render a working accordion.

2.1 YAML simple single item

{{< accordion yaml-simple >}}
This content is defined in the document yaml

2.2 YAML same label reused

{{< accordion yaml-simple >}}
This content is defined in the document yaml

2.3 YAML collapsed state

{{< accordion yaml-collapsed >}}
Collapsed body content
Expanded body content

2.4 YAML custom id

{{< accordion yaml-custom-id >}}
Custom id body

2.5 YAML id conflict

{{< accordion yaml-id-conflict >}}
duplicate
duplicate

2.6 YAML markdown formatting

{{< accordion yaml-markdown >}}
This is bold and italic

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 >}}
This is bold and italic

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" >}}
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." >}}
This is the content of the accordion.

2.12 Inline collapsed false

{{< accordion header="This starts expanded" body="Expanded content by default." collapsed="false" >}}
Expanded content by default.

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" >}}
Custom ids are useful when you need anchor links.

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}]' >}}
Content for item 1.
Content for item 2.

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"}]' >}}
Body A
Body B

2.16 Inline markdown formatting

{{< accordion header="**Bold header**" body="This is **bold** and *italic*" >}}
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>" >}}
This is bold and italic

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"}]' >}}
This is bold and italic.
  • 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>"}]' >}}
This is bold and italic.
  • Item 1
  • Item 2