made more tests async

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2021-10-13 16:18:59 +02:00
parent 22722f3cb2
commit 9f6c4233ac
@@ -16,7 +16,7 @@
import { Entity } from '@backstage/catalog-model';
import { makeStyles } from '@material-ui/core';
import { render } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import { renderHook } from '@testing-library/react-hooks';
import React from 'react';
import { PreviewCatalogInfoComponent } from './PreviewCatalogInfoComponent';
@@ -46,15 +46,17 @@ const entities: Entity[] = [
describe('<PreviewCatalogInfoComponent />', () => {
it('renders without exploding', async () => {
const { getByText, findByText } = render(
render(
<PreviewCatalogInfoComponent
repositoryUrl="http://my-repository/a/"
entities={entities}
/>,
);
const repositoryUrl = getByText('http://my-repository/a/catalog-info.yaml');
const kindText = await findByText('Kind_2');
const repositoryUrl = screen.getByText(
'http://my-repository/a/catalog-info.yaml',
);
const kindText = await screen.findByText('Kind_2');
expect(repositoryUrl).toBeInTheDocument();
expect(repositoryUrl).toBeVisible();
expect(kindText).toBeInTheDocument();
@@ -64,7 +66,7 @@ describe('<PreviewCatalogInfoComponent />', () => {
it('renders card with custom styles', async () => {
const { result } = renderHook(() => useStyles());
const { getByText } = render(
render(
<PreviewCatalogInfoComponent
repositoryUrl="http://my-repository/a/"
entities={entities}
@@ -72,8 +74,10 @@ describe('<PreviewCatalogInfoComponent />', () => {
/>,
);
const repositoryUrl = getByText('http://my-repository/a/catalog-info.yaml');
const kindText = getByText('Kind_2');
const repositoryUrl = screen.getByText(
'http://my-repository/a/catalog-info.yaml',
);
const kindText = await screen.findByText('Kind_2');
expect(repositoryUrl).toBeInTheDocument();
expect(repositoryUrl).not.toBeVisible();
expect(kindText).toBeInTheDocument();
@@ -83,7 +87,7 @@ describe('<PreviewCatalogInfoComponent />', () => {
it('renders with custom styles', async () => {
const { result } = renderHook(() => useStyles());
const { getByText } = render(
render(
<PreviewCatalogInfoComponent
repositoryUrl="http://my-repository/a/"
entities={entities}
@@ -91,8 +95,10 @@ describe('<PreviewCatalogInfoComponent />', () => {
/>,
);
const repositoryUrl = getByText('http://my-repository/a/catalog-info.yaml');
const kindText = getByText('Kind_2');
const repositoryUrl = screen.getByText(
'http://my-repository/a/catalog-info.yaml',
);
const kindText = await screen.findByText('Kind_2');
expect(repositoryUrl).toBeInTheDocument();
expect(repositoryUrl).toBeVisible();
expect(kindText).toBeInTheDocument();