-
Notifications
You must be signed in to change notification settings - Fork 26.1k
/
index.test.ts
42 lines (37 loc) · 1.07 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
/* eslint-env jest */
import { join } from 'path'
import cheerio from 'cheerio'
import {
killApp,
findPort,
nextStart,
nextBuild,
renderViaHTTP,
} from 'next-test-utils'
const appDir = join(__dirname, '../')
let appPort
let app
describe('Noscript Tests', () => {
beforeAll(async () => {
await nextBuild(appDir)
appPort = await findPort()
app = await nextStart(appDir, appPort)
})
afterAll(() => killApp(app))
describe('Noscript page source tests', () => {
it('should use local API for noscript img#basic-image src attribute', async () => {
const html = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(html)
expect($('noscript > img#basic-image').attr('src')).toMatch(
/^\/_next\/image/
)
})
it('should use loader url for noscript img#image-with-loader src attribute', async () => {
const html = await renderViaHTTP(appPort, '/')
const $ = cheerio.load(html)
expect($('noscript > img#image-with-loader').attr('src')).toMatch(
/^https:\/\/customresolver.com/
)
})
})
})