Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions app/generator/components/PreviewPanel.type-compiler.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { describe, it, expectTypeOf, expect } from 'vitest';
import React from 'react';
import { PreviewPanel } from './PreviewPanel';

describe('PreviewPanel Type Compiler Validation', () => {
it('exports PreviewPanel as a callable React component', () => {
expectTypeOf<typeof PreviewPanel>().toBeFunction();
});

it('accepts component props', () => {
type Props = React.ComponentProps<typeof PreviewPanel>;

expectTypeOf<Props>().toMatchObjectType<{
markdown: string;
}>();
});

it('preserves component prop schema', () => {
type Props = React.ComponentProps<typeof PreviewPanel>;

expectTypeOf<Props['markdown']>().toEqualTypeOf<string>();
});

it('supports compile-time validation for component props', () => {
const validProps: React.ComponentProps<typeof PreviewPanel> = {
markdown: '# Hello World',
};

expect(validProps.markdown).toBe('# Hello World');

const invalidProps: React.ComponentProps<typeof PreviewPanel> = {
// @ts-expect-error - markdown must be a string
markdown: 123,
};

expect(invalidProps).toBeDefined();

expect(invalidProps).toBeDefined();
});

it('accepts a valid props object', () => {
const props: React.ComponentProps<typeof PreviewPanel> = {
markdown: 'Sample markdown',
};

expect(props.markdown).toBe('Sample markdown');
});
});
Loading