fix(client): add tests for layoutSelector (#41047)

This commit is contained in:
Ahmad Abdolsaheb
2021-02-18 08:11:05 +03:00
committed by GitHub
parent e7aa1c5d62
commit b57e268329
2 changed files with 87 additions and 8 deletions

View File

@@ -13,21 +13,22 @@ export default function layoutSelector({ element, props }) {
} = props;
if (element.type === FourOhFourPage) {
return <DefaultLayout pathname={pathname}>{element}</DefaultLayout>;
return (
<DefaultLayout pathname={pathname} showFooter={true}>
{element}
</DefaultLayout>
);
}
if (/\/certification\//.test(pathname)) {
return (
<CertificationLayout pathname={pathname}>{element}</CertificationLayout>
);
}
if (/\/guide\//.test(pathname)) {
console.log('Hitting guide for some reason. Need a redirect.');
}
const splitPath = pathname.split('/');
const splitPath = pathname.split('/').filter(x => x);
const isSuperBlock =
(splitPath.length === 3 && splitPath[1]) ||
(splitPath.length === 4 && splitPath[2]);
(splitPath.length === 2 && splitPath[0]) === 'learn' ||
(splitPath.length === 3 && splitPath[1]) === 'learn';
if (/\/learn\//.test(pathname) && !isSuperBlock) {
return (
@@ -37,7 +38,11 @@ export default function layoutSelector({ element, props }) {
);
}
return <DefaultLayout pathname={pathname}>{element}</DefaultLayout>;
return (
<DefaultLayout pathname={pathname} showFooter={true}>
{element}
</DefaultLayout>
);
}
layoutSelector.propTypes = {