Skip to content

Commit 5d38526

Browse files
committed
refactor: simplify Home page export, add comprehensive vitest for HomeContent
1 parent 32e4892 commit 5d38526

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

app/page.test.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { render, screen } from '@testing-library/react';
2+
import HomeContent from './page';
3+
4+
vi.mock('@/components/TextGenerator', () => ({
5+
__esModule: true,
6+
default: () => <div>TextGenerator</div>,
7+
}));
8+
vi.mock('@/components/AuthButton', () => ({
9+
__esModule: true,
10+
default: () => <button>AuthButton</button>,
11+
}));
12+
vi.mock('@/components/LanguageSelector', () => ({
13+
__esModule: true,
14+
default: () => <div>LanguageSelector</div>,
15+
}));
16+
vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (k: string) => k }) }));
17+
18+
describe('HomeContent', () => {
19+
it('renders heading, subtitle, AuthButton, LanguageSelector, TextGenerator, and GitHub link', () => {
20+
render(<HomeContent />);
21+
expect(screen.getByText('Comprehendo')).toBeInTheDocument();
22+
expect(screen.getByText('subtitle')).toBeInTheDocument();
23+
expect(screen.getByText('AuthButton')).toBeInTheDocument();
24+
expect(screen.getByText('LanguageSelector')).toBeInTheDocument();
25+
expect(screen.getByText('TextGenerator')).toBeInTheDocument();
26+
expect(screen.getByRole('link', { name: 'github' })).toHaveAttribute(
27+
'href',
28+
'https://github.com/rgilks/comprehendo'
29+
);
30+
});
31+
});

app/page.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,4 @@ const HomeContent = () => {
5151
);
5252
};
5353

54-
const Home = () => {
55-
return <HomeContent />;
56-
};
57-
58-
export default Home;
54+
export default HomeContent;

0 commit comments

Comments
 (0)