File tree Expand file tree Collapse file tree 3 files changed +5
-26
lines changed
testing/tests/DevExpress.ui.widgets Expand file tree Collapse file tree 3 files changed +5
-26
lines changed Original file line number Diff line number Diff line change @@ -330,12 +330,13 @@ describe('Button', () => {
330330 originalEvent,
331331 } ;
332332 const button = new Button ( { onClick } ) ;
333- const stub = jest . fn ( ) ;
334333
335- button . contentRef = { current : { click : stub } } as any ;
336334 button . keyDown ( options ) ;
337335 expect ( options . originalEvent . preventDefault ) . toHaveBeenCalled ( ) ;
338- expect ( stub ) . toHaveBeenCalledTimes ( 1 ) ;
336+ expect ( onClick ) . toHaveBeenCalledTimes ( 1 ) ;
337+ expect ( onClick ) . toHaveBeenCalledWith ( {
338+ event : options . originalEvent ,
339+ } ) ;
339340 } ) ;
340341
341342 it ( 'should not simulate click by common keys down' , ( ) => {
Original file line number Diff line number Diff line change @@ -241,16 +241,12 @@ export class Button extends JSXComponent(ButtonProps) {
241241
242242 if ( keyName === 'space' || which === 'space' || keyName === 'enter' || which === 'enter' ) {
243243 ( originalEvent as Event ) . preventDefault ( ) ;
244- this . emitClickEvent ( ) ;
244+ this . onWidgetClick ( originalEvent as Event ) ;
245245 }
246246
247247 return undefined ;
248248 }
249249
250- emitClickEvent ( ) : void {
251- this . contentRef . current ! . click ( ) ;
252- }
253-
254250 get aria ( ) : Record < string , string > {
255251 const { text, icon } = this . props ;
256252
Original file line number Diff line number Diff line change @@ -388,24 +388,6 @@ QUnit.module('Button', function() {
388388 assert . equal ( clickFired , 2 , 'press space on button call click action' ) ;
389389 } ) ;
390390
391- QUnit . test ( 'click event is fired on "enter" press' , function ( assert ) {
392- const $element = $ ( '#button' ) . dxButton ( {
393- focusStateEnabled : true
394- } ) ;
395- const handler = sinon . spy ( ) ;
396-
397- $element . on ( 'click' , handler ) ;
398-
399- const keyboard = keyboardMock ( $element ) ;
400-
401- $element . trigger ( 'focusin' ) ;
402- keyboard . keyDown ( 'enter' ) ;
403- assert . strictEqual ( handler . callCount , 1 , 'press enter on button call click action' ) ;
404-
405- keyboard . keyDown ( 'space' ) ;
406- assert . strictEqual ( handler . callCount , 2 , 'press space on button call click action' ) ;
407- } ) ;
408-
409391 QUnit . test ( 'arguments on key press' , function ( assert ) {
410392 const clickHandler = sinon . spy ( ) ;
411393
You can’t perform that action at this time.
0 commit comments