Skip to content

Commit

Permalink
feat: test
Browse files Browse the repository at this point in the history
  • Loading branch information
crazyair committed Jul 19, 2024
1 parent a7392a9 commit ba7e7af
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/submit.test.tsx
Original file line number Diff line number Diff line change
@@ -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(

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note test

Unused variable getByText.
<form
onSubmit={(e) => {
e.preventDefault();
e.stopPropagation();
console.log('111');
}}
>
<Input onFocus={onFocus} onBlur={onBlur} />
<button type="submit">Submit</button>
</form>,
);
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'));
});

0 comments on commit ba7e7af

Please sign in to comment.