forked from nuxt/nuxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchildren.test.js
More file actions
56 lines (45 loc) · 1.72 KB
/
children.test.js
File metadata and controls
56 lines (45 loc) · 1.72 KB
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
55
56
import { loadFixture, getPort, Nuxt } from '../utils'
let port
// const url = (route) => 'http://localhost:' + port + route
let nuxt = null
describe('children', () => {
beforeAll(async () => {
const options = await loadFixture('children')
nuxt = new Nuxt(options)
await nuxt.ready()
port = await getPort()
await nuxt.server.listen(port, 'localhost')
})
test('/parent', async () => {
const { html } = await nuxt.server.renderRoute('/parent')
expect(html).toContain('<h1>I am the parent</h1>')
})
test('/parent/child', async () => {
const { html } = await nuxt.server.renderRoute('/parent/child')
expect(html).toContain('<h1>I am the parent</h1>')
expect(html).toContain('<h2>I am the child</h2>')
})
test('/parent should call _id.vue', async () => {
const { html } = await nuxt.server.renderRoute('/parent')
expect(html).toContain('<h1>I am the parent</h1>')
expect(html).toContain('<h2>Id=</h2>')
})
test('/parent/1', async () => {
const { html } = await nuxt.server.renderRoute('/parent/1')
expect(html).toContain('<h1>I am the parent</h1>')
expect(html).toContain('<h2>Id=1</h2>')
})
test('/parent/validate-child should display 404', async () => {
const { html } = await nuxt.server.renderRoute('/parent/validate-child')
expect(html).toContain('This page could not be found')
})
test('/parent/validate-child?key=12345', async () => {
const { html } = await nuxt.server.renderRoute('/parent/validate-child?key=12345')
expect(html).toContain('<h1>I am the parent</h1>')
expect(html).toContain('<h2>Child valid</h2>')
})
// Close server and ask nuxt to stop listening to file changes
afterAll(async () => {
await nuxt.close()
})
})