Skip to content

Commit

Permalink
test(fuzzy): add test for kazhala#20
Browse files Browse the repository at this point in the history
  • Loading branch information
ria02 committed Aug 28, 2021
1 parent f07f8e7 commit faec808
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/prompts/test_fuzzy.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from InquirerPy.base.complex import BaseComplexPrompt
import asyncio
import unittest
from typing import Callable, NamedTuple
from unittest.mock import ANY, MagicMock, patch
from unittest.mock import ANY, MagicMock, call, patch

from prompt_toolkit.application.application import Application
from prompt_toolkit.buffer import Buffer
Expand Down Expand Up @@ -718,3 +719,17 @@ def test_on_rendered(self, mocked, mocked_change):
mocked.assert_called_once()
self.assertEqual(prompt._buffer.text, "yes")
self.assertEqual(prompt._buffer.cursor_position, 3)

@patch.object(FuzzyPrompt, "_on_rendered")
@patch.object(BaseComplexPrompt, "_register_kb")
def test_constructor_keybindings(self, mocked_kb, mocked_rendered):
prompt = FuzzyPrompt(message="", choices=[1, 2, 3])
prompt._after_render(None)
try:
mocked_kb.assert_has_calls([call("space", filter=ANY)])
mocked_kb.assert_has_calls([call("j", filter=ANY)])
mocked_kb.assert_has_calls([call("k", filter=ANY)])
except AssertionError:
pass
else:
self.fail("space/j/k kb was registered")

0 comments on commit faec808

Please sign in to comment.