Skip to content

Commit

Permalink
Add unit tests for src and children props
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentSmedinga committed Dec 12, 2023
1 parent aa5d3d4 commit 7df0514
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion packages/react/src/HeroImage/HeroImage.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render } from '@testing-library/react'
import { render, screen } from '@testing-library/react'
import { createRef } from 'react'
import { HeroImage } from './HeroImage'
import '@testing-library/jest-dom'
Expand Down Expand Up @@ -29,4 +29,20 @@ describe('Hero image', () => {
const component = container.querySelector(':only-child')
expect(ref.current).toBe(component)
})

it('passes source prop to image element', () => {
render(<HeroImage src="test-src" />)
const imgElement = screen.getByRole('img')
expect(imgElement).toHaveAttribute('src', 'test-src')
})

it('renders children', () => {
render(
<HeroImage src="test-src">
<p>Test Child</p>
</HeroImage>,
)
const testChild = screen.getByText('Test Child')
expect(testChild).toBeTruthy()
})
})

0 comments on commit 7df0514

Please sign in to comment.