diff --git a/tests/test_html/test_html.py b/tests/test_html/test_html.py index 9b5d09c..32b8838c 100644 --- a/tests/test_html/test_html.py +++ b/tests/test_html/test_html.py @@ -20,16 +20,7 @@ from src.djlint import main as djlint from tests.conftest import reformat, write_to_file -def test_front_matter(runner: CliRunner, tmp_file: TextIO) -> None: - output = reformat( - tmp_file, - runner, - b"""--- -layout:
---- -
""", - ) - assert output.exit_code == 0 + def test_code_tag(runner: CliRunner, tmp_file: TextIO) -> None: diff --git a/tests/test_html/test_yaml.py b/tests/test_html/test_yaml.py new file mode 100644 index 0000000..3206878 --- /dev/null +++ b/tests/test_html/test_yaml.py @@ -0,0 +1,76 @@ +"""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 pathlib import Path +from typing import TextIO + +from click.testing import CliRunner + +from src.djlint import main as djlint +from tests.conftest import reformat, write_to_file + +def test_invalid(runner: CliRunner, tmp_file: TextIO) -> None: + output = reformat( + tmp_file, + runner, + b"""--- + invalid: +invalid: +--- + + + +""", + ) + assert output.text == """--- + invalid: +invalid: +--- + + + + + + +""" + + +def test_valid(runner: CliRunner, tmp_file: TextIO) -> None: + output = reformat( + tmp_file, + runner, + b""" +--- +hello: world +--- +""", + ) + assert output.text == """--- +hello: world +--- + + + + + + +""" + +def test_more(runner: CliRunner, tmp_file: TextIO) -> None: + output = reformat( + tmp_file, + runner, + b"""--- +layout:
+--- +
""", + ) + assert output.exit_code == 0