From ba7e7af2ccfd42e5188d06f038cfef9da34f09f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=9E=AB?= <645381995@qq.com> Date: Fri, 19 Jul 2024 17:19:55 +0800 Subject: [PATCH] feat: test --- tests/submit.test.tsx | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 tests/submit.test.tsx diff --git a/tests/submit.test.tsx b/tests/submit.test.tsx new file mode 100644 index 0000000..1948c23 --- /dev/null +++ b/tests/submit.test.tsx @@ -0,0 +1,29 @@ +import { fireEvent, render } from '@testing-library/react'; +import React from 'react'; +import Input from '../src'; + +it('enter', () => { + const onFocus = jest.fn(); + const onBlur = jest.fn(); + const { container, getByText } = render( +
{ + e.preventDefault(); + e.stopPropagation(); + console.log('111'); + }} + > + + +
, + ); + const inputEl = container.querySelector('input')!; + fireEvent.focus(inputEl); + fireEvent.keyDown(inputEl, { key: 'Enter' }); + fireEvent.keyDown(inputEl, { key: 'Enter' }); + + // fireEvent.submit(inputEl); + // fireEvent.submit(inputEl); + + // fireEvent.click(getByText('Submit')); +});