Nuxt/packages/nuxt/test/__snapshots__/pages-override-meta-enabled.test.ts.snap
Daniel Roe 407fde6765
feat(nuxt): experimentally extract route metadata at build time (#25210)
Co-authored-by: Bobbie Goede <bobbiegoede@gmail.com>
2024-01-29 16:44:54 +00:00

303 lines
9.4 KiB
Plaintext

{
"route without file": [
{
"alias": "["sweet-home"]",
"meta": "{"hello":"world"}",
"name": ""home"",
"path": ""/"",
"redirect": undefined,
},
],
"should allow pages with `:` in their path": [
{
"component": "() => import("pages/test:name.vue").then(m => m.default || m)",
"name": ""test:name"",
"path": ""/test\\:name"",
},
],
"should correctly merge nested routes": [
{
"children": [
{
"children": [
{
"component": "() => import("pages/param/index/index.vue").then(m => m.default || m)",
"name": ""param-index"",
"path": """",
},
{
"component": "() => import("layer/pages/param/index/sibling.vue").then(m => m.default || m)",
"name": ""param-index-sibling"",
"path": ""sibling"",
},
],
"component": "() => import("layer/pages/param/index.vue").then(m => m.default || m)",
"name": "mockMeta?.name",
"path": """",
},
{
"component": "() => import("pages/param/sibling.vue").then(m => m.default || m)",
"name": ""param-sibling"",
"path": ""sibling"",
},
],
"component": "() => import("pages/param.vue").then(m => m.default || m)",
"name": "mockMeta?.name",
"path": ""/param"",
},
{
"children": [
{
"component": "() => import("layer/pages/wrapper-expose/other/index.vue").then(m => m.default || m)",
"name": ""wrapper-expose-other"",
"path": """",
},
{
"component": "() => import("pages/wrapper-expose/other/sibling.vue").then(m => m.default || m)",
"name": ""wrapper-expose-other-sibling"",
"path": ""sibling"",
},
],
"component": "() => import("pages/wrapper-expose/other.vue").then(m => m.default || m)",
"name": "mockMeta?.name",
"path": ""/wrapper-expose/other"",
},
],
"should extract serializable values and override fallback when normalized with `overrideMeta: true`": [
{
"alias": "["sweet-home"]",
"component": "() => import("pages/index.vue").then(m => m.default || m)",
"meta": "mockMeta || {}",
"name": ""home"",
"path": ""/"",
"redirect": ""/"",
},
],
"should generate correct catch-all route": [
{
"component": "() => import("pages/[...slug].vue").then(m => m.default || m)",
"name": ""slug"",
"path": ""/:slug(.*)*"",
},
{
"component": "() => import("pages/index.vue").then(m => m.default || m)",
"name": ""index"",
"path": ""/"",
},
],
"should generate correct dynamic routes": [
{
"component": "() => import("pages/index.vue").then(m => m.default || m)",
"name": ""index"",
"path": ""/"",
},
{
"component": "() => import("pages/[slug].vue").then(m => m.default || m)",
"name": ""slug"",
"path": ""/:slug()"",
},
{
"children": [
{
"component": "() => import("pages/[[foo]]/index.vue").then(m => m.default || m)",
"name": ""foo"",
"path": """",
},
],
"component": "() => import("pages/[[foo]]").then(m => m.default || m)",
"name": "mockMeta?.name",
"path": ""/:foo?"",
},
{
"component": "() => import("pages/optional/[[opt]].vue").then(m => m.default || m)",
"name": ""optional-opt"",
"path": ""/optional/:opt?"",
},
{
"component": "() => import("pages/optional/prefix-[[opt]].vue").then(m => m.default || m)",
"name": ""optional-prefix-opt"",
"path": ""/optional/prefix-:opt?"",
},
{
"component": "() => import("pages/optional/[[opt]]-postfix.vue").then(m => m.default || m)",
"name": ""optional-opt-postfix"",
"path": ""/optional/:opt?-postfix"",
},
{
"component": "() => import("pages/optional/prefix-[[opt]]-postfix.vue").then(m => m.default || m)",
"name": ""optional-prefix-opt-postfix"",
"path": ""/optional/prefix-:opt?-postfix"",
},
{
"component": "() => import("pages/[bar]/index.vue").then(m => m.default || m)",
"name": ""bar"",
"path": ""/:bar()"",
},
{
"component": "() => import("pages/nonopt/[slug].vue").then(m => m.default || m)",
"name": ""nonopt-slug"",
"path": ""/nonopt/:slug()"",
},
{
"component": "() => import("pages/opt/[[slug]].vue").then(m => m.default || m)",
"name": ""opt-slug"",
"path": ""/opt/:slug?"",
},
{
"component": "() => import("pages/[[sub]]/route-[slug].vue").then(m => m.default || m)",
"name": ""sub-route-slug"",
"path": ""/:sub?/route-:slug()"",
},
],
"should generate correct id for catchall (order 1)": [
{
"component": "() => import("pages/[...stories].vue").then(m => m.default || m)",
"name": ""stories"",
"path": ""/:stories(.*)*"",
},
{
"component": "() => import("pages/stories/[id].vue").then(m => m.default || m)",
"name": ""stories-id"",
"path": ""/stories/:id()"",
},
],
"should generate correct id for catchall (order 2)": [
{
"component": "() => import("pages/stories/[id].vue").then(m => m.default || m)",
"name": ""stories-id"",
"path": ""/stories/:id()"",
},
{
"component": "() => import("pages/[...stories].vue").then(m => m.default || m)",
"name": ""stories"",
"path": ""/:stories(.*)*"",
},
],
"should generate correct route for kebab-case file": [
{
"component": "() => import("pages/kebab-case.vue").then(m => m.default || m)",
"name": ""kebab-case"",
"path": ""/kebab-case"",
},
],
"should generate correct route for snake_case file": [
{
"component": "() => import("pages/snake_case.vue").then(m => m.default || m)",
"name": ""snake_case"",
"path": ""/snake_case"",
},
],
"should generate correct routes for index pages": [
{
"component": "() => import("pages/index.vue").then(m => m.default || m)",
"name": ""index"",
"path": ""/"",
},
{
"component": "() => import("pages/parent/index.vue").then(m => m.default || m)",
"name": ""parent"",
"path": ""/parent"",
},
{
"component": "() => import("pages/parent/child/index.vue").then(m => m.default || m)",
"name": ""parent-child"",
"path": ""/parent/child"",
},
],
"should generate correct routes for parent/child": [
{
"children": [
{
"component": "() => import("pages/parent/child.vue").then(m => m.default || m)",
"name": ""parent-child"",
"path": ""child"",
},
],
"component": "() => import("pages/parent.vue").then(m => m.default || m)",
"name": ""parent"",
"path": ""/parent"",
},
],
"should handle trailing slashes with index routes": [
{
"children": [
{
"component": "() => import("pages/index/index/all.vue").then(m => m.default || m)",
"name": ""index-index-all"",
"path": ""all"",
},
],
"component": "() => import("pages/index/index.vue").then(m => m.default || m)",
"name": ""index"",
"path": ""/"",
},
],
"should not generate colliding route names when hyphens are in file name": [
{
"component": "() => import("pages/parent/[child].vue").then(m => m.default || m)",
"name": ""parent-child"",
"path": ""/parent/:child()"",
},
{
"component": "() => import("pages/parent-[child].vue").then(m => m.default || m)",
"name": ""parent-child"",
"path": ""/parent-:child()"",
},
],
"should not merge required param as a child of optional param": [
{
"component": "() => import("pages/[[foo]].vue").then(m => m.default || m)",
"name": ""foo"",
"path": ""/:foo?"",
},
{
"component": "() => import("pages/[foo].vue").then(m => m.default || m)",
"name": ""foo"",
"path": ""/:foo()"",
},
],
"should only allow "_" & "." as special character for dynamic route": [
{
"component": "() => import("pages/[a1_1a].vue").then(m => m.default || m)",
"name": ""a1_1a"",
"path": ""/:a1_1a()"",
},
{
"component": "() => import("pages/[b2.2b].vue").then(m => m.default || m)",
"name": ""b2.2b"",
"path": ""/:b2.2b()"",
},
{
"component": "() => import("pages/[b2]_[2b].vue").then(m => m.default || m)",
"name": ""b2_2b"",
"path": ""/:b2()_:2b()"",
},
{
"component": "() => import("pages/[[c3@3c]].vue").then(m => m.default || m)",
"name": ""c33c"",
"path": ""/:c33c?"",
},
{
"component": "() => import("pages/[[d4-4d]].vue").then(m => m.default || m)",
"name": ""d44d"",
"path": ""/:d44d?"",
},
],
"should properly override route name if definePageMeta name override is defined.": [
{
"component": "() => import("pages/index.vue").then(m => m.default || m)",
"name": ""home"",
"path": ""/"",
},
],
"should use fallbacks when normalized with `overrideMeta: true`": [
{
"alias": "mockMeta?.alias || []",
"component": "() => import("pages/index.vue").then(m => m.default || m)",
"meta": "mockMeta || {}",
"name": "mockMeta?.name",
"path": ""/"",
"redirect": "mockMeta?.redirect",
},
],
}