chore(environment,trading): fix unit tests for footer and node switcher (#3682)

This commit is contained in:
Matthew Russell 2023-05-09 13:39:17 -07:00 committed by GitHub
parent bded1d32ba
commit e44cf1ff53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 24 deletions

View File

@ -4,18 +4,15 @@ import { NodeHealth, NodeUrl, HealthIndicator } from './footer';
import { MockedProvider } from '@apollo/client/testing';
import { Intent } from '@vegaprotocol/ui-toolkit';
const mockSetNodeSwitcher = jest.fn();
jest.mock('@vegaprotocol/environment', () => ({
...jest.requireActual('@vegaprotocol/environment'),
useEnvironment: jest.fn().mockImplementation(() => ({
VEGA_URL: 'https://vega-url.wtf',
VEGA_INCIDENT_URL: 'https://blog.vega.community',
})),
}));
const mockSetNodeSwitcher = jest.fn();
jest.mock('../../stores', () => ({
...jest.requireActual('../../stores'),
useGlobalStore: () => mockSetNodeSwitcher,
useNodeSwitcherStore: jest.fn(() => mockSetNodeSwitcher),
}));
describe('NodeHealth', () => {

View File

@ -96,13 +96,13 @@ describe('RowData', () => {
mockHeaders(props.url);
render(renderComponent(props, statsQueryMock, subMock));
// radio should be disabled until query resolves
// radio should be enabled until query resolves
expect(
screen.getByRole('radio', {
checked: false,
name: props.url,
})
).toBeDisabled();
).toBeEnabled();
expect(screen.getByTestId('response-time-cell')).toHaveTextContent(
'Checking'
);
@ -124,7 +124,7 @@ describe('RowData', () => {
});
});
it('radio button disabled if query fails', async () => {
it('radio button still enabled if query fails', async () => {
mockHeaders(props.url, {});
const failedQueryMock: MockedResponse<StatisticsQuery> = {
@ -149,7 +149,7 @@ describe('RowData', () => {
checked: false,
name: props.url,
})
).toBeDisabled();
).toBeEnabled();
expect(screen.getByTestId('response-time-cell')).toHaveTextContent(
'Checking'
);
@ -170,7 +170,7 @@ describe('RowData', () => {
checked: false,
name: props.url,
})
).toBeDisabled();
).toBeEnabled();
});
});
@ -207,19 +207,6 @@ describe('RowData', () => {
expect(screen.getByTestId('block-height-cell')).toHaveClass('text-danger');
});
it('disables radio button if url is invalid', () => {
mockHeaders(props.url, { blockHeight: 100 });
render(renderComponent(props, statsQueryMock, subMock));
expect(
screen.getByRole('radio', {
checked: false,
name: props.url,
})
).toBeDisabled();
});
it('doesnt render the radio if its the custom row', () => {
render(
renderComponent(