Skip to content

Commit aa2da2a

Browse files
committed
test(packages/ui): test when alt prop is falsy in the image
1 parent 5ff89d0 commit aa2da2a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

packages/ui/src/image/image.spec.tsx

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,16 @@ vi.mock('next/image', () => ({
99

1010
describe('given that an asset is loaded onto the page', () => {
1111
describe('when the image is rendered', () => {
12-
describe('and the alt text is NOT provided', () => {
12+
describe('and the alt text is falsy', () => {
1313
test('then log an error to the console', () => {
1414
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {})
1515
const imageSource = '/path/to/image.jpg'
1616

17-
// @ts-expect-error NOTE: We are testing the error message
18-
render(<Image src={imageSource} width={18} height={18} />)
17+
render(<Image src={imageSource} alt="" width={18} height={18} />)
1918

2019
expect(consoleError).toHaveBeenCalledWith(
2120
`The source of the image must have an alt attribute. Please review the <Image src=\"${imageSource}\" alt=\"\" /> and provide an alt attribute for the image.`,
2221
)
23-
2422
consoleError.mockRestore()
2523
})
2624
})

0 commit comments

Comments
 (0)