-
Notifications
You must be signed in to change notification settings - Fork 243
/
character.ts
27 lines (21 loc) · 1003 Bytes
/
character.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import userEvent from 'index'
import {setup} from '__tests__/helpers/utils'
test('type [Enter] in textarea', () => {
const {element, getEvents} = setup(`<textarea>f</textarea>`)
userEvent.type(
element as HTMLTextAreaElement,
'oo[Enter]bar[ShiftLeft>][Enter]baz',
)
expect(element).toHaveValue('foo\nbar\nbaz')
expect(getEvents('input')[2]).toHaveProperty('inputType', 'insertLineBreak')
expect(getEvents('input')[6]).toHaveProperty('inputType', 'insertLineBreak')
})
test('type [Enter] in contenteditable', () => {
const {element, getEvents} = setup(`<div contenteditable="true">f</div>`)
;(element as HTMLDivElement).focus()
userEvent.keyboard('oo[Enter]bar[ShiftLeft>][Enter]baz')
expect(element).toHaveTextContent('foo bar baz')
expect(element?.firstChild).toHaveProperty('nodeValue', 'foo\nbar\nbaz')
expect(getEvents('input')[2]).toHaveProperty('inputType', 'insertParagraph')
expect(getEvents('input')[6]).toHaveProperty('inputType', 'insertLineBreak')
})