mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-11 23:23:10 +00:00
82 lines
1.3 KiB
Python
82 lines
1.3 KiB
Python
"""DjLint tests for yaml front matter.
|
|
|
|
run:
|
|
|
|
pytest tests/test_html/test_yaml.py --cov=src/djlint --cov-branch \
|
|
--cov-report xml:coverage.xml --cov-report term-missing
|
|
|
|
pytest tests/test_html/test_yaml.py
|
|
|
|
"""
|
|
# pylint: disable=C0116
|
|
from typing import TextIO
|
|
|
|
from click.testing import CliRunner
|
|
|
|
from tests.conftest import reformat
|
|
|
|
|
|
def test_invalid(runner: CliRunner, tmp_file: TextIO) -> None:
|
|
output = reformat(
|
|
tmp_file,
|
|
runner,
|
|
b"""---
|
|
invalid:
|
|
invalid:
|
|
---
|
|
|
|
|
|
|
|
<html><head></head><body></body></html>""",
|
|
)
|
|
assert (
|
|
output.text
|
|
== """---
|
|
invalid:
|
|
invalid:
|
|
---
|
|
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|
|
"""
|
|
)
|
|
|
|
|
|
def test_valid(runner: CliRunner, tmp_file: TextIO) -> None:
|
|
output = reformat(
|
|
tmp_file,
|
|
runner,
|
|
b"""
|
|
---
|
|
hello: world
|
|
---
|
|
<html><head></head><body></body></html>""",
|
|
)
|
|
assert (
|
|
output.text
|
|
== """---
|
|
hello: world
|
|
---
|
|
<html>
|
|
<head>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|
|
"""
|
|
)
|
|
|
|
|
|
def test_more(runner: CliRunner, tmp_file: TextIO) -> None:
|
|
output = reformat(
|
|
tmp_file,
|
|
runner,
|
|
b"""---
|
|
layout: <div><div></div></div>
|
|
---
|
|
<div></div>""",
|
|
)
|
|
assert output.exit_code == 0
|