Skip to content

Commit dd38459

Browse files
test: add type compiler tests for SectionCard
1 parent f7be954 commit dd38459

1 file changed

Lines changed: 48 additions & 0 deletions

File tree

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { describe, it, expectTypeOf } from 'vitest';
2+
import React from 'react';
3+
import { SectionCard } from './SectionCard';
4+
5+
type SectionCardProps = React.ComponentProps<typeof SectionCard>;
6+
7+
describe('SectionCard Type Compiler Validation', () => {
8+
it('exports SectionCard as a callable React component', () => {
9+
expectTypeOf(SectionCard).toBeFunction();
10+
});
11+
12+
it('accepts component props', () => {
13+
const props: SectionCardProps = {
14+
title: 'Settings',
15+
children: <div>Content</div>,
16+
};
17+
18+
expectTypeOf(props).toEqualTypeOf<SectionCardProps>();
19+
});
20+
21+
it('preserves component prop schema', () => {
22+
expectTypeOf<SectionCardProps>().toEqualTypeOf<{
23+
title: string;
24+
icon?: string;
25+
description?: string;
26+
children: React.ReactNode;
27+
defaultOpen?: boolean;
28+
badge?: number;
29+
}>();
30+
});
31+
32+
it('supports compile-time validation for component props', () => {
33+
expectTypeOf<SectionCardProps>().toBeObject();
34+
});
35+
36+
it('accepts a valid props object', () => {
37+
const props: SectionCardProps = {
38+
title: 'Generator',
39+
children: <div />,
40+
icon: '⚙️',
41+
description: 'Example',
42+
defaultOpen: true,
43+
badge: 2,
44+
};
45+
46+
expectTypeOf(props).toEqualTypeOf<SectionCardProps>();
47+
});
48+
});

0 commit comments

Comments
 (0)