@@ -224,6 +224,12 @@ describe('prompt input in form', () => {
224
224
( console . error as jest . Mock ) . mockClear ( ) ;
225
225
} ) ;
226
226
227
+ test ( 'enter key during IME composition does not submit form' , ( ) => {
228
+ const [ wrapper , submitSpy ] = renderPromptInputInForm ( { value : '' } ) ;
229
+ wrapper . findNativeTextarea ( ) . keydown ( { keyCode : KeyCode . enter , isComposing : true } ) ;
230
+ expect ( submitSpy ) . not . toHaveBeenCalled ( ) ;
231
+ } ) ;
232
+
227
233
test ( 'cancelling key event prevents submission' , ( ) => {
228
234
const [ wrapper , submitSpy ] = renderPromptInputInForm ( {
229
235
value : '' ,
@@ -247,21 +253,42 @@ describe('events', () => {
247
253
expect ( onChange ) . toHaveBeenCalledWith ( { value : 'updated value' } ) ;
248
254
} ) ;
249
255
250
- test ( 'fire an action event with correct parameters' , ( ) => {
256
+ test ( 'fire an action event on action button click with correct parameters' , ( ) => {
251
257
const onAction = jest . fn ( ) ;
252
258
const { wrapper } = renderPromptInput ( {
253
259
value : 'value' ,
254
260
actionButtonIconName : 'send' ,
255
261
onAction : event => onAction ( event . detail ) ,
256
262
} ) ;
257
263
258
- act ( ( ) => {
259
- wrapper . findActionButton ( ) . click ( ) ;
264
+ wrapper . findActionButton ( ) . click ( ) ;
265
+ expect ( onAction ) . toHaveBeenCalled ( ) ;
266
+ } ) ;
267
+
268
+ test ( 'fire an action event on enter keydown with correct parameters' , ( ) => {
269
+ const onAction = jest . fn ( ) ;
270
+ const { wrapper } = renderPromptInput ( {
271
+ value : 'value' ,
272
+ actionButtonIconName : 'send' ,
273
+ onAction : event => onAction ( event . detail ) ,
260
274
} ) ;
261
275
276
+ wrapper . findNativeTextarea ( ) . keydown ( KeyCode . enter ) ;
262
277
expect ( onAction ) . toHaveBeenCalled ( ) ;
263
278
} ) ;
264
279
280
+ test ( 'does not fire an action event on enter keydown if part of IME composition' , ( ) => {
281
+ const onAction = jest . fn ( ) ;
282
+ const { wrapper } = renderPromptInput ( {
283
+ value : 'value' ,
284
+ actionButtonIconName : 'send' ,
285
+ onAction : event => onAction ( event . detail ) ,
286
+ } ) ;
287
+
288
+ wrapper . findNativeTextarea ( ) . keydown ( { keyCode : KeyCode . enter , isComposing : true } ) ;
289
+ expect ( onAction ) . not . toHaveBeenCalled ( ) ;
290
+ } ) ;
291
+
265
292
test ( 'fire keydown event' , ( ) => {
266
293
const onKeyDown = jest . fn ( ) ;
267
294
const { wrapper } = renderPromptInput ( {
0 commit comments