Skip to content

Commit

Permalink
Merge pull request #334 from ameerul-deriv/FEQ-2632-endpoint-page-bec…
Browse files Browse the repository at this point in the history
…omes-blank-after-reset

Ameerul / FEQ-2632 Endpoint page become blank when click on Reset button
  • Loading branch information
farrah-deriv authored Sep 18, 2024
2 parents 6686628 + 808e9e5 commit cf5e2f7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/pages/endpoint/screens/Endpoint/Endpoint.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller, useForm } from 'react-hook-form';
import { getServerInfo } from '@/constants';
import { Button, Input, Text } from '@deriv-com/ui';
import { LocalStorageConstants, LocalStorageUtils } from '@deriv-com/utils';
import './Endpoint.scss';
Expand Down Expand Up @@ -86,7 +87,7 @@ const Endpoint = () => {
LocalStorageUtils.setValue<string>(LocalStorageConstants.configServerURL, '');
LocalStorageUtils.setValue<string>(LocalStorageConstants.configAppId, '');
reset();
window.location.reload();
getServerInfo();
}}
variant='outlined'
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import Endpoint from '../Endpoint';

const mockGetServerInfo = jest.fn();

jest.mock('@/constants', () => ({
getServerInfo: jest.fn(() => mockGetServerInfo()),
}));

describe('<Endpoint />', () => {
it('should render the endpoint component', () => {
render(<Endpoint />);
Expand All @@ -28,7 +34,7 @@ describe('<Endpoint />', () => {
expect(JSON.parse(localStorage.getItem('config.app_id') || '')).toBe('123');
});

it('should reset the server_url and app_id when user clicks on the reset button', async () => {
it('should call getServerInfo and reset the inputs when user clicks on the reset button', async () => {
render(<Endpoint />);

const serverUrlInput = screen.getByTestId('dt_endpoint_server_url_input');
Expand All @@ -41,5 +47,6 @@ describe('<Endpoint />', () => {

expect(JSON.parse(localStorage.getItem('config.server_url') || '')).toBe('');
expect(JSON.parse(localStorage.getItem('config.app_id') || '')).toBe('');
expect(mockGetServerInfo).toHaveBeenCalled();
});
});

0 comments on commit cf5e2f7

Please sign in to comment.