diff --git a/src/components/templates/Page/Page.test.tsx b/src/components/templates/Page/Page.test.tsx new file mode 100644 index 0000000..904ecf7 --- /dev/null +++ b/src/components/templates/Page/Page.test.tsx @@ -0,0 +1,32 @@ +import { screen } from '@testing-library/react' + +import { renderWithRouter as render } from 'components/utils/tests' + +import Page from '.' + +describe('Page component', () => { + const defaultProps = { + title: 'Test Page', + children:
Test Content
, + sx: { color: 'text.secondary' }, + } + + it('renders correctly and without crashing', () => { + render() + + // displays the correct title + expect(screen.getByText(defaultProps.title)).toBeInTheDocument() + + // displays the correct children + expect(screen.getByText('Test Content')).toBeInTheDocument() + + // sets the document title correctly + expect(document.title).toBe(`Michele Tartari - ${defaultProps.title}`) + }) + + it('does not render the title and divider when title is not provided', () => { + render() + expect(screen.queryByText(defaultProps.title)).not.toBeInTheDocument() + expect(screen.queryByRole('separator')).not.toBeInTheDocument() + }) +})