Merge pull request #28114 from schultzp2020/add-tests
fix: remove test has no assertions warning
This commit is contained in:
@@ -55,7 +55,7 @@ describe('ApiProvider', () => {
|
||||
<MyHocConsumer />
|
||||
</ApiProvider>,
|
||||
);
|
||||
renderedHoc.getByText('hoc message: hello');
|
||||
expect(renderedHoc.getByText('hoc message: hello')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should provide nested access to apis', () => {
|
||||
@@ -84,7 +84,7 @@ describe('ApiProvider', () => {
|
||||
</ApiProvider>
|
||||
</ApiProvider>,
|
||||
);
|
||||
renderedHook.getByText('a=z b=y');
|
||||
expect(renderedHook.getByText('a=z b=y')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should ignore deps in prototype', () => {
|
||||
@@ -107,7 +107,7 @@ describe('ApiProvider', () => {
|
||||
<MyWeirdHocConsumer />
|
||||
</ApiProvider>,
|
||||
);
|
||||
renderedHoc.getByText('hoc message: hello');
|
||||
expect(renderedHoc.getByText('hoc message: hello')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should error if no provider is available', () => {
|
||||
@@ -229,6 +229,6 @@ describe('v1 consumer', () => {
|
||||
<MyHookConsumerV1 />
|
||||
</ApiProvider>,
|
||||
);
|
||||
renderedHook.getByText('hook message: hello');
|
||||
expect(renderedHook.getByText('hook message: hello')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -34,8 +34,12 @@ describe('<CodeSnippet />', () => {
|
||||
// react-syntax-highlighter is large and can cause significant slowdowns
|
||||
// This test makes sure we're loading things in asynchronously and not too broadly.
|
||||
it('renders quickly', async () => {
|
||||
const start = new Date();
|
||||
await renderInTestApp(<CodeSnippet text="" language="javascript" />);
|
||||
}, 1000);
|
||||
const end = new Date();
|
||||
|
||||
expect(end.getTime() - start.getTime()).toBeLessThanOrEqual(1000);
|
||||
}, 1500);
|
||||
|
||||
it('renders text without exploding', async () => {
|
||||
const { getByText } = await renderInTestApp(<CodeSnippet {...minProps} />);
|
||||
|
||||
+2
-2
@@ -58,8 +58,8 @@ describe('<FeatureCalloutCircular />', () => {
|
||||
description="description"
|
||||
/>,
|
||||
);
|
||||
rendered.getByText('description');
|
||||
rendered.getByText('title');
|
||||
expect(rendered.getByText('description')).toBeInTheDocument();
|
||||
expect(rendered.getByText('title')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders with correct style', async () => {
|
||||
|
||||
@@ -20,10 +20,12 @@ import { OverflowTooltip } from './OverflowTooltip';
|
||||
|
||||
describe('<OverflowTooltip />', () => {
|
||||
it('renders without exploding', async () => {
|
||||
render(<OverflowTooltip text="Text that may overflow" />);
|
||||
expect(
|
||||
render(<OverflowTooltip text="Text that may overflow" />),
|
||||
).toBeTruthy();
|
||||
});
|
||||
|
||||
it('renders without exploding when the text prop is missing', async () => {
|
||||
render(<OverflowTooltip text={undefined} />);
|
||||
expect(render(<OverflowTooltip text={undefined} />)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -24,34 +24,34 @@ describe('<Gauge />', () => {
|
||||
const { getByText } = await renderInTestApp(
|
||||
<Gauge value={10} fractional={false} />,
|
||||
);
|
||||
getByText('10%');
|
||||
expect(getByText('10%')).toBeInTheDocument();
|
||||
});
|
||||
it('handles fractional prop', async () => {
|
||||
const { getByText } = await renderInTestApp(
|
||||
<Gauge value={0.1} fractional />,
|
||||
);
|
||||
getByText('10%');
|
||||
expect(getByText('10%')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('handles max prop', async () => {
|
||||
const { getByText } = await renderInTestApp(
|
||||
<Gauge value={1} max={10} fractional={false} />,
|
||||
);
|
||||
getByText('1%');
|
||||
expect(getByText('1%')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('handles unit prop', async () => {
|
||||
const { getByText } = await renderInTestApp(
|
||||
<Gauge value={10} fractional={false} unit="m" />,
|
||||
);
|
||||
getByText('10m');
|
||||
expect(getByText('10m')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('handle relativeToMax prop', async () => {
|
||||
const { getByText } = await renderInTestApp(
|
||||
<Gauge value={7} max={10} relativeToMax fractional={false} unit=" pts" />,
|
||||
);
|
||||
getByText('7 pts');
|
||||
expect(getByText('7 pts')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('handle decimalDigits prop', async () => {
|
||||
@@ -65,7 +65,7 @@ describe('<Gauge />', () => {
|
||||
unit="/10"
|
||||
/>,
|
||||
);
|
||||
getByText('5.50/10');
|
||||
expect(getByText('5.50/10')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
const ok = '#111';
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
import React from 'react';
|
||||
import { ContentHeader } from './ContentHeader';
|
||||
import { renderInTestApp } from '@backstage/test-utils';
|
||||
import _ from 'lodash';
|
||||
|
||||
jest.mock('react-helmet', () => {
|
||||
return {
|
||||
@@ -27,14 +28,14 @@ jest.mock('react-helmet', () => {
|
||||
describe('<ContentHeader/>', () => {
|
||||
it('should render with title', async () => {
|
||||
const rendered = await renderInTestApp(<ContentHeader title="Title" />);
|
||||
rendered.getByText('Title');
|
||||
expect(rendered.getByText('Title')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render without title', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<ContentHeader>content</ContentHeader>,
|
||||
);
|
||||
rendered.getByText('content');
|
||||
expect(rendered.getByText('content')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render with titleComponent', async () => {
|
||||
@@ -43,13 +44,13 @@ describe('<ContentHeader/>', () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<ContentHeader titleComponent={titleComponent} />,
|
||||
);
|
||||
rendered.getByText(title);
|
||||
expect(rendered.getByText(title)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should render with description', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<ContentHeader description="description" />,
|
||||
);
|
||||
rendered.getByText('description');
|
||||
expect(rendered.getByText('description')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -29,42 +29,46 @@ jest.mock('react-helmet', () => {
|
||||
describe('<Header/>', () => {
|
||||
it('should render with title', async () => {
|
||||
const rendered = await renderInTestApp(<Header title="Title" />);
|
||||
rendered.getByText('Title');
|
||||
expect(rendered.getByText('Title')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should set document title', async () => {
|
||||
const rendered = await renderInTestApp(<Header title="Title1" />);
|
||||
rendered.getByText('Title1');
|
||||
rendered.getByText('defaultTitle: Title1 | Backstage');
|
||||
expect(rendered.getByText('Title1')).toBeInTheDocument();
|
||||
expect(
|
||||
rendered.getByText('defaultTitle: Title1 | Backstage'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should override document title', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<Header title="Title1" pageTitleOverride="Title2" />,
|
||||
);
|
||||
rendered.getByText('Title1');
|
||||
rendered.getByText('defaultTitle: Title2 | Backstage');
|
||||
expect(rendered.getByText('Title1')).toBeInTheDocument();
|
||||
expect(
|
||||
rendered.getByText('defaultTitle: Title2 | Backstage'),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should have subtitle', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<Header title="Title" subtitle="Subtitle" />,
|
||||
);
|
||||
rendered.getByText('Subtitle');
|
||||
expect(rendered.getByText('Subtitle')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should have type rendered', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<Header title="Title" type="tool" />,
|
||||
);
|
||||
rendered.getByText('tool');
|
||||
expect(rendered.getByText('tool')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should have breadcrumb rendered', async () => {
|
||||
const rendered = await renderInTestApp(
|
||||
<Header title="Title" type="tool" typeLink="/tool" />,
|
||||
);
|
||||
rendered.getAllByText('Title');
|
||||
expect(rendered.getAllByText('Title')).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should use app.title', async () => {
|
||||
@@ -75,6 +79,6 @@ describe('<Header/>', () => {
|
||||
<Header title="Title" type="tool" typeLink="/tool" />,
|
||||
</TestApiProvider>,
|
||||
);
|
||||
rendered.getAllByText(/Title | Blah/);
|
||||
expect(rendered.getAllByText(/Title | Blah/)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -22,7 +22,14 @@ import userEvent from '@testing-library/user-event';
|
||||
|
||||
describe('<ComponentContextMenu />', () => {
|
||||
it('renders without any items and without exploding', async () => {
|
||||
await renderInTestApp(<HeaderActionMenu actionItems={[]} />);
|
||||
const rendered = await renderInTestApp(
|
||||
<HeaderActionMenu actionItems={[]} />,
|
||||
);
|
||||
|
||||
expect(rendered.queryByTestId('header-action-menu')).toBeInTheDocument();
|
||||
expect(
|
||||
rendered.queryByTestId('header-action-item'),
|
||||
).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('can open the menu and click menu items', async () => {
|
||||
|
||||
Reference in New Issue
Block a user