grafana/public/app/core/components/PageHeader/PageHeader.test.tsx
Torkel Ödegaard 1e85a6f4fd
TopNav: New page layouts (#51510)
* First stab at new page layouts behind feature toggle

* Simplifying PageHeader

* Progress on a new model that can more easily support new and old page layouts

* Progress

* rename folder

* Progress

* Minor change

* fixes

* Fixing tests

* Make breadcrumbs work

* Add tests for old Page component

* Adding tests for new Page component and behavior

* fixing page header test

* Fixed test

* AppChrome outside route

* Renaming folder

* Minor fix

* Updated

* Fixing StoragePage

* Fix for banners

Co-authored-by: Ashley Harrison <ashley.harrison@grafana.com>
2022-07-06 17:00:56 +02:00

41 lines
1.2 KiB
TypeScript

import { render, screen } from '@testing-library/react';
import React from 'react';
import { PageHeader } from './PageHeader';
describe('PageHeader', () => {
describe('when the nav tree has a node with a title', () => {
it('should render the title', async () => {
const nav = {
icon: 'folder-open',
id: 'node',
subTitle: 'node subtitle',
url: '',
text: 'node',
};
render(<PageHeader navItem={nav as any} />);
expect(screen.getByRole('heading', { name: 'node' })).toBeInTheDocument();
});
});
describe('when the nav tree has a node with breadcrumbs and a title', () => {
it('should render the title with breadcrumbs first and then title last', async () => {
const nav = {
icon: 'folder-open',
id: 'child',
subTitle: 'child subtitle',
url: '',
text: 'child',
breadcrumbs: [{ title: 'Parent', url: 'parentUrl' }],
};
render(<PageHeader navItem={nav as any} />);
expect(screen.getByRole('heading', { name: 'Parent / child' })).toBeInTheDocument();
expect(screen.getByRole('link', { name: 'Parent' })).toBeInTheDocument();
});
});
});