forked from nuxt-modules/i18n
/
baseUrl_runtimeConfig.spec.ts
35 lines (32 loc) · 960 Bytes
/
baseUrl_runtimeConfig.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { expect, test } from 'vitest'
import { fileURLToPath } from 'node:url'
import { setup, $fetch } from '@nuxt/test-utils'
import { getDom, getDataFromDom, assertLocaleHeadWithDom } from '../helper'
const configDomain = 'https://runtime-config-domain.com'
await setup({
rootDir: fileURLToPath(new URL(`../fixtures/basic`, import.meta.url)),
browser: true,
// overrides
nuxtConfig: {
runtimeConfig: {
public: {
i18n: {
baseUrl: configDomain
}
}
},
i18n: {
// debug: true,
defaultLocale: 'en',
baseUrl: ''
}
}
})
test('render seo tags with baseUrl', async () => {
const html = await $fetch('/?noncanonical')
const dom = getDom(html)
await assertLocaleHeadWithDom(dom, '#home-use-locale-head')
const links = getDataFromDom(dom, '#home-use-locale-head').link
const i18nCan = links.find(x => x.id === 'i18n-can')
expect(i18nCan.href).toContain(configDomain)
})