-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAppShell.test.tsx
More file actions
51 lines (45 loc) · 1.5 KB
/
Copy pathAppShell.test.tsx
File metadata and controls
51 lines (45 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import { render, screen, within } from '@testing-library/react';
import { usePathname } from 'next/navigation';
import { describe, expect, it, vi } from 'vitest';
import AppShell from './AppShell';
vi.mock('next/navigation', () => ({
usePathname: vi.fn(() => '/'),
}));
describe('AppShell', () => {
it('keeps primary navigation and external links available', () => {
const { container } = render(
<AppShell>
<main>content</main>
</AppShell>
);
const primaryNavigation = within(screen.getByLabelText('Ark 주요 탐색'));
expect(
primaryNavigation.getByRole('link', { name: 'Archive' })
).toHaveAttribute('href', '/archive');
expect(
primaryNavigation.getByRole('link', { name: 'Resume' })
).toHaveAttribute('href', '/resume');
expect(
primaryNavigation.queryByRole('link', { name: 'Tech' })
).not.toBeInTheDocument();
expect(screen.getAllByLabelText('Ark 외부 링크')).toHaveLength(1);
expect(container.querySelector('footer')).toContainElement(
screen.getByLabelText('Ark 외부 링크')
);
expect(
container.querySelector('[data-page-layout="home"]')
).toBeInTheDocument();
});
it('treats existing post routes as part of Archive', () => {
vi.mocked(usePathname).mockReturnValue('/blog/ctr-pipeline');
render(
<AppShell>
<main>content</main>
</AppShell>
);
expect(screen.getByRole('link', { name: 'Archive' })).toHaveAttribute(
'aria-current',
'page'
);
});
});