Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
jankaifer committed Nov 21, 2022
1 parent eb93a04 commit 4f8a9e8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/integration/next-image-new/default/pages/ref-forwarding.js
@@ -0,0 +1,16 @@
import React from 'react'
import Image from 'next/image'
import { useRef } from 'react'
import { useEffect } from 'react'

export default function Page() {
const ref = useRef()
useEffect(() => {
window.ref = ref
}, [])
return (
<div>
<Image id="img" src="/test.jpg" height={100} width={100} ref={ref} />
</div>
)
}
17 changes: 17 additions & 0 deletions test/integration/next-image-new/default/test/index.test.ts
Expand Up @@ -1257,6 +1257,23 @@ function runTests(mode) {
}
}
})

it.only('should forward ref to native img', async () => {
let browser
try {
browser = await webdriver(appPort, '/ref-forwarding')
await waitFor(1000)
const dataId = 'arst'
await browser.eval(`window.ref.current.dataset.id = '${dataId}'`)
expect(await browser.elementById('img').getAttribute('data-id')).toBe(
dataId
)
} finally {
if (browser) {
await browser.close()
}
}
})
}

describe('Image Component Default Tests', () => {
Expand Down

0 comments on commit 4f8a9e8

Please sign in to comment.