mirror of
https://github.com/nuxt/nuxt.git
synced 2025-03-09 03:03:18 +00:00
test: redirect to external url
This commit is contained in:
parent
21f9145309
commit
3020af7c38
@ -143,6 +143,15 @@ test('/redirect2', async t => {
|
||||
t.is(await page.$text('h1'), 'Index page')
|
||||
})
|
||||
|
||||
test('/redirect3', async t => {
|
||||
// New page for redirecting to external link.
|
||||
const page = await browser.page(url('/'))
|
||||
await page.nuxt.navigate('/redirect3', false)
|
||||
await page.waitForFunction(() => window.location.href === 'https://nuxtjs.org/')
|
||||
page.close()
|
||||
t.pass()
|
||||
})
|
||||
|
||||
test('/no-ssr', async t => {
|
||||
await page.nuxt.navigate('/no-ssr')
|
||||
|
||||
|
@ -117,6 +117,19 @@ test('/redirect -> check redirected source', async t => {
|
||||
t.true(html.includes('<h1>Index page</h1>'))
|
||||
})
|
||||
|
||||
test('/redirect -> external link', async t => {
|
||||
const headers = {}
|
||||
const { html } = await nuxt.renderRoute('/redirect3', {
|
||||
res: {
|
||||
setHeader(k, v) {
|
||||
headers[k] = v
|
||||
}
|
||||
}
|
||||
})
|
||||
t.is(headers.Location, 'https://nuxtjs.org')
|
||||
t.true(html.includes('<div>redirecting.</div>'))
|
||||
})
|
||||
|
||||
test('/special-state -> check window.__NUXT__.test = true', async t => {
|
||||
const window = await nuxt.renderAndGetWindow(url('/special-state'))
|
||||
t.is(window.document.title, 'Nuxt.js')
|
||||
|
11
test/fixtures/basic/pages/redirect3.vue
vendored
Normal file
11
test/fixtures/basic/pages/redirect3.vue
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
<template>
|
||||
<div>Redirecting...</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
fetch({ redirect }) {
|
||||
return redirect('https://nuxtjs.org/')
|
||||
}
|
||||
}
|
||||
</script>
|
Loading…
Reference in New Issue
Block a user