/
index.test.ts
54 lines (46 loc) · 1.2 KB
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* eslint-env jest */
import { join } from 'path'
import cheerio from 'cheerio'
import {
findPort,
killApp,
launchApp,
nextStart,
nextBuild,
renderViaHTTP,
} from 'next-test-utils'
const appDir = join(__dirname, '../')
let appPort
let app
function runTests() {
it('should include noscript for placeholder=blur but not others', async () => {
const html = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(html)
expect($('noscript > img#basic-image').attr('src')).toBeUndefined()
expect($('noscript > img#image-with-loader').attr('src')).toBeUndefined()
expect($('noscript > img#image-with-blur').attr('src')).toMatch('blur.jpg')
})
}
describe('Future Image Component Noscript Tests', () => {
describe('dev mode', () => {
beforeAll(async () => {
appPort = await findPort()
app = await launchApp(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})
runTests()
})
describe('server mode', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(async () => {
await killApp(app)
})
runTests()
})
})