2018-11-14 19:32:07 +00:00
|
|
|
import { getPort, loadFixture, Nuxt, rp } from '../utils'
|
|
|
|
|
|
|
|
let port
|
2023-10-16 21:23:38 +00:00
|
|
|
const url = route => 'http://127.0.0.1:' + port + route
|
2018-11-14 19:32:07 +00:00
|
|
|
|
|
|
|
let nuxt = null
|
|
|
|
|
|
|
|
describe('fallback', () => {
|
|
|
|
beforeAll(async () => {
|
|
|
|
const config = await loadFixture('with-config')
|
2019-03-08 20:43:23 +00:00
|
|
|
|
2018-11-14 19:32:07 +00:00
|
|
|
nuxt = new Nuxt(config)
|
2019-03-08 20:43:23 +00:00
|
|
|
await nuxt.ready()
|
|
|
|
|
2018-11-14 19:32:07 +00:00
|
|
|
port = await getPort()
|
2023-10-16 21:23:38 +00:00
|
|
|
await nuxt.server.listen(port, '127.0.0.1')
|
2018-11-14 19:32:07 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
test('robots.txt handled', async () => {
|
|
|
|
await expect(rp(url('/test/robots.txt')))
|
|
|
|
.rejects.toMatchObject({
|
2019-12-03 17:36:39 +00:00
|
|
|
response: { body: '', statusCode: 404 }
|
2018-11-14 19:32:07 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test('normal html routes should be rendered using SSR', async () => {
|
|
|
|
await expect(rp(url('/test/index.html')))
|
|
|
|
.rejects.toMatchObject({
|
2019-12-03 17:36:39 +00:00
|
|
|
response: { body: expect.stringContaining('data-n-head-ssr'), statusCode: 404 }
|
2018-11-14 19:32:07 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
test('uknown assets handled in dist', async () => {
|
|
|
|
await expect(rp(url('/test/orion/foo.xyz')))
|
|
|
|
.rejects.toMatchObject({
|
2019-12-03 17:36:39 +00:00
|
|
|
response: { body: '', statusCode: 404 }
|
2018-11-14 19:32:07 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
// Close server and ask nuxt to stop listening to file changes
|
|
|
|
afterAll(async () => {
|
|
|
|
await nuxt.close()
|
|
|
|
})
|
|
|
|
})
|