mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-23 22:25:12 +00:00
test: spa test
This commit is contained in:
parent
0583558d77
commit
90419e331b
@ -1,3 +1,5 @@
|
|||||||
|
import consola from 'consola'
|
||||||
|
import mockLog from '../utils/mock-log'
|
||||||
import { loadFixture, getPort, Nuxt } from '../utils'
|
import { loadFixture, getPort, Nuxt } from '../utils'
|
||||||
|
|
||||||
let nuxt = null
|
let nuxt = null
|
||||||
@ -12,7 +14,9 @@ const renderRoute = async _url => {
|
|||||||
return { window, head, html }
|
return { window, head, html }
|
||||||
}
|
}
|
||||||
|
|
||||||
describe.skip('spa', () => {
|
describe('spa', () => {
|
||||||
|
mockLog(['log'], consola)
|
||||||
|
|
||||||
beforeAll(async () => {
|
beforeAll(async () => {
|
||||||
const config = loadFixture('spa')
|
const config = loadFixture('spa')
|
||||||
nuxt = new Nuxt(config)
|
nuxt = new Nuxt(config)
|
||||||
@ -21,44 +25,22 @@ describe.skip('spa', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
test('/ (basic spa)', async () => {
|
test('/ (basic spa)', async () => {
|
||||||
// const logSpy = await interceptLog()
|
|
||||||
const { html } = await renderRoute('/')
|
const { html } = await renderRoute('/')
|
||||||
expect(html.includes('Hello SPA!')).toBe(true)
|
expect(html).toMatch('Hello SPA!')
|
||||||
// release()
|
expect(consola.log).not.toHaveBeenCalledWith('created')
|
||||||
// expect(logSpy.withArgs('created').notCalled).toBe(true)
|
expect(consola.log).toHaveBeenCalledWith('mounted')
|
||||||
// expect(logSpy.withArgs('mounted').calledOnce).toBe(true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/custom (custom layout)', async () => {
|
test('/custom (custom layout)', async () => {
|
||||||
// const logSpy = await interceptLog()
|
|
||||||
const { html } = await renderRoute('/custom')
|
const { html } = await renderRoute('/custom')
|
||||||
expect(html.includes('Custom layout')).toBe(true)
|
expect(html).toMatch('Custom layout')
|
||||||
// release()
|
expect(consola.log).toHaveBeenCalledWith('created')
|
||||||
// expect(logSpy.withArgs('created').calledOnce).toBe(true)
|
expect(consola.log).toHaveBeenCalledWith('mounted')
|
||||||
// expect(logSpy.withArgs('mounted').calledOnce).toBe(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('/custom (not default layout)', async () => {
|
|
||||||
// const logSpy = await interceptLog()
|
|
||||||
const { head } = await renderRoute('/custom')
|
|
||||||
expect(head.includes('src="/_nuxt/layouts/default.')).toBe(false)
|
|
||||||
// release()
|
|
||||||
// expect(logSpy.withArgs('created').calledOnce).toBe(true)
|
|
||||||
// expect(logSpy.withArgs('mounted').calledOnce).toBe(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('/custom (call mounted and created once)', async () => {
|
|
||||||
// const logSpy = await interceptLog()
|
|
||||||
await renderRoute('/custom')
|
|
||||||
// release()
|
|
||||||
// expect(logSpy.withArgs('created').calledOnce).toBe(true)
|
|
||||||
// expect(logSpy.withArgs('mounted').calledOnce).toBe(true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/mounted', async () => {
|
test('/mounted', async () => {
|
||||||
const { html } = await renderRoute('/mounted')
|
const { html } = await renderRoute('/mounted')
|
||||||
|
expect(html).toMatch('<h1>Test: updated</h1>')
|
||||||
expect(html.includes('<h1>Test: updated</h1>')).toBe(true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('/_nuxt/ (access publicPath in spa mode)', async () => {
|
test('/_nuxt/ (access publicPath in spa mode)', async () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user