/
typescript.test.ts
37 lines (32 loc) · 1.11 KB
/
typescript.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
import { createNext, FileRef } from 'e2e-utils'
import { NextInstance } from 'e2e-utils'
import { renderViaHTTP } from 'next-test-utils'
import cheerio from 'cheerio'
import path from 'path'
import webdriver from 'next-webdriver'
const appDir = path.join(__dirname, 'typescript')
describe('New Link Behavior', () => {
let next: NextInstance
beforeAll(async () => {
next = await createNext({
files: {
pages: new FileRef(path.join(appDir, 'pages')),
'tsconfig.json': new FileRef(path.join(appDir, 'tsconfig.json')),
'next.config.js': new FileRef(path.join(appDir, 'next.config.js')),
},
})
})
afterAll(() => next.destroy())
it('should render link with <a>', async () => {
const html = await renderViaHTTP(next.url, '/')
const $ = cheerio.load(html)
const $a = $('a')
expect($a.text()).toBe('Visit')
expect($a.attr('href')).toBe('/test')
})
it('should apply ref on link', async () => {
const browser = await webdriver(next.url, `/ref`)
const text = await browser.elementByCss('#anchor-text').text()
expect(text).toBe('AnchorText: About')
})
})