Skip to content

Commit

Permalink
test: Assert type of props returned from getImageProps
Browse files Browse the repository at this point in the history
  • Loading branch information
icyJoseph committed Oct 2, 2024
1 parent b00824b commit 093283c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test/unit/next-image-get-img-props.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,30 @@ describe('getImageProps()', () => {
['src', '/_next/image?url=%2Ftest.png&w=256&q=75'],
])
})

it('should have correct type for props', async () => {
const { props } = getImageProps({
alt: 'a nice desc',
id: 'my-image',
src: '/test.png',
width: 100,
height: 200,
})

expect(props.alt).toBeString()
expect(props.id).toBeString()
expect(props.loading).toBeString()

expect(props.width).toBeNumber()
expect(props.height).toBeNumber()

expect(props.decoding).toBeString()
expect(props.style).toBeObject()
expect(props.style.color).toBeString()
expect(props.src).toBeString()
expect(props.srcSet).toBeString()
})

it('should handle priority', async () => {
const { props } = getImageProps({
alt: 'a nice desc',
Expand Down

0 comments on commit 093283c

Please sign in to comment.