Skip to content

Commit 59210e0

Browse files
committed
fix: 补充测试用例
1 parent 1bd097d commit 59210e0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/Select.test.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,6 +1048,39 @@ describe('Select.Basic', () => {
10481048
expect(end).toBe(1);
10491049
expect(cursorValue).toBe('1');
10501050
});
1051+
1052+
it('Moving the cursor in TextArea does not display the listbox', () => {
1053+
const onKeyDown = jest.fn();
1054+
const onMouseDown = jest.fn();
1055+
const textareaRef = jest.fn();
1056+
const mouseDownPreventDefault = jest.fn();
1057+
const { container } = render(
1058+
<Select
1059+
mode="combobox"
1060+
value="abc\ndef"
1061+
ref={textareaRef}
1062+
getInputElement={() => (
1063+
<textarea rows={3} onKeyDown={onKeyDown} onMouseDown={onMouseDown} />
1064+
)}
1065+
options={[{ value: 'light' }, { value: 'bamboo' }]}
1066+
allowClear
1067+
/>,
1068+
);
1069+
1070+
const textareaEle = container.querySelector('textarea');
1071+
toggleOpen(container);
1072+
1073+
const mouseDownEvent = createEvent.mouseDown(textareaEle);
1074+
mouseDownEvent.preventDefault = mouseDownPreventDefault;
1075+
fireEvent(textareaEle, mouseDownEvent);
1076+
1077+
keyDown(textareaEle, KeyCode.ENTER);
1078+
1079+
[KeyCode.LEFT, KeyCode.DOWN, KeyCode.RIGHT, KeyCode.UP].forEach((keyCode) => {
1080+
keyDown(textareaEle, keyCode);
1081+
expectOpen(container, false);
1082+
});
1083+
});
10511084
});
10521085

10531086
it('getRawInputElement for rc-cascader', () => {

0 commit comments

Comments
 (0)