Skip to content

Commit

Permalink
adding a tests for disabled options
Browse files Browse the repository at this point in the history
  • Loading branch information
iamalisalehi committed Jul 17, 2024
1 parent 768a539 commit 116e1a7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pick/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ def move_up(self) -> None:
if self.index < 0:
self.index = len(self.options) - 1
option = self.options[self.index]
if isinstance(option, Option) and not option.enable:
if isinstance(option, Option) and not option.enabled:
self.index -= 1

def move_down(self) -> None:
self.index += 1
if self.index >= len(self.options):
self.index = 0
option = self.options[self.index]
if isinstance(option, Option) and not option.enable:
if isinstance(option, Option) and not option.enabled:
self.index += 1

def mark_index(self) -> None:
Expand Down
7 changes: 7 additions & 0 deletions tests/test_pick.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,10 @@ def test_option():
assert option[0].label == "option1"
assert option[0].value == 101
assert option[0].description == "description1"

def test_disabled_option():
options = [Option("option1"), Option("option2", enabled=False), Option("option3")]
picker = Picker(options)
assert picker.get_selected() == (Option("option1"), 0)
picker.move_down()
assert picker.get_selected() == (Option("option3"), 2)

0 comments on commit 116e1a7

Please sign in to comment.