Skip to content

Commit

Permalink
test: merge issue nuxt-modules#2758 test (nuxt-modules#2868)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored Mar 21, 2024
1 parent eadfef9 commit 51cd3b0
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 66 deletions.
File renamed without changes.
7 changes: 0 additions & 7 deletions specs/fixtures/issues/2758/app.vue

This file was deleted.

23 changes: 0 additions & 23 deletions specs/fixtures/issues/2758/nuxt.config.ts

This file was deleted.

14 changes: 0 additions & 14 deletions specs/fixtures/issues/2758/package.json

This file was deleted.

3 changes: 0 additions & 3 deletions specs/fixtures/issues/2758/pages/index.vue

This file was deleted.

15 changes: 0 additions & 15 deletions specs/issues/2758.spec.ts

This file was deleted.

38 changes: 34 additions & 4 deletions specs/routing_strategies/root_redirect.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect } from 'vitest'
import { fileURLToPath } from 'node:url'
import { setup, url, fetch } from '../utils'
import { startServerWithRuntimeConfig } from '../helper'

await setup({
rootDir: fileURLToPath(new URL(`../fixtures/basic`, import.meta.url)),
Expand All @@ -10,12 +11,41 @@ await setup({
i18n: {
strategy: 'prefix',
defaultLocale: 'en',
rootRedirect: 'fr'
// configure `rootDirect` to object so it can be overwritten by `runtimeConfig`
rootRedirect: { path: 'about', statusCode: 302 }
}
}
})

test('can redirect to rootRedirect option path', async () => {
const res = await fetch('/')
expect(res.url).toBe(url('/fr'))
describe('rootRedirect', async () => {
test('can redirect to rootRedirect option path', async () => {
const restore = await startServerWithRuntimeConfig({
public: {
i18n: {
rootRedirect: 'fr'
}
}
})

const res = await fetch('/')
expect(res.url).toBe(url('/fr'))

await restore()
})

test('(#2758) `statusCode` in `rootRedirect` should work with strategy "prefix"', async () => {
const restore = await startServerWithRuntimeConfig({
public: {
i18n: {
rootRedirect: { statusCode: 418, path: 'test-route' }
}
}
})

const res = await fetch(url('/'))
expect(res.status).toEqual(418)
expect(res.headers.get('location')).toEqual('/en/test-route')

await restore()
})
})

0 comments on commit 51cd3b0

Please sign in to comment.