File tree Expand file tree Collapse file tree 3 files changed +16
-7
lines changed
browser-webdriverio/src/commands
browser/src/client/tester/locators Expand file tree Collapse file tree 3 files changed +16
-7
lines changed Original file line number Diff line number Diff line change @@ -4,16 +4,16 @@ import type { UserEventCommand } from './utils'
44export const click : UserEventCommand < UserEvent [ 'click' ] > = async (
55 context ,
66 selector ,
7- options = { } ,
7+ options ,
88) => {
99 const browser = context . browser
10- await browser . $ ( selector ) . click ( options as any )
10+ await browser . $ ( selector ) . click ( options )
1111}
1212
1313export const dblClick : UserEventCommand < UserEvent [ 'dblClick' ] > = async (
1414 context ,
1515 selector ,
16- _options = { } ,
16+ _options ,
1717) => {
1818 const browser = context . browser
1919 await browser . $ ( selector ) . doubleClick ( )
@@ -22,7 +22,7 @@ export const dblClick: UserEventCommand<UserEvent['dblClick']> = async (
2222export const tripleClick : UserEventCommand < UserEvent [ 'tripleClick' ] > = async (
2323 context ,
2424 selector ,
25- _options = { } ,
25+ _options ,
2626) => {
2727 const browser = context . browser
2828 await browser
Original file line number Diff line number Diff line change @@ -74,15 +74,15 @@ export abstract class Locator {
7474 } )
7575 }
7676
77- public click ( options : UserEventClickOptions = { } ) : Promise < void > {
77+ public click ( options ? : UserEventClickOptions ) : Promise < void > {
7878 return this . triggerCommand < void > ( '__vitest_click' , this . selector , options )
7979 }
8080
81- public dblClick ( options : UserEventClickOptions = { } ) : Promise < void > {
81+ public dblClick ( options ? : UserEventClickOptions ) : Promise < void > {
8282 return this . triggerCommand < void > ( '__vitest_dblClick' , this . selector , options )
8383 }
8484
85- public tripleClick ( options : UserEventClickOptions = { } ) : Promise < void > {
85+ public tripleClick ( options ? : UserEventClickOptions ) : Promise < void > {
8686 return this . triggerCommand < void > ( '__vitest_tripleClick' , this . selector , options )
8787 }
8888
Original file line number Diff line number Diff line change @@ -23,12 +23,21 @@ describe('userEvent.click', () => {
2323 document . body . appendChild ( button )
2424 const onClick = vi . fn ( )
2525 const dblClick = vi . fn ( )
26+ const onContextmenu = vi . fn ( )
2627 button . addEventListener ( 'click' , onClick )
28+ button . addEventListener ( 'dblclick' , onClick )
29+ button . addEventListener ( 'contextmenu' , onContextmenu )
2730
2831 await userEvent . click ( button )
2932
3033 expect ( onClick ) . toHaveBeenCalled ( )
3134 expect ( dblClick ) . not . toHaveBeenCalled ( )
35+ expect ( onContextmenu ) . not . toHaveBeenCalled ( )
36+
37+ onClick . mockClear ( )
38+ await userEvent . click ( button , { button : 'right' } )
39+ expect ( onClick ) . not . toHaveBeenCalled ( )
40+ expect ( onContextmenu ) . toHaveBeenCalled ( )
3241 } )
3342
3443 test ( 'correctly doesn\'t click on a disabled button' , async ( ) => {
You can’t perform that action at this time.
0 commit comments