2018-11-26 12:09:30 +00:00
|
|
|
import { loadFixture, getPort, Nuxt, rp, wChunk } from '../utils'
|
2018-11-07 23:37:06 +00:00
|
|
|
|
|
|
|
let nuxt, port
|
|
|
|
const url = route => 'http://localhost:' + port + route
|
|
|
|
|
2018-11-26 22:49:47 +00:00
|
|
|
describe('modern client mode (SSR)', () => {
|
2018-11-07 23:37:06 +00:00
|
|
|
beforeAll(async () => {
|
|
|
|
const options = await loadFixture('modern', { modern: 'client' })
|
|
|
|
nuxt = new Nuxt(options)
|
|
|
|
port = await getPort()
|
|
|
|
await nuxt.server.listen(port, 'localhost')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should contain nomodule legacy resources', async () => {
|
|
|
|
const response = await rp(url('/'))
|
|
|
|
expect(response).toContain('script nomodule src="/_nuxt/app.js')
|
|
|
|
expect(response).toContain('script nomodule src="/_nuxt/commons.app.js')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should contain module modern resources', async () => {
|
|
|
|
const response = await rp(url('/'))
|
|
|
|
expect(response).toContain('<script type="module" src="/_nuxt/modern-app.js"')
|
|
|
|
expect(response).toContain('<script type="module" src="/_nuxt/modern-commons.app.js"')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should contain module preload resources', async () => {
|
|
|
|
const response = await rp(url('/'))
|
|
|
|
expect(response).toContain('<link rel="modulepreload" href="/_nuxt/modern-app.js" as="script">')
|
|
|
|
expect(response).toContain('<link rel="modulepreload" href="/_nuxt/modern-commons.app.js" as="script">')
|
|
|
|
})
|
|
|
|
|
2018-11-26 12:09:30 +00:00
|
|
|
test('should contain module http2 pushed resources', async () => {
|
|
|
|
const { headers: { link } } = await rp(url('/'), { resolveWithFullResponse: true })
|
|
|
|
expect(link).toEqual([
|
|
|
|
'</_nuxt/modern-runtime.js>; rel=preload; as=script',
|
|
|
|
'</_nuxt/modern-commons.app.js>; rel=preload; as=script',
|
|
|
|
'</_nuxt/modern-app.js>; rel=preload; as=script',
|
|
|
|
`</_nuxt/modern-${wChunk('pages/index.js')}>; rel=preload; as=script`
|
|
|
|
].join(', '))
|
|
|
|
})
|
|
|
|
|
2018-11-07 23:37:06 +00:00
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
|
|
afterAll(async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
|
|
|
})
|