Skip to content

Commit

Permalink
test: add more test
Browse files Browse the repository at this point in the history
  • Loading branch information
chenshuai2144 committed Nov 23, 2022
1 parent b14daf7 commit 3c1f846
Show file tree
Hide file tree
Showing 2 changed files with 130 additions and 0 deletions.
110 changes: 110 additions & 0 deletions test/__snapshots__/transformRoute.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1898,6 +1898,116 @@ Map {
}
`;

exports[`layout support **/* 1`] = `
Array [
Object {
"key": "base/",
"locale": "menu.qiankun",
"name": "qiankun",
"path": "base/",
"pro_layout_parentKeys": Array [],
},
Object {
"children": Array [
Object {
"key": "/list/name",
"locale": "menu.list.name",
"name": "name",
"path": "/list/name",
"pro_layout_parentKeys": Array [
"/list",
],
},
Object {
"key": "name/",
"locale": "menu.list.name2",
"name": "name2",
"path": "name/",
"pro_layout_parentKeys": Array [
"/list",
],
},
],
"key": "/list",
"locale": "menu.list",
"name": "list",
"path": "/list",
"pro_layout_parentKeys": Array [],
},
Object {
"key": "/.",
"locale": "menu.all",
"name": "all",
"path": "/.",
"pro_layout_parentKeys": Array [],
},
]
`;

exports[`layout support **/* 2`] = `
Map {
"/base/" => Object {
"key": "base/",
"locale": "menu.qiankun",
"name": "qiankun",
"path": "base/",
"pro_layout_parentKeys": Array [],
},
"/list/name" => Object {
"key": "/list/name",
"locale": "menu.list.name",
"name": "name",
"path": "/list/name",
"pro_layout_parentKeys": Array [
"/list",
],
},
"/list/name/" => Object {
"key": "name/",
"locale": "menu.list.name2",
"name": "name2",
"path": "name/",
"pro_layout_parentKeys": Array [
"/list",
],
},
"/list" => Object {
"children": Array [
Object {
"key": "/list/name",
"locale": "menu.list.name",
"name": "name",
"path": "/list/name",
"pro_layout_parentKeys": Array [
"/list",
],
},
Object {
"key": "name/",
"locale": "menu.list.name2",
"name": "name2",
"path": "name/",
"pro_layout_parentKeys": Array [
"/list",
],
},
],
"key": "/list",
"locale": "menu.list",
"name": "list",
"path": "/list",
"pro_layout_parentKeys": Array [],
},
"/." => Object {
"key": "/.",
"locale": "menu.all",
"name": "all",
"path": "/.",
"pro_layout_parentKeys": Array [],
},
}
`;

exports[`normal 1`] = `
Object {
"access": "canAdmin",
Expand Down
20 changes: 20 additions & 0 deletions test/transformRoute.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -444,3 +444,23 @@ test('layout support *', () => {
expect(userMenuData).toMatchSnapshot();
expect(breadcrumb).toMatchSnapshot();
});

test('layout support **/*', () => {
const { menuData: userMenuData, breadcrumb } = transformRoute(
[
{ path: 'base/*', name: 'qiankun' },
{
path: 'list',
name: 'list',
children: [
{ path: 'name', name: 'name' },
{ path: 'name/*', name: 'name2' },
],
},
{ path: '/*', name: 'all' },
],
false,
);
expect(userMenuData).toMatchSnapshot();
expect(breadcrumb).toMatchSnapshot();
});

0 comments on commit 3c1f846

Please sign in to comment.