test: update tests to work with onChange
Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
+12
-6
@@ -101,9 +101,13 @@ describe('BitbucketRepoPicker', () => {
|
||||
|
||||
const workspaceInput = getAllByRole('textbox')[0];
|
||||
|
||||
act(() => workspaceInput.focus());
|
||||
fireEvent.change(workspaceInput, { target: { value: 'test-workspace' } });
|
||||
act(() => workspaceInput.blur());
|
||||
act(() => {
|
||||
workspaceInput.focus();
|
||||
fireEvent.change(workspaceInput, {
|
||||
target: { value: 'test-workspace' },
|
||||
});
|
||||
workspaceInput.blur();
|
||||
});
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({ workspace: 'test-workspace' });
|
||||
});
|
||||
@@ -124,9 +128,11 @@ describe('BitbucketRepoPicker', () => {
|
||||
|
||||
const projectInput = getAllByRole('textbox')[1];
|
||||
|
||||
act(() => projectInput.focus());
|
||||
fireEvent.change(projectInput, { target: { value: 'test-project' } });
|
||||
act(() => projectInput.blur());
|
||||
act(() => {
|
||||
projectInput.focus();
|
||||
fireEvent.change(projectInput, { target: { value: 'test-project' } });
|
||||
projectInput.blur();
|
||||
});
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith({ project: 'test-project' });
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
useTemplateSecrets,
|
||||
ScaffolderRJSFField,
|
||||
} from '@backstage/plugin-scaffolder-react';
|
||||
import { act, fireEvent } from '@testing-library/react';
|
||||
import { act, fireEvent, waitFor } from '@testing-library/react';
|
||||
|
||||
describe('RepoUrlPicker', () => {
|
||||
const mockScaffolderApi: Partial<ScaffolderApi> = {
|
||||
@@ -98,8 +98,15 @@ describe('RepoUrlPicker', () => {
|
||||
const [ownerInput, repoInput] = getAllByRole('textbox');
|
||||
const submitButton = getByRole('button');
|
||||
|
||||
fireEvent.change(ownerInput, { target: { value: 'backstage' } });
|
||||
fireEvent.change(repoInput, { target: { value: 'repo123' } });
|
||||
act(() => {
|
||||
ownerInput.focus();
|
||||
fireEvent.change(ownerInput, { target: { value: 'backstage' } });
|
||||
ownerInput.blur();
|
||||
|
||||
repoInput.focus();
|
||||
fireEvent.change(repoInput, { target: { value: 'repo123' } });
|
||||
repoInput.blur();
|
||||
});
|
||||
|
||||
fireEvent.click(submitButton);
|
||||
|
||||
|
||||
+5
-3
@@ -71,9 +71,11 @@ describe('RepoUrlPickerRepoName', () => {
|
||||
|
||||
expect(textArea).toBeVisible();
|
||||
|
||||
act(() => textArea.focus());
|
||||
fireEvent.change(textArea, { target: { value: 'foo' } });
|
||||
act(() => textArea.blur());
|
||||
act(() => {
|
||||
textArea.focus();
|
||||
fireEvent.change(textArea, { target: { value: 'foo' } });
|
||||
textArea.blur();
|
||||
});
|
||||
|
||||
expect(onChange).toHaveBeenCalledWith('foo');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user