chore(environment,trading): fix unit tests for footer and node switcher (#3682)
This commit is contained in:
parent
bded1d32ba
commit
e44cf1ff53
@ -4,18 +4,15 @@ import { NodeHealth, NodeUrl, HealthIndicator } from './footer';
|
|||||||
import { MockedProvider } from '@apollo/client/testing';
|
import { MockedProvider } from '@apollo/client/testing';
|
||||||
import { Intent } from '@vegaprotocol/ui-toolkit';
|
import { Intent } from '@vegaprotocol/ui-toolkit';
|
||||||
|
|
||||||
|
const mockSetNodeSwitcher = jest.fn();
|
||||||
|
|
||||||
jest.mock('@vegaprotocol/environment', () => ({
|
jest.mock('@vegaprotocol/environment', () => ({
|
||||||
...jest.requireActual('@vegaprotocol/environment'),
|
...jest.requireActual('@vegaprotocol/environment'),
|
||||||
useEnvironment: jest.fn().mockImplementation(() => ({
|
useEnvironment: jest.fn().mockImplementation(() => ({
|
||||||
VEGA_URL: 'https://vega-url.wtf',
|
VEGA_URL: 'https://vega-url.wtf',
|
||||||
VEGA_INCIDENT_URL: 'https://blog.vega.community',
|
VEGA_INCIDENT_URL: 'https://blog.vega.community',
|
||||||
})),
|
})),
|
||||||
}));
|
useNodeSwitcherStore: jest.fn(() => mockSetNodeSwitcher),
|
||||||
|
|
||||||
const mockSetNodeSwitcher = jest.fn();
|
|
||||||
jest.mock('../../stores', () => ({
|
|
||||||
...jest.requireActual('../../stores'),
|
|
||||||
useGlobalStore: () => mockSetNodeSwitcher,
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe('NodeHealth', () => {
|
describe('NodeHealth', () => {
|
||||||
|
@ -96,13 +96,13 @@ describe('RowData', () => {
|
|||||||
mockHeaders(props.url);
|
mockHeaders(props.url);
|
||||||
render(renderComponent(props, statsQueryMock, subMock));
|
render(renderComponent(props, statsQueryMock, subMock));
|
||||||
|
|
||||||
// radio should be disabled until query resolves
|
// radio should be enabled until query resolves
|
||||||
expect(
|
expect(
|
||||||
screen.getByRole('radio', {
|
screen.getByRole('radio', {
|
||||||
checked: false,
|
checked: false,
|
||||||
name: props.url,
|
name: props.url,
|
||||||
})
|
})
|
||||||
).toBeDisabled();
|
).toBeEnabled();
|
||||||
expect(screen.getByTestId('response-time-cell')).toHaveTextContent(
|
expect(screen.getByTestId('response-time-cell')).toHaveTextContent(
|
||||||
'Checking'
|
'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, {});
|
mockHeaders(props.url, {});
|
||||||
|
|
||||||
const failedQueryMock: MockedResponse<StatisticsQuery> = {
|
const failedQueryMock: MockedResponse<StatisticsQuery> = {
|
||||||
@ -149,7 +149,7 @@ describe('RowData', () => {
|
|||||||
checked: false,
|
checked: false,
|
||||||
name: props.url,
|
name: props.url,
|
||||||
})
|
})
|
||||||
).toBeDisabled();
|
).toBeEnabled();
|
||||||
expect(screen.getByTestId('response-time-cell')).toHaveTextContent(
|
expect(screen.getByTestId('response-time-cell')).toHaveTextContent(
|
||||||
'Checking'
|
'Checking'
|
||||||
);
|
);
|
||||||
@ -170,7 +170,7 @@ describe('RowData', () => {
|
|||||||
checked: false,
|
checked: false,
|
||||||
name: props.url,
|
name: props.url,
|
||||||
})
|
})
|
||||||
).toBeDisabled();
|
).toBeEnabled();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -207,19 +207,6 @@ describe('RowData', () => {
|
|||||||
expect(screen.getByTestId('block-height-cell')).toHaveClass('text-danger');
|
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', () => {
|
it('doesnt render the radio if its the custom row', () => {
|
||||||
render(
|
render(
|
||||||
renderComponent(
|
renderComponent(
|
||||||
|
Loading…
Reference in New Issue
Block a user