Add test case for Progress component (#2953)
* remove data-testid from div * add test case for Progress component * add changeset * update the GraphiQLPage test cases to handle Progress timeout * update the RadarComponent and RadarPage test case to handle Progress timeout * update the TechDocsProgressBar test case to handle Progress timeout * add changeset
This commit is contained in:
@@ -19,6 +19,7 @@ import { GraphiQLPage } from './GraphiQLPage';
|
||||
import { ThemeProvider } from '@material-ui/core';
|
||||
import { lightTheme } from '@backstage/theme';
|
||||
import { ApiProvider, ApiRegistry } from '@backstage/core';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { renderWithEffects } from '@backstage/test-utils';
|
||||
import { GraphQLBrowseApi, graphQlBrowseApiRef } from '../../lib/api';
|
||||
|
||||
@@ -28,6 +29,7 @@ jest.mock('../GraphiQLBrowser', () => ({
|
||||
|
||||
describe('GraphiQLPage', () => {
|
||||
it('should show progress', async () => {
|
||||
jest.useFakeTimers();
|
||||
const loadingApi: GraphQLBrowseApi = {
|
||||
async getEndpoints() {
|
||||
await new Promise(() => {});
|
||||
@@ -43,9 +45,12 @@ describe('GraphiQLPage', () => {
|
||||
,
|
||||
</ApiProvider>,
|
||||
);
|
||||
|
||||
act(() => {
|
||||
jest.advanceTimersByTime(250);
|
||||
});
|
||||
rendered.getByText('GraphiQL');
|
||||
rendered.getByTestId('progress');
|
||||
jest.useRealTimers();
|
||||
});
|
||||
|
||||
it('should show error', async () => {
|
||||
|
||||
Reference in New Issue
Block a user