@@ -47,6 +47,18 @@ describe('router', () => {
4747 children : [ ChildRoute , OtherChildRoute ] ,
4848 } ;
4949
50+ const MetaRoute : Route = {
51+ name : 'meta' ,
52+ path : '/meta' ,
53+ meta : {
54+ seed : 'Route meta' ,
55+ nested : {
56+ key : 'Nested key' ,
57+ value : 'Nested value' ,
58+ } ,
59+ } ,
60+ } ;
61+
5062 const ParamRoute : Route = {
5163 name : 'param' ,
5264 path : '/param/:id/user/:firstName:?/:lastName' ,
@@ -138,6 +150,7 @@ describe('router', () => {
138150 PathRoute ,
139151 OtherRoute ,
140152 ParentRoute ,
153+ MetaRoute ,
141154 ParamRoute ,
142155 QueryRoute ,
143156 ParamQueryRoute ,
@@ -668,6 +681,58 @@ describe('router', () => {
668681 expect ( route . route . path ) . toBe ( '/parent/child' ) ;
669682 } ) ;
670683
684+ it ( 'should resolve a route from a location with title template' , async ( ) => {
685+ expect . assertions ( 5 ) ;
686+
687+ const path = TitleRoute . path ;
688+ const route = await router . resolve ( { path } ) ;
689+
690+ expect ( route ) . toBeDefined ( ) ;
691+ expect ( route . name ) . toBe ( TitleRoute . name ) ;
692+ expect ( route . path ) . toBe ( path ) ;
693+ expect ( route . route ?. path ) . toBe ( TitleRoute . path ) ;
694+ expect ( route . title ) . toStrictEqual ( TitleRoute . title ) ;
695+ } ) ;
696+
697+ it ( 'should resolve a route from a location with title override' , async ( ) => {
698+ expect . assertions ( 5 ) ;
699+
700+ const path = TitleRoute . path ;
701+ const route = await router . resolve ( { path, title : 'custom title template' } ) ;
702+
703+ expect ( route ) . toBeDefined ( ) ;
704+ expect ( route . name ) . toBe ( TitleRoute . name ) ;
705+ expect ( route . path ) . toBe ( path ) ;
706+ expect ( route . route ?. path ) . toBe ( TitleRoute . path ) ;
707+ expect ( route . title ) . toStrictEqual ( 'custom title template' ) ;
708+ } ) ;
709+
710+ it ( 'should resolve a route from a location with meta object' , async ( ) => {
711+ expect . assertions ( 5 ) ;
712+
713+ const path = MetaRoute . path ;
714+ const route = await router . resolve ( { path } ) ;
715+
716+ expect ( route ) . toBeDefined ( ) ;
717+ expect ( route . name ) . toBe ( MetaRoute . name ) ;
718+ expect ( route . path ) . toBe ( path ) ;
719+ expect ( route . route ?. path ) . toBe ( MetaRoute . path ) ;
720+ expect ( route . meta ) . toStrictEqual ( MetaRoute . meta ) ;
721+ } ) ;
722+
723+ it ( 'should resolve a route from a location and merge meta object' , async ( ) => {
724+ expect . assertions ( 5 ) ;
725+
726+ const path = MetaRoute . path ;
727+ const route = await router . resolve ( { path, meta : { push : 'push value' , nested : { key : 'new key' , value : 'new key' } } } ) ;
728+
729+ expect ( route ) . toBeDefined ( ) ;
730+ expect ( route . name ) . toBe ( MetaRoute . name ) ;
731+ expect ( route . path ) . toBe ( path ) ;
732+ expect ( route . route ?. path ) . toBe ( MetaRoute . path ) ;
733+ expect ( route . meta ) . toStrictEqual ( { ...MetaRoute . meta , push : 'push value' , nested : { key : 'new key' , value : 'new key' } } ) ;
734+ } ) ;
735+
671736 it ( 'should resolve a route from a location with param parameters' , async ( ) => {
672737 expect . assertions ( 5 ) ;
673738
@@ -705,7 +770,7 @@ describe('router', () => {
705770 expect ( route . query ) . toStrictEqual ( { page : '2' , limit : '5' } ) ;
706771 } ) ;
707772
708- it ( 'should resolve a route from a location with default query parameters' , async ( ) => {
773+ it ( 'should resolve a route from a name with default query parameters' , async ( ) => {
709774 expect . assertions ( 5 ) ;
710775
711776 const route = await router . resolve ( { name : QueryRoute . name } ) ;
0 commit comments