# Path: mkdocs/structure/toc.py
# def get_toc(toc_tokens):
#     toc = [_parse_toc_token(i) for i in toc_tokens]
#     # For the table of contents, always mark the first element as active
#     if len(toc):
#         toc[0].active = True
#     return TableOfContents(toc)
# 
# Path: mkdocs/tests/base.py
# def dedent(text):
#     return textwrap.dedent(text).strip()
# 
# def get_markdown_toc(markdown_source):
#     """ Return TOC generated by Markdown parser from Markdown source text. """
#     md = markdown.Markdown(extensions=['toc'])
#     md.convert(markdown_source)
#     return md.toc_tokens


import unittest
from mkdocs.structure.toc import get_toc
from mkdocs.tests.base import dedent, get_markdown_toc


class TableOfContentsTests(unittest.TestCase):

    def test_indented_toc(self):
        md = dedent("""
        # Heading 1
        ## Heading 2
        ### Heading 3
        """)
        expected = dedent("""
        Heading 1 - #heading-1
            Heading 2 - #heading-2
                Heading 3 - #heading-3
        """)
        toc = get_toc(get_markdown_toc(md))
        self.assertEqual(str(toc).strip(), expected)
        self.assertEqual(len(toc), 1)

    def test_indented_toc_html(self):
        md = dedent("""
        # Heading 1
        ## <code>Heading</code> 2
        ## Heading 3
        """)
        expected = dedent("""
        Heading 1 - #heading-1
            Heading 2 - #heading-2
            Heading 3 - #heading-3
        """)

# Path: mkdocs/structure/toc.py
# def get_toc(toc_tokens):
#     toc = [_parse_toc_token(i) for i in toc_tokens]
#     # For the table of contents, always mark the first element as active
#     if len(toc):
#         toc[0].active = True
#     return TableOfContents(toc)
# 
# Path: mkdocs/tests/base.py
# def dedent(text):
#     return textwrap.dedent(text).strip()
# 
# def get_markdown_toc(markdown_source):
#     """ Return TOC generated by Markdown parser from Markdown source text. """
#     md = markdown.Markdown(extensions=['toc'])
#     md.convert(markdown_source)
#     return md.toc_tokens


# Path: mkdocs/tests/structure/toc_tests.py
import unittest
from mkdocs.structure.toc import get_toc
from mkdocs.tests.base import dedent, get_markdown_toc



class TableOfContentsTests(unittest.TestCase):

    def test_indented_toc(self):
        md = dedent("""
        # Heading 1
        ## Heading 2
        ### Heading 3
        """)
        expected = dedent("""
        Heading 1 - #heading-1
            Heading 2 - #heading-2
                Heading 3 - #heading-3
        """)
        toc = get_toc(get_markdown_toc(md))
        self.assertEqual(str(toc).strip(), expected)
        self.assertEqual(len(toc), 1)

    def test_indented_toc_html(self):
        md = dedent("""
        # Heading 1
        ## <code>Heading</code> 2
        ## Heading 3
        """)
        expected = dedent("""
        Heading 1 - #heading-1
            Heading 2 - #heading-2
            Heading 3 - #heading-3
        """)

        toc = get_toc(get_markdown_toc(md))