diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.test.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.test.tsx
new file mode 100644
index 0000000000..4c392d646c
--- /dev/null
+++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.test.tsx
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2022 The Backstage Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import React from 'react';
+import { RepoUrlPickerRepoName } from './RepoUrlPickerRepoName';
+import { render, fireEvent } from '@testing-library/react';
+
+describe('RepoUrlPickerRepoName', () => {
+ it('should call onChange with the first allowed repo if there is none set already', async () => {
+ const onChange = jest.fn();
+
+ render(
+ ,
+ );
+
+ expect(onChange).toHaveBeenCalledWith('foo');
+ });
+
+ it('should render a dropdown of all the options', async () => {
+ const allowedRepos = ['foo', 'bar'];
+
+ const onChange = jest.fn();
+
+ const { getByRole } = render(
+ ,
+ );
+
+ const select = getByRole('combobox');
+ await fireEvent.click(select);
+
+ for (const option of allowedRepos) {
+ const element = getByRole('option', { name: option });
+ expect(element).toBeVisible();
+ }
+ });
+
+ it('should render a normal text area when no options are passed', async () => {
+ const onChange = jest.fn();
+
+ const { getByRole } = render(
+ ,
+ );
+
+ const textArea = getByRole('textbox');
+
+ expect(textArea).toBeVisible();
+
+ fireEvent.change(textArea, { target: { value: 'foo' } });
+
+ expect(onChange).toHaveBeenCalledWith('foo');
+ });
+});
diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.tsx
index f2d68b08f3..1393b1902e 100644
--- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.tsx
+++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPickerRepoName.tsx
@@ -54,7 +54,7 @@ export const RepoUrlPickerRepoName = (props: {
native
label="Repositories Available"
onChange={selected =>
- onChange(String(Array.isArray(selected) ? selected[0] : selected))
+ String(Array.isArray(selected) ? selected[0] : selected)
}
disabled={allowedRepos.length === 1}
selected={repoName}