@@ -86,6 +86,61 @@ describe('loadRouteLocation', () => {
86
86
] )
87
87
} )
88
88
89
+ describe ( 'mods' , ( ) => {
90
+ const mod = {
91
+ default : components . Home ,
92
+ __esModule : true ,
93
+ custom : true ,
94
+ }
95
+ const mod2 = {
96
+ default : FunctionalHome ,
97
+ __esModule : true ,
98
+ custom : true ,
99
+ }
100
+
101
+ it ( 'preserves resolved modules' , async ( ) => {
102
+ const router = createRouter ( {
103
+ history : createMemoryHistory ( ) ,
104
+ routes : [
105
+ {
106
+ path : '/' ,
107
+ component : async ( ) => mod ,
108
+ } ,
109
+ ] ,
110
+ } )
111
+
112
+ const loaded = await loadRouteLocation ( router . resolve ( '/' ) )
113
+ // mods follow the same structure as components
114
+ expect ( loaded . matched [ 0 ] ?. mods ) . toEqual ( {
115
+ default : expect . anything ( ) ,
116
+ } )
117
+ expect ( loaded . matched [ 0 ] ?. mods ?. default ) . toBe ( mod )
118
+ } )
119
+
120
+ it ( 'preserves resolved modules for named components' , async ( ) => {
121
+ const router = createRouter ( {
122
+ history : createMemoryHistory ( ) ,
123
+ routes : [
124
+ {
125
+ path : '/' ,
126
+ components : {
127
+ default : async ( ) => mod2 ,
128
+ name : async ( ) => mod ,
129
+ } ,
130
+ } ,
131
+ ] ,
132
+ } )
133
+
134
+ const loaded = await loadRouteLocation ( router . resolve ( '/' ) )
135
+ expect ( loaded . matched [ 0 ] ?. mods ) . toEqual ( {
136
+ default : expect . anything ( ) ,
137
+ name : expect . anything ( ) ,
138
+ } )
139
+ expect ( loaded . matched [ 0 ] ?. mods ?. name ) . toBe ( mod )
140
+ expect ( loaded . matched [ 0 ] ?. mods ?. default ) . toBe ( mod2 )
141
+ } )
142
+ } )
143
+
89
144
it ( 'throws with non loadable routes' , async ( ) => {
90
145
expect . assertions ( 1 )
91
146
await expect (
0 commit comments