File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 11import pytest
2+ from prompt_toolkit .key_binding import KeyBindings
23
34from commitizen .cz .conventional_commits .conventional_commits import (
45 ConventionalCommitsCz ,
@@ -173,3 +174,10 @@ def test_info(config):
173174 conventional_commits = ConventionalCommitsCz (config )
174175 info = conventional_commits .info ()
175176 assert isinstance (info , str )
177+
178+
179+ def test_body_question_is_multiline (config ):
180+ cz = ConventionalCommitsCz (config )
181+ body_question = next (q for q in cz .questions () if q ["name" ] == "body" )
182+ assert body_question ["multiline" ] is True
183+ assert isinstance (body_question ["key_bindings" ], KeyBindings )
Original file line number Diff line number Diff line change 44from commitizen .cz import exceptions , utils
55
66
7+ def test_multiline_key_bindings_enter_submits_on_empty (mocker : MockFixture ):
8+ kb = utils .get_multiline_key_bindings ()
9+ handler = kb .get_bindings_for_keys (("enter" ,))[0 ].handler
10+
11+ buff = mocker .MagicMock ()
12+ buff .text = ""
13+ event = mocker .MagicMock ()
14+ event .app .current_buffer = buff
15+
16+ handler (event )
17+ buff .validate_and_handle .assert_called_once ()
18+ buff .insert_text .assert_not_called ()
19+
20+
21+ def test_multiline_key_bindings_enter_inserts_newline (mocker : MockFixture ):
22+ kb = utils .get_multiline_key_bindings ()
23+ handler = kb .get_bindings_for_keys (("enter" ,))[0 ].handler
24+
25+ buff = mocker .MagicMock ()
26+ buff .text = "some content"
27+ event = mocker .MagicMock ()
28+ event .app .current_buffer = buff
29+
30+ handler (event )
31+ buff .insert_text .assert_called_once_with ("\n " )
32+ buff .validate_and_handle .assert_not_called ()
33+
34+
735def test_required_validator ():
836 assert utils .required_validator ("test" ) == "test"
937
You can’t perform that action at this time.
0 commit comments