@@ -136,15 +136,28 @@ describe('Event responder: Press', () => {
136136 ) ;
137137 } ) ;
138138
139+ it ( 'is called after auxillary-button "pointerdown" event' , ( ) => {
140+ ref . current . dispatchEvent (
141+ createEvent ( 'pointerdown' , { button : 1 , pointerType : 'mouse' } ) ,
142+ ) ;
143+ expect ( onPressStart ) . toHaveBeenCalledTimes ( 1 ) ;
144+ expect ( onPressStart ) . toHaveBeenCalledWith (
145+ expect . objectContaining ( {
146+ button : 'auxillary' ,
147+ pointerType : 'mouse' ,
148+ type : 'pressstart' ,
149+ } ) ,
150+ ) ;
151+ } ) ;
152+
139153 it ( 'ignores browser emulated events' , ( ) => {
140154 ref . current . dispatchEvent ( createEvent ( 'pointerdown' ) ) ;
141155 ref . current . dispatchEvent ( createEvent ( 'touchstart' ) ) ;
142156 ref . current . dispatchEvent ( createEvent ( 'mousedown' ) ) ;
143157 expect ( onPressStart ) . toHaveBeenCalledTimes ( 1 ) ;
144158 } ) ;
145159
146- it ( 'ignores any events not caused by left-click or touch/pen contact' , ( ) => {
147- ref . current . dispatchEvent ( createEvent ( 'pointerdown' , { button : 1 } ) ) ;
160+ it ( 'ignores any events not caused by primary/auxillary-click or touch/pen contact' , ( ) => {
148161 ref . current . dispatchEvent ( createEvent ( 'pointerdown' , { button : 5 } ) ) ;
149162 ref . current . dispatchEvent ( createEvent ( 'mousedown' , { button : 2 } ) ) ;
150163 expect ( onPressStart ) . toHaveBeenCalledTimes ( 0 ) ;
@@ -330,6 +343,23 @@ describe('Event responder: Press', () => {
330343 ) ;
331344 } ) ;
332345
346+ it ( 'is called after auxillary-button "pointerup" event' , ( ) => {
347+ ref . current . dispatchEvent (
348+ createEvent ( 'pointerdown' , { button : 1 , pointerType : 'mouse' } ) ,
349+ ) ;
350+ ref . current . dispatchEvent (
351+ createEvent ( 'pointerup' , { button : 1 , pointerType : 'mouse' } ) ,
352+ ) ;
353+ expect ( onPressEnd ) . toHaveBeenCalledTimes ( 1 ) ;
354+ expect ( onPressEnd ) . toHaveBeenCalledWith (
355+ expect . objectContaining ( {
356+ button : 'auxillary' ,
357+ pointerType : 'mouse' ,
358+ type : 'pressend' ,
359+ } ) ,
360+ ) ;
361+ } ) ;
362+
333363 it ( 'ignores browser emulated events' , ( ) => {
334364 ref . current . dispatchEvent (
335365 createEvent ( 'pointerdown' , { pointerType : 'touch' } ) ,
@@ -664,6 +694,21 @@ describe('Event responder: Press', () => {
664694 ) ;
665695 } ) ;
666696
697+ it ( 'is not called after auxillary-button press' , ( ) => {
698+ const element = (
699+ < Press onPress = { onPress } >
700+ < div ref = { ref } />
701+ </ Press >
702+ ) ;
703+ ReactDOM . render ( element , container ) ;
704+
705+ ref . current . dispatchEvent ( createEvent ( 'pointerdown' , { button : 1 } ) ) ;
706+ ref . current . dispatchEvent (
707+ createEvent ( 'pointerup' , { button : 1 , clientX : 10 , clientY : 10 } ) ,
708+ ) ;
709+ expect ( onPress ) . not . toHaveBeenCalled ( ) ;
710+ } ) ;
711+
667712 it ( 'is called after valid "keyup" event' , ( ) => {
668713 ref . current . dispatchEvent ( createKeyboardEvent ( 'keydown' , { key : 'Enter' } ) ) ;
669714 ref . current . dispatchEvent ( createKeyboardEvent ( 'keyup' , { key : 'Enter' } ) ) ;
@@ -709,6 +754,22 @@ describe('Event responder: Press', () => {
709754 expect ( onPress ) . toHaveBeenCalledTimes ( 1 ) ;
710755 } ) ;
711756
757+ it ( 'is called with modifier keys' , ( ) => {
758+ ref . current . dispatchEvent (
759+ createEvent ( 'pointerdown' , { metaKey : true , pointerType : 'mouse' } ) ,
760+ ) ;
761+ ref . current . dispatchEvent (
762+ createEvent ( 'pointerup' , { metaKey : true , pointerType : 'mouse' } ) ,
763+ ) ;
764+ expect ( onPress ) . toHaveBeenCalledWith (
765+ expect . objectContaining ( {
766+ pointerType : 'mouse' ,
767+ type : 'press' ,
768+ metaKey : true ,
769+ } ) ,
770+ ) ;
771+ } ) ;
772+
712773 // No PointerEvent fallbacks
713774 // TODO: jsdom missing APIs
714775 // it('is called after "touchend" event', () => {
0 commit comments