Skip to content

Commit

Permalink
fix: usage of userEvent
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksii Kurinnyi <[email protected]>
  • Loading branch information
akurinnoy committed Sep 17, 2024
1 parent e35bccb commit c9128c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ exports[`SshPassphrase snapshot 1`] = `
required={false}
type="password"
/>
</div>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,33 +34,35 @@ describe('SshPassphrase', () => {
});

describe('text area', () => {
it('should handle SSH passphrase', () => {
it('should handle SSH passphrase', async () => {
renderComponent();

expect(mockOnChange).not.toHaveBeenCalled();

const input = screen.getByPlaceholderText('Enter passphrase (optional)');

const passphrase = 'passphrase';
userEvent.paste(input, passphrase);
await userEvent.click(input)
await userEvent.paste(passphrase);

expect(mockOnChange).toHaveBeenCalledWith(passphrase);
});

it('should handle the empty value', () => {
it('should handle the empty value', async () => {
renderComponent();

expect(mockOnChange).not.toHaveBeenCalled();

const input = screen.getByPlaceholderText('Enter passphrase (optional)');

// fill the SSH key data field
userEvent.paste(input, 'ssh-key-data');
await userEvent.click(input);
await userEvent.paste('ssh-key-data');

mockOnChange.mockClear();

// clear the SSH key data field
userEvent.clear(input);
await userEvent.clear(input);

expect(mockOnChange).toHaveBeenCalledWith('');
});
Expand Down

0 comments on commit c9128c3

Please sign in to comment.