"""Test cases for Details."""
from .. import util
class TestDetails(util.MdCase):
"""Test Details."""
extension = ['pymdownx.details', 'markdown.extensions.def_list']
extension_configs = {
'pymdownx.blocks': {
'blocks': ['pymdownx.blocks.details:Details']
}
}
def test_with_preceding_text(self):
"""Test content right before details."""
expected = r'''
foo
foo
Details
'''
self.check_markdown(
R'''
foo
**foo**
??? note "Details"
''',
expected,
True
)
def test_nested(self):
"""Test nested."""
expected = r'''
details
content
open nested details
content
more content
'''
self.check_markdown(
r'''
??? "details"
content
???+ "open nested details"
content
more content
''',
expected,
True
)
def test_class(self):
"""Test class."""
expected = r'''
details with class
content
'''
self.check_markdown(
r'''
??? optional-class "details with class"
content
''',
expected,
True
)
def test_multiple_classes(self):
"""Test multiple classes."""
expected = r'''
details with multiple class
content
'''
self.check_markdown(
r'''
??? multiple optional-class "details with multiple class"
content
''',
expected,
True
)
def test_only_class(self):
"""Test only class."""
expected = r'''
Only-class
content
'''
self.check_markdown(
r'''
??? only-class
content
''',
expected,
True
)
def test_only_multiple_classes(self):
"""Test only multiple classes."""
expected = r'''
Multiple
content
'''
self.check_markdown(
r'''
??? multiple classes
content
''',
expected,
True
)
def test_content_after(self):
"""Test content after details."""
expected = r'''
details end test
content
other content
'''
self.check_markdown(
r'''
??? "details end test"
content
other content
''',
expected,
True
)
def test_relaxed_spacing(self):
"""Test relaxed spacing."""
expected = r'''
Title
content
'''
self.check_markdown(
r'''
???relaxed spacing "Title"
content
''',
expected,
True
)
def test_relaxed_spacing_no_title(self):
"""Test relaxed spacing and no title."""
expected = r'''
Relaxed
content
'''
self.check_markdown(
r'''
???relaxed spacing no title
content
''',
expected,
True
)
def test_with_lists(self):
"""Test with lists."""
self.check_markdown(
'''
- List
??? note "Details"
- Paragraph
Paragraph
''',
'''
''',
True
)
def test_with_big_lists(self):
"""Test details with a longer list."""
self.check_markdown(
'''
- List
??? note "Details"
- Paragraph
Paragraph
- Paragraph
paragraph
''',
'''
-
List
Details
-
Paragraph
Paragraph
-
Paragraph
paragraph
''',
True
)
def test_with_complex_lists(self):
"""Test details in a complex list scenario."""
self.check_markdown(
'''
- List
??? note "Details"
- Paragraph
??? note "Details"
1. Paragraph
Paragraph
''',
'''
-
List
Details
-
Paragraph
Details
-
Paragraph
Paragraph
''',
True
)
def test_definition_list(self):
"""Test with definition list."""
self.check_markdown(
'''
- List
??? note "Details"
Term
: Definition
More text
: Another
definition
Even more text
''',
'''
-
List
Details
- Term
-
Definition
More text
-
Another
definition
Even more text
''',
True
)
def test_details_complex_list(self):
"""Test details complex list scenario."""
self.check_markdown(
'''
???+ "With details block with loose lists"
- Parent 1
- Child 1
- Child 2
''',
'''
With details block with loose lists
''',
True
)
def test_details_complex_list_unindentd_content(self):
"""Test details complex list scenario with un-indented content."""
self.check_markdown(
'''
???+ "With details block with loose lists"
- Parent 1
- Child 1
- Child 2
- Parent 2
''',
'''
With details block with loose lists
''',
True
)