@@ -19,13 +19,13 @@ def on_mount(self) -> None:
19
19
20
20
21
21
async def test_initial_list_no_highlight () -> None :
22
- """When the list initially appears, nothing will be highlighted ."""
22
+ """When the list initially appears, the first item is highlghted ."""
23
23
async with CommandPaletteApp ().run_test () as pilot :
24
24
assert CommandPalette .is_open (pilot .app )
25
25
assert pilot .app .screen .query_one (CommandList ).visible is False
26
26
await pilot .press ("a" )
27
27
assert pilot .app .screen .query_one (CommandList ).visible is True
28
- assert pilot .app .screen .query_one (CommandList ).highlighted is None
28
+ assert pilot .app .screen .query_one (CommandList ).highlighted == 0
29
29
30
30
31
31
async def test_down_arrow_selects_an_item () -> None :
@@ -35,32 +35,19 @@ async def test_down_arrow_selects_an_item() -> None:
35
35
assert pilot .app .screen .query_one (CommandList ).visible is False
36
36
await pilot .press ("a" )
37
37
assert pilot .app .screen .query_one (CommandList ).visible is True
38
- assert pilot .app .screen .query_one (CommandList ).highlighted is None
38
+ assert pilot .app .screen .query_one (CommandList ).highlighted == 0
39
39
await pilot .press ("down" )
40
- assert pilot .app .screen .query_one (CommandList ).highlighted is not None
40
+ assert pilot .app .screen .query_one (CommandList ).highlighted == 1
41
41
42
42
43
43
async def test_enter_selects_an_item () -> None :
44
- """Typing in a search value then pressing enter should select a command."""
44
+ """Typing in a search value then pressing enter should dismiss the command palette ."""
45
45
async with CommandPaletteApp ().run_test () as pilot :
46
46
assert CommandPalette .is_open (pilot .app )
47
47
assert pilot .app .screen .query_one (CommandList ).visible is False
48
48
await pilot .press ("a" )
49
49
assert pilot .app .screen .query_one (CommandList ).visible is True
50
- assert pilot .app .screen .query_one (CommandList ).highlighted is None
51
- await pilot .press ("enter" )
52
- assert pilot .app .screen .query_one (CommandList ).highlighted is not None
53
-
54
-
55
- async def test_selection_of_command_closes_command_palette () -> None :
56
- """Selecting a command from the list should close the list."""
57
- async with CommandPaletteApp ().run_test () as pilot :
58
- assert CommandPalette .is_open (pilot .app )
59
- assert pilot .app .screen .query_one (CommandList ).visible is False
60
- await pilot .press ("a" )
61
- assert pilot .app .screen .query_one (CommandList ).visible is True
62
- assert pilot .app .screen .query_one (CommandList ).highlighted is None
63
- await pilot .press ("enter" )
64
- assert pilot .app .screen .query_one (CommandList ).highlighted is not None
50
+ assert pilot .app .screen .query_one (CommandList ).highlighted == 0
65
51
await pilot .press ("enter" )
66
52
assert not CommandPalette .is_open (pilot .app )
53
+ assert not pilot .app .screen .query (CommandList )
0 commit comments