From 3c1f84691849a0a63777e7dc100402bedb82a12b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=9F=E8=B4=A4?= Date: Wed, 23 Nov 2022 15:20:43 +0800 Subject: [PATCH] test: add more test --- .../__snapshots__/transformRoute.test.ts.snap | 110 ++++++++++++++++++ test/transformRoute.test.ts | 20 ++++ 2 files changed, 130 insertions(+) diff --git a/test/__snapshots__/transformRoute.test.ts.snap b/test/__snapshots__/transformRoute.test.ts.snap index 257db20..2a0ca65 100644 --- a/test/__snapshots__/transformRoute.test.ts.snap +++ b/test/__snapshots__/transformRoute.test.ts.snap @@ -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", diff --git a/test/transformRoute.test.ts b/test/transformRoute.test.ts index eb40c77..c763412 100644 --- a/test/transformRoute.test.ts +++ b/test/transformRoute.test.ts @@ -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(); +});