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

View File

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

View File

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