Skip to content

Commit

Permalink
fix: 补充测试用例
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarryxin committed Sep 27, 2024
1 parent 1bd097d commit 59210e0
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/Select.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,39 @@ describe('Select.Basic', () => {
expect(end).toBe(1);
expect(cursorValue).toBe('1');
});

it('Moving the cursor in TextArea does not display the listbox', () => {
const onKeyDown = jest.fn();
const onMouseDown = jest.fn();
const textareaRef = jest.fn();
const mouseDownPreventDefault = jest.fn();
const { container } = render(
<Select
mode="combobox"
value="abc\ndef"
ref={textareaRef}
getInputElement={() => (
<textarea rows={3} onKeyDown={onKeyDown} onMouseDown={onMouseDown} />
)}
options={[{ value: 'light' }, { value: 'bamboo' }]}
allowClear
/>,
);

const textareaEle = container.querySelector('textarea');
toggleOpen(container);

const mouseDownEvent = createEvent.mouseDown(textareaEle);
mouseDownEvent.preventDefault = mouseDownPreventDefault;
fireEvent(textareaEle, mouseDownEvent);

keyDown(textareaEle, KeyCode.ENTER);

[KeyCode.LEFT, KeyCode.DOWN, KeyCode.RIGHT, KeyCode.UP].forEach((keyCode) => {
keyDown(textareaEle, keyCode);
expectOpen(container, false);
});
});
});

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

0 comments on commit 59210e0

Please sign in to comment.