feat: ui:disabled allowed in DefaultRepoBranchPicker
Signed-off-by: Nikunj Hudka <nikunjhudka123@gmail.com>
This commit is contained in:
+18
-1
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import { fireEvent, render } from '@testing-library/react';
|
||||
import { fireEvent, render, screen } from '@testing-library/react';
|
||||
|
||||
import { DefaultRepoBranchPicker } from './DefaultRepoBranchPicker';
|
||||
|
||||
@@ -33,6 +33,23 @@ describe('DefaultRepoBranchPicker', () => {
|
||||
expect(getByRole('textbox')).toHaveValue('main');
|
||||
});
|
||||
|
||||
it('input field disabled', () => {
|
||||
render(
|
||||
<DefaultRepoBranchPicker
|
||||
onChange={jest.fn()}
|
||||
isDisabled
|
||||
state={{ branch: 'main' }}
|
||||
rawErrors={[]}
|
||||
/>,
|
||||
);
|
||||
|
||||
const input = screen.getByRole('textbox');
|
||||
|
||||
// Expect input to be disabled
|
||||
expect(input).toBeDisabled();
|
||||
expect(input).toHaveValue('main');
|
||||
});
|
||||
|
||||
it('calls onChange when the input field changes', () => {
|
||||
const onChange = jest.fn();
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ export const DefaultRepoBranchPicker = ({
|
||||
onChange,
|
||||
state,
|
||||
rawErrors,
|
||||
isDisabled,
|
||||
required,
|
||||
}: BaseRepoBranchPickerProps) => {
|
||||
const { branch } = state;
|
||||
@@ -45,6 +46,7 @@ export const DefaultRepoBranchPicker = ({
|
||||
<TextField
|
||||
id="branchInput"
|
||||
label="Branch"
|
||||
disabled={isDisabled}
|
||||
onChange={e => onChange({ branch: e.target.value })}
|
||||
value={branch}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user