Skip to content

Commit

Permalink
test(number): replace
Browse files Browse the repository at this point in the history
  • Loading branch information
kazhala committed Dec 9, 2021
1 parent 8145c80 commit 8a80ffd
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/prompts/test_number.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import unittest
from decimal import Decimal
from unittest.mock import ANY, call, patch

from prompt_toolkit.keys import Keys
Expand Down Expand Up @@ -429,3 +430,20 @@ def test_sn(self) -> None:

self.float_prompt.value = Decimal("1.1")
self.assertEqual(self.float_prompt._integral_buffer.text, "1")

def test_replace_mode(self) -> None:
self.assertFalse(self.prompt._whole_replace)
self.assertTrue(self.float_prompt._integral_replace)
self.float_prompt._handle_focus(None)
self.float_prompt._handle_left(None)
self.assertFalse(self.float_prompt._integral_replace)

prompt = NumberPrompt(message="", float_allowed=True)
prompt._on_rendered(None)
self.assertTrue(prompt._whole_replace)
self.assertTrue(prompt._integral_replace)
prompt._handle_up(None)
self.assertFalse(prompt._whole_replace)
prompt._handle_dot(None)
prompt._handle_right(None)
self.assertFalse(prompt._integral_replace)

0 comments on commit 8a80ffd

Please sign in to comment.