2018-10-31 15:52:35 +00:00
|
|
|
import { loadFixture, getPort, Nuxt, rp } from '../utils'
|
|
|
|
|
|
|
|
let nuxt, port
|
|
|
|
const url = route => 'http://localhost:' + port + route
|
|
|
|
|
2018-11-07 23:37:06 +00:00
|
|
|
describe('modern server mode', () => {
|
2018-10-31 15:52:35 +00:00
|
|
|
beforeAll(async () => {
|
2018-11-07 23:37:06 +00:00
|
|
|
const options = await loadFixture('modern', { modern: 'server' })
|
2018-10-31 15:52:35 +00:00
|
|
|
nuxt = new Nuxt(options)
|
|
|
|
port = await getPort()
|
|
|
|
await nuxt.server.listen(port, 'localhost')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should use legacy resources by default', async () => {
|
|
|
|
const response = await rp(url('/'))
|
|
|
|
expect(response).toContain('/_nuxt/app.js')
|
|
|
|
expect(response).toContain('/_nuxt/commons.app.js')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should use modern resources for modern resources', async () => {
|
|
|
|
const response = await rp(url('/'), {
|
|
|
|
headers: {
|
|
|
|
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
expect(response).toContain('/_nuxt/modern-app.js')
|
|
|
|
expect(response).toContain('/_nuxt/modern-commons.app.js')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should include es6 syntax in modern resources', async () => {
|
|
|
|
const response = await rp(url('/_nuxt/modern-app.js'))
|
|
|
|
expect(response).toContain('arrow:()=>"build test"')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('should not include es6 syntax in normal resources', async () => {
|
|
|
|
const response = await rp(url('/_nuxt/app.js'))
|
|
|
|
expect(response).not.toContain('arrow:()=>"build test"')
|
|
|
|
})
|
2018-11-07 23:37:06 +00:00
|
|
|
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
|
|
afterAll(async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
2018-10-31 15:52:35 +00:00
|
|
|
})
|