Files
grafana/public/app/core/components/PageHeader/PageHeader.test.tsx
Torkel Ödegaard 3e55c967ee Theming: Support for runtime theme switching and hooks for custom themes (#31301)
* WIP Custom themes

* Load custom themes from URL and via event

* Dynamic page background

* Header color change

* Fixing tests and emotion warnings

* Fixed test

* moving cx to getStyles

* Review fixes

* minor change
2021-02-20 09:02:06 +01:00

46 lines
1.3 KiB
TypeScript

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