diff --git a/tests/settings/base.py b/tests/settings/base.py index 7d67a0d..7a9682f 100644 --- a/tests/settings/base.py +++ b/tests/settings/base.py @@ -71,3 +71,4 @@ STATIC_URL = "/static/" SITE_ID = 1 WAGTAIL_SITE_NAME = "My Example Site" +WAGTAILMARKDOWN_EXTENSIONS = ["toc"] diff --git a/tests/test_pages.py b/tests/test_pages.py index 6febe75..594b4de 100644 --- a/tests/test_pages.py +++ b/tests/test_pages.py @@ -59,3 +59,19 @@ def test_canonical_url(client): soup = BeautifulSoup(res.content, "html.parser") el = soup.find("link", attrs={"rel": "canonical"}) assert el["href"] == "https://foo.com" + + +def test_renders_toc(client): + post = BlogPage( + title="My post", + body=""" +[TOC] +# first paragraph""", + date=timezone.now(), + ) + pages = [(BlogIndexPage(title="index"), [post])] + with page_tree(pages): + [(_, [post])] = pages + res = client.get(post.get_url()) + assert res.status_code == 200 + assert BeautifulSoup(res.content, "html.parser").select(".toc") diff --git a/tox.ini b/tox.ini index 09b8d46..c28cc4b 100644 --- a/tox.ini +++ b/tox.ini @@ -80,6 +80,8 @@ passenv = addopts = --ds=tests.settings.test --reuse-db -ra testpaths = tests norecursedirs = .git */migrations/* .venv +filterwarnings = + ignore::django.utils.deprecation.RemovedInDjango40Warning [isort] recursive = True