From 0437bcb574da45ca022e6fb73b7aa1ebaf34835a Mon Sep 17 00:00:00 2001
From: deletedUser <86692796+DeletedUser9@users.noreply.github.com>
Date: Mon, 20 Jul 2026 18:54:25 +1200
Subject: [PATCH] test: added test cases for VideoHighlightCard component
---
.../VideoHighlightCard.test.tsx | 98 +++++++++++++++++++
1 file changed, 98 insertions(+)
create mode 100644 src/app/(frontend)/gallery/_components/video-highlights/VideoHighlightCard.test.tsx
diff --git a/src/app/(frontend)/gallery/_components/video-highlights/VideoHighlightCard.test.tsx b/src/app/(frontend)/gallery/_components/video-highlights/VideoHighlightCard.test.tsx
new file mode 100644
index 00000000..a3faa19f
--- /dev/null
+++ b/src/app/(frontend)/gallery/_components/video-highlights/VideoHighlightCard.test.tsx
@@ -0,0 +1,98 @@
+import { render } from '@testing-library/react'
+import { describe, expect, it } from 'vitest'
+
+import { VideoHighlightCard } from './VideoHighlightCard'
+
+describe('VideoHighlightCard', () => {
+ describe('no url prop is provided', () => {
+ it('renders grey placeholder', () => {
+ const { container } = render()
+ const placeholder = container.querySelector('div')
+ expect(placeholder).not.toBeNull()
+ expect(placeholder?.className).toContain('bg-[#D9D9D9]')
+ })
+ it('does not render an iframe', () => {
+ const { container } = render()
+
+ expect(container.querySelector('iframe')).toBeNull()
+ })
+ })
+
+ describe('when a valid YouTube URL is passed', () => {
+ it('renders an iframe with the YouTube embed url', () => {
+ const { container } = render(
+ ,
+ )
+
+ const iframe = container.querySelector('iframe')
+ expect(iframe).not.toBeNull()
+ expect(iframe?.getAttribute('src')).toBe(
+ 'https://www.youtube.com/embed/dQw4w9WgXcQ',
+ )
+ })
+
+ it('renders an iframe for a youtu.be short URL', () => {
+ const { container } = render(
+ ,
+ )
+
+ const iframe = container.querySelector('iframe')
+ expect(iframe).not.toBeNull()
+ expect(iframe?.getAttribute('src')).toBe(
+ 'https://www.youtube.com/embed/dQw4w9WgXcQ',
+ )
+ })
+ })
+
+ describe('when a valid Vimeo URL is passed', () => {
+ it('renders an iframe with the Vimeo embed url', () => {
+ const { container } = render(
+ ,
+ )
+
+ const iframe = container.querySelector('iframe')
+ expect(iframe).not.toBeNull()
+ expect(iframe?.getAttribute('src')).toBe(
+ 'https://player.vimeo.com/video/123456789',
+ )
+ })
+ })
+
+ describe('iframe attributes', () => {
+ it('has the allowFullScreen attribute', () => {
+ const { container } = render(
+ ,
+ )
+
+ const iframe = container.querySelector('iframe')
+ expect(iframe?.hasAttribute('allowfullscreen')).toBe(true)
+ })
+
+ it('has a non-empty title attribute', () => {
+ const { container } = render(
+ ,
+ )
+
+ const iframe = container.querySelector('iframe')
+ const title = iframe?.getAttribute('title')
+ expect(title).toBeTruthy()
+ expect(title?.trim().length).toBeGreaterThan(0)
+ })
+ })
+
+ describe('when the url is an empty string', () => {
+ it('does not render an iframe', () => {
+ const { container } = render()
+
+ expect(container.querySelector('iframe')).toBeNull()
+ })
+ })
+
+ describe('when the url is invalid', () => {
+ it('does not render an iframe', () => {
+ const { container } = render()
+
+ expect(container.querySelector('iframe')).toBeNull()
+ })
+ })
+})