@@ -818,6 +818,100 @@ describe('generateRouteResolver', () => {
818
818
` )
819
819
} )
820
820
821
+ it ( 'generates correct nested layouts' , ( ) => {
822
+ const tree = new PrefixTree ( DEFAULT_OPTIONS )
823
+ const importsMap = new ImportsMap ( )
824
+ tree . insert ( 'a' , 'a.vue' )
825
+ tree . insert ( 'a/(a-home)' , 'a/(a-home).vue' )
826
+ tree . insert ( 'a/b' , 'a/b.vue' )
827
+ tree . insert ( 'a/b/c' , 'a/b/c.vue' )
828
+ tree . insert ( 'a/b/(b-home)' , 'a/b/(b-home).vue' )
829
+ tree . insert ( 'a/d' , 'a/d.vue' )
830
+ tree . insert ( 'a/b/e' , 'a/b/e.vue' )
831
+
832
+ const resolver = generateRouteResolver (
833
+ tree ,
834
+ DEFAULT_OPTIONS ,
835
+ importsMap ,
836
+ new Map ( )
837
+ )
838
+
839
+ // FIXME: there are conflicting paths here. The order is correct as nested routes appear higher but
840
+ // it should appeand a trailing slash to the children route or the parent
841
+ // Adding it to the parent makes the routing stable but also inconsistent trailing slash
842
+ // I think it's better to not have a stable routing to preserve stable trailing slash
843
+
844
+ expect ( resolver ) . toMatchInlineSnapshot ( `
845
+ "
846
+ const r_0 = normalizeRouteRecord({
847
+ name: '/a',
848
+ path: new MatcherPatternPathStatic('/a'),
849
+ components: {
850
+ 'default': () => import('a.vue')
851
+ },
852
+ })
853
+ const r_1 = normalizeRouteRecord({
854
+ name: '/a/(a-home)',
855
+ path: new MatcherPatternPathStatic('/a'),
856
+ components: {
857
+ 'default': () => import('a/(a-home).vue')
858
+ },
859
+ parent: r_0,
860
+ })
861
+ const r_2 = normalizeRouteRecord({
862
+ name: '/a/b',
863
+ path: new MatcherPatternPathStatic('/a/b'),
864
+ components: {
865
+ 'default': () => import('a/b.vue')
866
+ },
867
+ parent: r_0,
868
+ })
869
+ const r_3 = normalizeRouteRecord({
870
+ name: '/a/b/(b-home)',
871
+ path: new MatcherPatternPathStatic('/a/b'),
872
+ components: {
873
+ 'default': () => import('a/b/(b-home).vue')
874
+ },
875
+ parent: r_2,
876
+ })
877
+ const r_4 = normalizeRouteRecord({
878
+ name: '/a/b/c',
879
+ path: new MatcherPatternPathStatic('/a/b/c'),
880
+ components: {
881
+ 'default': () => import('a/b/c.vue')
882
+ },
883
+ parent: r_2,
884
+ })
885
+ const r_5 = normalizeRouteRecord({
886
+ name: '/a/b/e',
887
+ path: new MatcherPatternPathStatic('/a/b/e'),
888
+ components: {
889
+ 'default': () => import('a/b/e.vue')
890
+ },
891
+ parent: r_2,
892
+ })
893
+ const r_6 = normalizeRouteRecord({
894
+ name: '/a/d',
895
+ path: new MatcherPatternPathStatic('/a/d'),
896
+ components: {
897
+ 'default': () => import('a/d.vue')
898
+ },
899
+ parent: r_0,
900
+ })
901
+
902
+ export const resolver = createFixedResolver([
903
+ r_3, // /a/b
904
+ r_4, // /a/b/c
905
+ r_5, // /a/b/e
906
+ r_1, // /a
907
+ r_2, // /a/b
908
+ r_6, // /a/d
909
+ r_0, // /a
910
+ ])
911
+ "
912
+ ` )
913
+ } )
914
+
821
915
describe ( 'route prioritization in resolver' , ( ) => {
822
916
function getRouteOrderFromResolver ( tree : PrefixTree ) : string [ ] {
823
917
const resolver = generateRouteResolver (
0 commit comments