Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit 54d501d

Browse files
committed
fix: added test case
1 parent c4dd511 commit 54d501d

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/features/Apiexplorer/RequestJSONBox/__tests__/RequestJsonBox.test.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ describe('RequestResponseRenderer', () => {
7373
expect(placeholder).toHaveLength(1);
7474
});
7575

76+
it('should disable text box if no api call is selected in the dropdown', () => {
77+
const newProps = {
78+
handleChange: jest.fn(),
79+
request_example: '',
80+
name: null as TSocketEndpointNames,
81+
auth: 0,
82+
};
83+
cleanup();
84+
render(<RequestJSONBox {...newProps} />);
85+
const textarea = screen.getByLabelText('Request JSON');
86+
expect(textarea).toBeDisabled();
87+
});
88+
7689
it('should render response renderer component', async () => {
7790
const primaryButton = screen.getByRole('button', { name: /Send Request/i });
7891
const secondaryButton = screen.getByRole('button', { name: /clear/i });

src/features/Apiexplorer/RequestJSONBox/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ function RequestJSONBox<T extends TSocketEndpointNames>({
2525
const [isdisabled, setIsDisabled] = useState(false);
2626

2727
useEffect(() => {
28-
if (name === undefined) {
28+
if (name === null) {
2929
setIsDisabled(true);
30+
} else {
31+
setIsDisabled(false);
3032
}
3133
}, [name]);
3234

0 commit comments

Comments
 (0)