From cd3c4bc89c169616b38bdb7443bb4eb7571b020c Mon Sep 17 00:00:00 2001 From: Bertrand Yuan Date: Thu, 26 Mar 2026 00:15:40 +0800 Subject: fix defects in pr #11 --- src/components/json-ld.test.tsx | 2 +- src/components/json-ld.tsx | 2 +- src/components/ui/button.test.tsx | 15 +++++++++++---- 3 files changed, 13 insertions(+), 6 deletions(-) (limited to 'src/components') 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(); + const { container } = render(); 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(); + render(); 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(); + render(); const button = screen.getByText(`${size} Size`); expect(button).toBeInTheDocument(); }); -- cgit v1.2.3