このコミットが含まれているのは:
@@ -1,4 +1,4 @@
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { fireEvent, render, screen } from '@testing-library/react'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import PostThumbnailPreview from '@/components/posts/PostThumbnailPreview'
|
||||
@@ -9,4 +9,28 @@ describe ('PostThumbnailPreview', () => {
|
||||
|
||||
expect (screen.getByRole ('img')).toHaveAttribute ('src', 'blob:preview')
|
||||
})
|
||||
|
||||
it ('renders an empty thumbnail frame without text when the URL is empty', () => {
|
||||
const { container } = render (
|
||||
<PostThumbnailPreview url="" className="h-10 w-10"/>)
|
||||
|
||||
expect (screen.queryByRole ('img')).toBeNull ()
|
||||
expect (screen.queryByText ('サムネールを表示できません')).toBeNull ()
|
||||
expect (screen.queryByText ('なし')).toBeNull ()
|
||||
expect (container.querySelector ('div.rounded.border.bg-muted')).not.toBeNull ()
|
||||
expect (container.textContent).toBe ('')
|
||||
})
|
||||
|
||||
it ('renders an empty thumbnail frame without text when image loading fails', () => {
|
||||
const { container } = render (
|
||||
<PostThumbnailPreview url="blob:preview" className="h-10 w-10"/>)
|
||||
|
||||
fireEvent.error (screen.getByRole ('img'))
|
||||
|
||||
expect (screen.queryByRole ('img')).toBeNull ()
|
||||
expect (screen.queryByText ('サムネールを表示できません')).toBeNull ()
|
||||
expect (screen.queryByText ('なし')).toBeNull ()
|
||||
expect (container.querySelector ('div.rounded.border.bg-muted')).not.toBeNull ()
|
||||
expect (container.textContent).toBe ('')
|
||||
})
|
||||
})
|
||||
|
||||
新しい課題から参照
ユーザをブロックする