aboutsummaryrefslogtreecommitdiffstats
path: root/src/test/Main.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/Main.test.ts')
-rw-r--r--src/test/Main.test.ts45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/test/Main.test.ts b/src/test/Main.test.ts
new file mode 100644
index 0000000..1fdd1e2
--- /dev/null
+++ b/src/test/Main.test.ts
@@ -0,0 +1,45 @@
1import { render, screen } from '@testing-library/svelte';
2import Main from '../lib/components/Main.svelte';
3
4describe('Main component', () => {
5 test('it renders the Projects section with the correct heading and content', () => {
6 render(Main);
7
8 const projectsHeading = screen.getByText('Projects');
9 expect(projectsHeading).toBeInTheDocument();
10
11 const projectText = screen.getByText(/git repository/i);
12 expect(projectText).toBeInTheDocument();
13
14 const link = screen.getByRole('link', { name: /git repository/i });
15 expect(link).toHaveAttribute('href', 'https://git.philw.dev');
16 expect(link).toHaveAttribute('target', '_blank');
17 });
18
19 test('it renders the Contact section with the correct heading and content', () => {
20 render(Main);
21
22 const contactHeading = screen.getByText('Contact');
23 expect(contactHeading).toBeInTheDocument();
24
25 const emailLink = screen.getByRole('link', { name: /email filip wandzio/i });
26 expect(emailLink).toHaveAttribute('href', 'mailto:contact@philw.dev');
27
28 const matrixLink = screen.getByRole('link', { name: /filip wandzio matrix account/i });
29 expect(matrixLink).toHaveAttribute('href', 'https://matrix.to/#/@philw:matrix.philw.dev');
30 });
31
32 test('it has the correct aria-labelledby attributes for accessibility', () => {
33 render(Main);
34
35 // Ensure sections are correctly labeled for accessibility
36 const aboutSection = screen.getByRole('region', { name: /about/i });
37 expect(aboutSection).toHaveAttribute('aria-labelledby', 'about-heading');
38
39 const projectsSection = screen.getByRole('region', { name: /projects/i });
40 expect(projectsSection).toHaveAttribute('aria-labelledby', 'projects-heading');
41
42 const contactSection = screen.getByRole('region', { name: /contact/i });
43 expect(contactSection).toHaveAttribute('aria-labelledby', 'contact-heading');
44 });
45});