@@ -150,6 +150,70 @@ describe('Editor', () => {
150
150
expect ( plugin . handleDrop ) . has . been . calledWith ( 'command' , pluginEditor . getEditorState , pluginEditor . onChange ) ;
151
151
} ) ;
152
152
153
+ it ( 'calls the handle- and on-hooks of the first plugin and not the second in case it was handeled' , ( ) => {
154
+ const plugins = [
155
+ {
156
+ handleKeyCommand : sinon . stub ( ) . returns ( true ) ,
157
+ onUpArrow : sinon . stub ( ) . returns ( true ) ,
158
+ } ,
159
+ {
160
+ handleKeyCommand : sinon . spy ( ) ,
161
+ onUpArrow : sinon . spy ( ) ,
162
+ } ,
163
+ ] ;
164
+ const result = shallow (
165
+ < PluginEditor
166
+ editorState = { editorState }
167
+ onChange = { onChange }
168
+ plugins = { plugins }
169
+ />
170
+ ) ;
171
+
172
+ const draftEditor = result . node ;
173
+ draftEditor . props . handleKeyCommand ( 'command' ) ;
174
+ expect ( plugins [ 0 ] . handleKeyCommand ) . has . been . calledOnce ( ) ;
175
+ expect ( plugins [ 1 ] . handleKeyCommand ) . has . not . been . called ( ) ;
176
+
177
+ draftEditor . props . onUpArrow ( ) ;
178
+ expect ( plugins [ 0 ] . onUpArrow ) . has . been . calledOnce ( ) ;
179
+ expect ( plugins [ 1 ] . onUpArrow ) . has . not . been . called ( ) ;
180
+ } ) ;
181
+
182
+ it ( 'calls the handle- and on-hooks of all plugins in case none handeles the command' , ( ) => {
183
+ const plugins = [
184
+ {
185
+ handleKeyCommand : sinon . spy ( ) ,
186
+ onUpArrow : sinon . spy ( ) ,
187
+ } ,
188
+ {
189
+ handleKeyCommand : sinon . spy ( ) ,
190
+ onUpArrow : sinon . spy ( ) ,
191
+ } ,
192
+ {
193
+ handleKeyCommand : sinon . spy ( ) ,
194
+ onUpArrow : sinon . spy ( ) ,
195
+ } ,
196
+ ] ;
197
+ const result = shallow (
198
+ < PluginEditor
199
+ editorState = { editorState }
200
+ onChange = { onChange }
201
+ plugins = { plugins }
202
+ />
203
+ ) ;
204
+
205
+ const draftEditor = result . node ;
206
+ draftEditor . props . handleKeyCommand ( 'command' ) ;
207
+ expect ( plugins [ 0 ] . handleKeyCommand ) . has . been . calledOnce ( ) ;
208
+ expect ( plugins [ 1 ] . handleKeyCommand ) . has . been . calledOnce ( ) ;
209
+ expect ( plugins [ 2 ] . handleKeyCommand ) . has . been . calledOnce ( ) ;
210
+
211
+ draftEditor . props . onUpArrow ( ) ;
212
+ expect ( plugins [ 0 ] . onUpArrow ) . has . been . calledOnce ( ) ;
213
+ expect ( plugins [ 1 ] . onUpArrow ) . has . been . calledOnce ( ) ;
214
+ expect ( plugins [ 2 ] . onUpArrow ) . has . been . calledOnce ( ) ;
215
+ } ) ;
216
+
153
217
it ( 'calls the fn-hooks of the plugin' , ( ) => {
154
218
const plugins = [
155
219
{
0 commit comments