File tree Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Expand file tree Collapse file tree 2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -22,8 +22,8 @@ test.describe('basic behavior', async () => {
22
22
23
23
test ( 'item onSelect is called on click' , async ( { page } ) => {
24
24
const item = page . locator ( `[cmdk-item][data-value="Item"]` )
25
- const [ message ] = await Promise . all ( [ page . waitForEvent ( 'console' ) , item . click ( ) ] )
26
- expect ( message . text ( ) ) . toEqual ( 'Item selected' )
25
+ await item . click ( )
26
+ expect ( await page . evaluate ( ( ) => ( window as any ) . onSelect ) ) . toEqual ( 'Item selected' )
27
27
} )
28
28
29
29
test ( 'first item is selected by default' , async ( { page } ) => {
Original file line number Diff line number Diff line change @@ -7,7 +7,13 @@ const Page = () => {
7
7
< Command . Input placeholder = "Search…" className = "input" />
8
8
< Command . List className = "list" >
9
9
< Command . Empty className = "empty" > No results.</ Command . Empty >
10
- < Command . Item keywords = { [ 'key' ] } onSelect = { ( ) => console . log ( 'Item selected' ) } className = "item" >
10
+ < Command . Item
11
+ keywords = { [ 'key' ] }
12
+ onSelect = { ( ) => {
13
+ ; ( window as any ) . onSelect = 'Item selected'
14
+ } }
15
+ className = "item"
16
+ >
11
17
Item
12
18
</ Command . Item >
13
19
< Command . Item value = "xxx" className = "item" >
You can’t perform that action at this time.
0 commit comments