Skip to content

Commit 0219db5

Browse files
committed
Add test for default format
1 parent 2591e3d commit 0219db5

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

tests/test_format.py

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pathlib
2-
import textwrap
32

43
from click.testing import CliRunner
54

@@ -12,16 +11,27 @@ def test_format_cmd(tmp_path: pathlib.Path, cli_runner: CliRunner):
1211
beanhub_dir.mkdir()
1312

1413
bean_file = beanhub_dir / "sample.bean"
15-
bean_file.write_text(
16-
textwrap.dedent(
17-
"""\
18-
2024-06-27 open Assets:Cash
19-
"""
20-
)
21-
)
14+
bean_file.write_text("2024-06-27 open Assets:Cash")
2215

2316
cli_runner.mix_stderr = False
2417
with switch_cwd(tmp_path):
2518
result = cli_runner.invoke(cli, ["format", str(bean_file)])
2619
assert result.exit_code == 0
2720
assert bean_file.read_text() == "2024-06-27 open Assets:Cash\n"
21+
22+
23+
def test_format_cmd_without_args(tmp_path: pathlib.Path, cli_runner: CliRunner):
24+
beanhub_dir = tmp_path / ".beanhub"
25+
beanhub_dir.mkdir()
26+
27+
included_bean = beanhub_dir / "mybook.bean"
28+
included_bean.write_text("2024-06-27 open Assets:Cash")
29+
30+
main_bean = beanhub_dir / "main.bean"
31+
main_bean.write_text('include "mybook.bean"')
32+
33+
cli_runner.mix_stderr = False
34+
with switch_cwd(beanhub_dir):
35+
result = cli_runner.invoke(cli, ["format"])
36+
assert result.exit_code == 0
37+
assert included_bean.read_text() == "2024-06-27 open Assets:Cash\n"

0 commit comments

Comments
 (0)