summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBertrand Yuan <noreply@bertyuan.com>2026-03-26 00:15:40 +0800
committerBertrand Yuan <noreply@bertyuan.com>2026-03-26 00:15:40 +0800
commitcd3c4bc89c169616b38bdb7443bb4eb7571b020c (patch)
tree71d0985970984c105582f6e3c370b254f38e9bbe
parent8a6a6712e7554f110b5ef951f270d88fd010e040 (diff)
fix defects in pr #11
-rw-r--r--src/components/json-ld.test.tsx2
-rw-r--r--src/components/json-ld.tsx2
-rw-r--r--src/components/ui/button.test.tsx15
-rw-r--r--vite.config.ts11
4 files changed, 21 insertions, 9 deletions
diff --git a/src/components/json-ld.test.tsx b/src/components/json-ld.test.tsx
index c96e5c3..6a81414 100644
--- a/src/components/json-ld.test.tsx
+++ b/src/components/json-ld.test.tsx
@@ -46,7 +46,7 @@ describe('json-ld components', () => {
});
test('returns null when post is not provided', () => {
- const { container } = render(<PostJsonLd post={null as unknown as any} />);
+ const { container } = render(<PostJsonLd post={null} />);
expect(container.firstChild).toBeNull();
});
diff --git a/src/components/json-ld.tsx b/src/components/json-ld.tsx
index 58cb0ba..bbfad33 100644
--- a/src/components/json-ld.tsx
+++ b/src/components/json-ld.tsx
@@ -4,7 +4,7 @@ import { baseUrl } from '@/lib/constants';
import type { BlogPost } from '@/lib/payload-posts';
import type { BlogPosting, BreadcrumbList, Graph } from 'schema-dts';
-export const PostJsonLd = ({ post }: { post: BlogPost }) => {
+export const PostJsonLd = ({ post }: { post: BlogPost | null | undefined }) => {
if (!post) {
return null;
}
diff --git a/src/components/ui/button.test.tsx b/src/components/ui/button.test.tsx
index 314e9bf..f8bd3a9 100644
--- a/src/components/ui/button.test.tsx
+++ b/src/components/ui/button.test.tsx
@@ -14,9 +14,16 @@ describe('Button', () => {
// Test buttons with different variants
test('renders button with different variants', () => {
- const variants = ['default', 'destructive', 'outline', 'secondary', 'ghost', 'link'];
+ const variants = [
+ 'default',
+ 'destructive',
+ 'outline',
+ 'secondary',
+ 'ghost',
+ 'link',
+ ] as const;
variants.forEach((variant) => {
- render(<Button variant={variant as any}>{variant} Variant</Button>);
+ render(<Button variant={variant}>{variant} Variant</Button>);
const button = screen.getByText(`${variant} Variant`);
expect(button).toBeInTheDocument();
});
@@ -24,9 +31,9 @@ describe('Button', () => {
// Test buttons with different sizes
test('renders button with different sizes', () => {
- const sizes = ['default', 'sm', 'lg', 'icon'];
+ const sizes = ['default', 'sm', 'lg', 'icon'] as const;
sizes.forEach((size) => {
- render(<Button size={size as any}>{size} Size</Button>);
+ render(<Button size={size}>{size} Size</Button>);
const button = screen.getByText(`${size} Size`);
expect(button).toBeInTheDocument();
});
diff --git a/vite.config.ts b/vite.config.ts
index ec36e8c..507d61a 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -7,9 +7,14 @@ export default defineConfig({
test: {
environment: 'jsdom',
setupFiles: './src/test/setup.ts',
- include: ['**/*.test.tsx', '**/*.test.ts'],
- alias: {
- '@': path.resolve(__dirname, './src'),
+ include: ['**/*.{test,spec}.{ts,tsx,js,jsx}'],
+ coverage: {
+ include: [
+ 'src/components/**/*.{ts,tsx}',
+ 'src/hooks/**/*.{ts,tsx}',
+ 'src/lib/**/*.{ts,tsx}',
+ ],
+ exclude: ['src/**/*.test.{ts,tsx,js,jsx}', 'src/test/**'],
},
},
resolve: {