Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
blueswen committed May 4, 2024
1 parent 50bc180 commit 6895d4e
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/fixtures/docs/manual.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
![image](img.png){ .on-glb }
9 changes: 9 additions & 0 deletions tests/fixtures/mkdocs-manual.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
site_name: test mkdocs_glightbox
use_directory_urls: true

markdown_extensions:
- attr_list

plugins:
- glightbox:
manual: true
28 changes: 28 additions & 0 deletions tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,3 +663,31 @@ def test_enable_by_image(tmp_path):
rf'<a class="glightbox".*?href="{re.escape(path)}img\.png".*?><img.*?class="on-glb".*?src="{re.escape(path)}img\.png".*?\/><\/a>',
contents,
)


def test_manual(tmp_path):
"""
Manual mode
"""
mkdocs_file = "mkdocs-manual.yml"
testproject_path = validate_mkdocs_file(tmp_path, f"tests/fixtures/{mkdocs_file}")
file = testproject_path / "site/index.html"
contents = file.read_text(encoding="utf8")
validate_static(contents)
validate_script(contents)
assert (
re.search(
r'<a class="glightbox".*?href="img\.png".*?>\s*<img.*?src="img\.png".*?\/><\/a>',
contents,
)
is None
)

file = testproject_path / "site/manual/index.html"
contents = file.read_text(encoding="utf8")
validate_static(contents, path="../")
validate_script(contents)
assert re.search(
r'<a class="glightbox".*?href="..\/img\.png".*?>\s*<img.*?src="..\/img\.png".*?\/><\/a>',
contents,
)

0 comments on commit 6895d4e

Please sign in to comment.