File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import { expectFnCalled } from '@test/utils';
5
5
import '@testing-library/jest-dom' ;
6
6
7
7
import EditorAction from '../action' ;
8
+ import { groupActionItemDisabledClassName } from '../base' ;
8
9
9
10
const current : IEditorActionsProps = {
10
11
id : '1' ,
@@ -71,4 +72,32 @@ describe('The Editor Component', () => {
71
72
expect ( container . querySelector ( `.codicon-warning` ) ) . toBeInTheDocument ( ) ;
72
73
expect ( container . querySelectorAll ( `.codicon-warning` ) ! . length ) . toBe ( 8 ) ;
73
74
} ) ;
75
+
76
+ test ( 'The EditorAction item disabled' , ( ) => {
77
+ const mockAction : IEditorActionsProps [ ] = Array ( 8 )
78
+ . fill ( 1 )
79
+ . map ( ( _ , index ) => ( {
80
+ id : index . toString ( ) ,
81
+ place : 'outer' ,
82
+ icon : 'warning' ,
83
+ } ) ) ;
84
+ mockAction [ 0 ] . disabled = true ;
85
+ const mockCallback = jest . fn ( ) ;
86
+
87
+ const { container } = render (
88
+ < EditorAction
89
+ isActiveGroup = { true }
90
+ actions = { mockAction }
91
+ onClickActions = { jest . fn ( ) }
92
+ />
93
+ ) ;
94
+
95
+ const liDom = container . querySelector (
96
+ `.${ groupActionItemDisabledClassName } `
97
+ ) ;
98
+
99
+ expect ( liDom ) . not . toBeNull ( ) ;
100
+ liDom && fireEvent . click ( liDom ) ;
101
+ expect ( mockCallback ) . not . toBeCalled ( ) ;
102
+ } ) ;
74
103
} ) ;
Original file line number Diff line number Diff line change @@ -82,7 +82,9 @@ function EditorAction(props: IEditorActionProps & IEditorController) {
82
82
outer . map ( ( action ) => (
83
83
< Tooltip key = { action . id } overlay = { action . title } >
84
84
< div
85
- onClick = { ( ) => handleActionsClick ( action ) }
85
+ onClick = { ( ) =>
86
+ ! action . disabled && handleActionsClick ( action )
87
+ }
86
88
className = { classNames (
87
89
groupActionsItemClassName ,
88
90
action . disabled &&
You can’t perform that action at this time.
0 commit comments