1import { configFromFs } from '../mockState'; 2 3describe(configFromFs, () => { 4 it(`matches`, () => { 5 expect( 6 configFromFs([ 7 '(foo)/_layout.tsx', 8 '(foo)/bar/_layout.tsx', 9 '(foo)/bar/[id].tsx', 10 '(foo)/bar/[...rest].tsx', 11 ]) 12 ).toEqual({ 13 initialRouteName: undefined, 14 screens: { 15 '(foo)': { 16 initialRouteName: undefined, 17 path: '(foo)', 18 screens: { 19 bar: { 20 initialRouteName: undefined, 21 path: 'bar', 22 screens: { '[...rest]': '*rest', '[id]': ':id' }, 23 }, 24 }, 25 }, 26 }, 27 }); 28 }); 29 30 it(`adds initial route names`, () => { 31 // Ensure we don't need to explicitly add the initial route name 32 expect( 33 configFromFs([ 34 '[...404].js', 35 '(app)/_layout.tsx', 36 '(app)/(explore)/_layout.tsx', 37 '(app)/(explore)/[user]/index.tsx', 38 '(app)/(explore)/explore.tsx', 39 ]) 40 ).toEqual({ 41 initialRouteName: undefined, 42 screens: { 43 // Should match 404... maybe 44 '[...404]': '*404', 45 '(app)': { 46 path: '(app)', 47 initialRouteName: undefined, 48 screens: { 49 '(explore)': { 50 path: '(explore)', 51 screens: { 52 '[user]/index': ':user', 53 explore: 'explore', 54 }, 55 initialRouteName: 'explore', 56 }, 57 }, 58 }, 59 }, 60 }); 61 }); 62 63 it(`matches parallel`, () => { 64 expect( 65 configFromFs([ 66 '[...404].js', 67 '(app)/_layout.tsx', 68 [ 69 '(app)/(explore)/_layout.tsx', 70 { 71 unstable_settings: { 72 initialRouteName: 'explore', 73 }, 74 }, 75 ], 76 '(app)/(explore)/[user]/index.tsx', 77 '(app)/(explore)/explore.tsx', 78 [ 79 '(app)/([user])/_layout.tsx', 80 { 81 unstable_settings: { 82 initialRouteName: '[user]/index', 83 }, 84 }, 85 ], 86 '(app)/([user])/[user]/index.tsx', 87 '(app)/([user])/explore.tsx', 88 ]) 89 ).toEqual({ 90 initialRouteName: undefined, 91 screens: { 92 // Should match 404... maybe 93 '[...404]': '*404', 94 '(app)': { 95 path: '(app)', 96 initialRouteName: undefined, 97 screens: { 98 '(explore)': { 99 path: '(explore)', 100 screens: { 101 '[user]/index': ':user', 102 explore: 'explore', 103 }, 104 initialRouteName: 'explore', 105 }, 106 '([user])': { 107 path: '([user])', 108 screens: { 109 '[user]/index': ':user', 110 explore: 'explore', 111 }, 112 initialRouteName: '[user]/index', 113 }, 114 }, 115 }, 116 }, 117 }); 118 }); 119}); 120