Skip to content

Commit

Permalink
fix: getRoutes async patch (umijs#54)
Browse files Browse the repository at this point in the history
* chore: add routes config test cases

* fix: await patchRoutes

* fix: routes test case

* chore: rename test case name
  • Loading branch information
ycjcl868 committed Feb 13, 2020
1 parent 36cb4fa commit 0b23612
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 1 deletion.
58 changes: 58 additions & 0 deletions packages/core/src/Route/Route.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,64 @@ test('config empty', async () => {
).toEqual([]);
});

test('config routes', async () => {
const route = new Route();
expect(
await route.getRoutes({
config: {
routes: [
{
path: '/',
component: '../layouts/SecurityLayout',
routes: [
{
path: '/',
component: '../layouts/BasicLayout',
routes: [
{
path: '/',
redirect: '/welcome',
},
{ component: './404' },
],
},
{ component: './404' },
],
},
{ component: './404' },
],
},
root: '/tmp',
}),
).toEqual([
{
path: '/',
component: '/layouts/SecurityLayout',
routes: [
{
path: '/',
component: '/layouts/BasicLayout',
routes: [
{
path: '/',
redirect: '/welcome',
},
{
component: '/tmp/404',
},
],
},
{
component: '/tmp/404',
},
],
},
{
component: '/tmp/404',
},
]);
});

test('conventional normal', async () => {
const route = new Route();
expect(
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/Route/Route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Route {
}

if (route.routes) {
this.patchRoutes(route.routes, opts);
await this.patchRoutes(route.routes, opts);
}

// resolve component path
Expand Down

0 comments on commit 0b23612

Please sign in to comment.