use renderInTestApp

Signed-off-by: Fredrik Adelöw <freben@gmail.com>
This commit is contained in:
Fredrik Adelöw
2023-09-14 21:22:11 +02:00
parent 8a6a66f621
commit ab6474579f
72 changed files with 2587 additions and 2982 deletions
@@ -14,8 +14,8 @@
* limitations under the License.
*/
import { wrapInTestApp } from '@backstage/test-utils';
import { render } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import { screen } from '@testing-library/react';
import * as React from 'react';
import { RollbarTopActiveItem } from '../../api/types';
import { RollbarTopItemsTable } from './RollbarTopItemsTable';
@@ -40,32 +40,28 @@ const items: RollbarTopActiveItem[] = [
describe('RollbarTopItemsTable component', () => {
it('should render empty data message when loaded and no data', async () => {
const rendered = render(
wrapInTestApp(
<RollbarTopItemsTable
items={[]}
organization="foo"
project="bar"
loading={false}
/>,
),
await renderInTestApp(
<RollbarTopItemsTable
items={[]}
organization="foo"
project="bar"
loading={false}
/>,
);
expect(rendered.getByText(/No records to display/)).toBeInTheDocument();
expect(screen.getByText(/No records to display/)).toBeInTheDocument();
});
it('should display item attributes when loading has finished', async () => {
const rendered = render(
wrapInTestApp(
<RollbarTopItemsTable
items={items}
organization="foo"
project="bar"
loading={false}
/>,
),
await renderInTestApp(
<RollbarTopItemsTable
items={items}
organization="foo"
project="bar"
loading={false}
/>,
);
expect(rendered.getByText(/1234/)).toBeInTheDocument();
expect(rendered.getByText(/Error in foo/)).toBeInTheDocument();
expect(rendered.getByText(/critical/)).toBeInTheDocument();
expect(screen.getByText(/1234/)).toBeInTheDocument();
expect(screen.getByText(/Error in foo/)).toBeInTheDocument();
expect(screen.getByText(/critical/)).toBeInTheDocument();
});
});
@@ -14,17 +14,16 @@
* limitations under the License.
*/
import { wrapInTestApp } from '@backstage/test-utils';
import { render } from '@testing-library/react';
import { renderInTestApp } from '@backstage/test-utils';
import React from 'react';
import { TrendGraph } from './TrendGraph';
describe('TrendGraph component', () => {
it('should render a trend graph sparkline', async () => {
const mockCounts = [1, 2, 3, 4];
const rendered = render(
wrapInTestApp(<TrendGraph counts={mockCounts} data-testid="graph" />),
await renderInTestApp(
<TrendGraph counts={mockCounts} data-testid="graph" />,
);
expect(rendered).toBeTruthy();
expect(true).toBeTruthy();
});
});