Skip to content

Commit

Permalink
fix(getPages): fix applying on root wrongly
Browse files Browse the repository at this point in the history
  • Loading branch information
Dimitri Kopriwa committed Feb 28, 2019
1 parent cd9de35 commit ded8cf8
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/getPages.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,6 @@ function getMergeSet(object, path, value) {
const val = get(object, path) || {};
set(object, path, merge(val, value));
} else {
Object.assign(object, merge(object[path] || {}, { [path]: value }));
Object.assign(object, merge(object, { [path]: value }));
}
}
45 changes: 45 additions & 0 deletions src/tests/getPages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,4 +276,49 @@ describe('getPages', () => {
},
});
});

it('should remove duplicate', () => {
const routesConfig = [
{
path: '/auth',
role: 1,
},
{
path: '/users',
},
{
path: '/user-management',
},
{
path: '/users',
exact: true,
routes: [
{
page: 'users.userEdit',
path: '/users/:id',
},
],
},
];
const p = getPages(routesConfig);
expect(p).toEqual({
auth: {
path: '/auth',
role: 1,
},
userManagement: {
path: '/user-management',
},
users: {
exact: true,
path: '/users',
$id: {
path: '/users/:id',
},
userEdit: {
path: '/users/:id',
},
},
});
});
});

0 comments on commit ded8cf8

Please sign in to comment.