chore: optimize test case

This commit is contained in:
ClarkXia 2022-07-05 19:21:49 +08:00
parent 575920592e
commit 3e62eddfa0
3 changed files with 5 additions and 6 deletions

View File

@ -95,7 +95,7 @@ function getPageUrl(routeId: string, options: ParseOptions) {
async function getPageConfig(routeId: string, configEntry: string): Promise<MixedPage> {
const routesConfig = (await import(configEntry)).default;
const routeConfig = routesConfig![`/${routeId}`]?.() as MixedPage;
const routeConfig = routesConfig![`/${routeId}`]?.() as MixedPage || {};
const filteredConfig = {};
Object.keys(routeConfig).forEach((key) => {
if (validPageConfigKeys.includes(key)) {

View File

@ -415,7 +415,6 @@ describe('parse manifest', () => {
...options,
urlPrefix: '{{xxx}}/',
});
console.log('manifest', manifest);
expect(manifest.tab_bar?.url).toBe('{{xxx}}/tabBar');
expect(manifest.tab_bar?.name).toBe('{{xxx}}');
})

View File

@ -1,15 +1,15 @@
const configData = {
home: {
'/home': {
priority: 'low',
dataPrefetch: {
api: 'test/api',
},
},
about: {
'/about': {
defaultFrameIndex: 0,
queryParams: 'c=123',
},
'app/nest': {
'/app/nest': {
frames: [
'home',
{
@ -23,7 +23,7 @@ const config = new Proxy(configData, {
get: function(obj, props) {
if (props in obj) {
const defaultConfig = {
title: `title-${props}`,
title: `title-${props.replace(/^\//, '')}`,
};
return () => ({
...defaultConfig,