2021-09-08 08:46:40 +00:00
|
|
|
"""Djlint tests specific to Handlebars.js.
|
|
|
|
|
|
|
|
|
|
run::
|
|
|
|
|
|
|
|
|
|
pytest tests/test_handlebars.py --cov=src/djlint --cov-branch \
|
|
|
|
|
--cov-report xml:coverage.xml --cov-report term-missing
|
2021-10-07 09:34:51 +00:00
|
|
|
|
|
|
|
|
pytest tests/test_handlebars.py::test_each --cov=src/djlint --cov-branch \
|
|
|
|
|
--cov-report xml:coverage.xml --cov-report term-missing
|
|
|
|
|
|
2021-09-08 08:46:40 +00:00
|
|
|
"""
|
|
|
|
|
# pylint: disable=C0116
|
|
|
|
|
|
|
|
|
|
from typing import TextIO
|
|
|
|
|
|
|
|
|
|
from click.testing import CliRunner
|
|
|
|
|
|
2022-05-13 20:36:55 +00:00
|
|
|
from tests.conftest import reformat
|
2021-09-08 08:46:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_each(runner: CliRunner, tmp_file: TextIO) -> None:
|
|
|
|
|
output = reformat(
|
|
|
|
|
tmp_file,
|
|
|
|
|
runner,
|
|
|
|
|
b"""{{#each people}}{{print_person}} <p>and more long stuff</p>{{/each}}""",
|
|
|
|
|
)
|
2021-11-29 11:19:07 +00:00
|
|
|
print(output.text)
|
|
|
|
|
assert output.exit_code == 1
|
2021-09-08 08:46:40 +00:00
|
|
|
assert (
|
2021-11-29 11:19:07 +00:00
|
|
|
output.text
|
2021-09-08 08:46:40 +00:00
|
|
|
== r"""{{#each people }}
|
|
|
|
|
{{ print_person }}
|
2022-05-16 14:25:29 +00:00
|
|
|
<p>and more long stuff</p>
|
2021-09-08 08:46:40 +00:00
|
|
|
{{/each }}
|
|
|
|
|
"""
|
|
|
|
|
)
|