2024-03-10 12:22:01 +00:00
|
|
|
import { render } from '@testing-library/react';
|
|
|
|
|
2021-12-30 15:46:12 +00:00
|
|
|
import { UserViewModel } from '@/portainer/models/user';
|
2024-03-10 12:22:01 +00:00
|
|
|
import { withTestRouter } from '@/react/test-utils/withRouter';
|
|
|
|
import { withUserProvider } from '@/react/test-utils/withUserProvider';
|
|
|
|
import { withTestQueryProvider } from '@/react/test-utils/withTestQuery';
|
2021-12-30 15:46:12 +00:00
|
|
|
|
|
|
|
import { PageHeader } from './PageHeader';
|
|
|
|
|
|
|
|
test('should display a PageHeader', async () => {
|
|
|
|
const username = 'username';
|
|
|
|
const user = new UserViewModel({ Username: username });
|
|
|
|
|
2024-03-10 12:22:01 +00:00
|
|
|
const Wrapped = withTestQueryProvider(
|
|
|
|
withUserProvider(withTestRouter(PageHeader), user)
|
2021-12-30 15:46:12 +00:00
|
|
|
);
|
|
|
|
|
2024-03-10 12:22:01 +00:00
|
|
|
const title = 'title';
|
|
|
|
const { queryByText } = render(<Wrapped title={title} />);
|
|
|
|
|
2021-12-30 15:46:12 +00:00
|
|
|
const heading = queryByText(title);
|
|
|
|
expect(heading).toBeVisible();
|
|
|
|
|
|
|
|
expect(queryByText(username)).toBeVisible();
|
|
|
|
});
|