Skip to content

Commit bcdbf0a

Browse files
test(template): add empty fallback coverage
1 parent 81d9f71 commit bcdbf0a

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// app/template.empty-fallback.test.tsx
2+
3+
import { describe, expect, it, vi } from 'vitest';
4+
import { render, screen } from '@testing-library/react';
5+
import '@testing-library/jest-dom';
6+
7+
vi.mock('framer-motion', () => ({
8+
motion: {
9+
div: ({ children }: { children?: React.ReactNode }) => (
10+
<div data-testid="motion-wrapper">{children}</div>
11+
),
12+
},
13+
}));
14+
15+
import Template from './template';
16+
17+
describe('Template Empty & Missing Input Fallbacks', () => {
18+
it('renders successfully with null children', () => {
19+
render(<Template>{null}</Template>);
20+
21+
expect(screen.getByTestId('motion-wrapper')).toBeInTheDocument();
22+
});
23+
24+
it('renders successfully with undefined children', () => {
25+
render(<Template>{undefined}</Template>);
26+
27+
expect(screen.getByTestId('motion-wrapper')).toBeInTheDocument();
28+
});
29+
30+
it('renders successfully with an empty fragment', () => {
31+
render(
32+
<Template>
33+
<></>
34+
</Template>
35+
);
36+
37+
expect(screen.getByTestId('motion-wrapper')).toBeInTheDocument();
38+
});
39+
40+
it('preserves wrapper structure when no content is provided', () => {
41+
render(<Template>{null}</Template>);
42+
43+
const wrapper = screen.getByTestId('motion-wrapper');
44+
45+
expect(wrapper).toBeInTheDocument();
46+
expect(wrapper.childElementCount).toBe(0);
47+
});
48+
49+
it('renders provided content correctly', () => {
50+
render(
51+
<Template>
52+
<div>Fallback Content</div>
53+
</Template>
54+
);
55+
56+
expect(screen.getByText('Fallback Content')).toBeInTheDocument();
57+
});
58+
});

0 commit comments

Comments
 (0)