mirror of
https://github.com/Hopiu/djLint.git
synced 2026-05-12 15:33:08 +00:00
test(yaml): added more yaml tests
This commit is contained in:
parent
98e20ee885
commit
eec497d043
2 changed files with 77 additions and 10 deletions
|
|
@ -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: <div><div></div></div>
|
||||
---
|
||||
<div></div>""",
|
||||
)
|
||||
assert output.exit_code == 0
|
||||
|
||||
|
||||
|
||||
def test_code_tag(runner: CliRunner, tmp_file: TextIO) -> None:
|
||||
|
|
|
|||
76
tests/test_html/test_yaml.py
Normal file
76
tests/test_html/test_yaml.py
Normal file
|
|
@ -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:
|
||||
---
|
||||
|
||||
|
||||
|
||||
<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
|
||||
Loading…
Reference in a new issue