diff --git a/src/pages/endpoint/screens/Endpoint/Endpoint.tsx b/src/pages/endpoint/screens/Endpoint/Endpoint.tsx index 2e1face3..e1c4ff42 100644 --- a/src/pages/endpoint/screens/Endpoint/Endpoint.tsx +++ b/src/pages/endpoint/screens/Endpoint/Endpoint.tsx @@ -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'; @@ -86,7 +87,7 @@ const Endpoint = () => { LocalStorageUtils.setValue(LocalStorageConstants.configServerURL, ''); LocalStorageUtils.setValue(LocalStorageConstants.configAppId, ''); reset(); - window.location.reload(); + getServerInfo(); }} variant='outlined' > diff --git a/src/pages/endpoint/screens/Endpoint/__tests__/Endpoint.spec.tsx b/src/pages/endpoint/screens/Endpoint/__tests__/Endpoint.spec.tsx index 984e5b81..bc22acc7 100644 --- a/src/pages/endpoint/screens/Endpoint/__tests__/Endpoint.spec.tsx +++ b/src/pages/endpoint/screens/Endpoint/__tests__/Endpoint.spec.tsx @@ -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('', () => { it('should render the endpoint component', () => { render(); @@ -28,7 +34,7 @@ describe('', () => { 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(); const serverUrlInput = screen.getByTestId('dt_endpoint_server_url_input'); @@ -41,5 +47,6 @@ describe('', () => { expect(JSON.parse(localStorage.getItem('config.server_url') || '')).toBe(''); expect(JSON.parse(localStorage.getItem('config.app_id') || '')).toBe(''); + expect(mockGetServerInfo).toHaveBeenCalled(); }); });