Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Timer committed Oct 27, 2020
1 parent 4546f6d commit 196e347
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/integration/image-component/default/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ const nextConfig = join(appDir, 'next.config.js')
let appPort
let app

async function hasImageMatchingUrl(browser, url) {
const links = await browser.elementsByCss('img')
let foundMatch = false
for (const link of links) {
const src = await link.getAttribute('src')
if (src === url) {
foundMatch = true
break
}
}
return foundMatch
}

function runTests(mode) {
it('should load the images', async () => {
let browser
Expand Down Expand Up @@ -54,6 +67,16 @@ function runTests(mode) {

return 'result-correct'
}, /result-correct/)

expect(
await hasImageMatchingUrl(
browser,
mode === 'serverless'
? // FIXME: this is a bug
`http://localhost:${appPort}/_next/image/?url=%2Ftest.jpg&w=420&q=75`
: `http://localhost:${appPort}/_next/image?url=%2Ftest.jpg&w=420&q=75`
)
).toBe(true)
} finally {
if (browser) {
await browser.close()
Expand Down

0 comments on commit 196e347

Please sign in to comment.