fix: footer showing up on new RWD challenges (#44562)

This commit is contained in:
Tom
2021-12-23 01:02:35 -06:00
committed by GitHub
parent 075bc04a2b
commit b27aeb11ca
2 changed files with 32 additions and 2 deletions

View File

@ -7,11 +7,23 @@ const pathnames = {
challenge:
'/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
},
englishWithYear: {
landing: '/',
superBlock: '/learn/2022/responsive-web-design',
challenge:
'/learn/2022/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
},
espanol: {
landing: '/espanol',
superBlock: '/espanol/learn/responsive-web-design',
challenge:
'/espanol/learn/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
},
espanolWithYear: {
landing: '/espanol',
superBlock: '/espanol/learn/2022/responsive-web-design',
challenge:
'/espanol/learn/2022/responsive-web-design/basic-html-and-html5/say-hello-to-html-elements'
}
};
@ -37,6 +49,12 @@ describe('isLanding', () => {
it('returns false for English challenge pathname', () => {
expect(isLanding(pathnames.english.challenge)).toBe(false);
});
it('returns false for English with year challenge pathname', () => {
expect(isLanding(pathnames.englishWithYear.challenge)).toBe(false);
});
it('returns false for Espanol with year challenge pathname', () => {
expect(isLanding(pathnames.espanolWithYear.challenge)).toBe(false);
});
});
describe('isChallenge', () => {
@ -61,4 +79,10 @@ describe('isChallenge', () => {
it('returns true for English challenge pathname', () => {
expect(isChallenge(pathnames.english.challenge)).toBe(true);
});
it('returns true for English with year challenge pathname', () => {
expect(isChallenge(pathnames.englishWithYear.challenge)).toBe(true);
});
it('returns true for Espanol with year challenge pathname', () => {
expect(isChallenge(pathnames.espanolWithYear.challenge)).toBe(true);
});
});

View File

@ -7,8 +7,14 @@ const splitPath = (pathname: string): string[] =>
export const isChallenge = (pathname: string): boolean => {
const pathArray = splitPath(pathname);
return (
(pathArray.length === 4 && pathArray[0]) === 'learn' ||
(pathArray.length === 5 && pathArray[1]) === 'learn'
// learn/<superBlock>/<block>/<challenge>
(pathArray.length === 4 && pathArray[0] === 'learn') ||
// learn/<year>/<superBlock>/<block>/<challenge>
(pathArray.length === 5 && pathArray[0] === 'learn') ||
// <i18n>/learn/<superBlock>/<block>/<challenge>
(pathArray.length === 5 && pathArray[1] === 'learn') ||
// <i18n>/learn/<year>/<superBlock>/<block>/<challenge>
(pathArray.length === 6 && pathArray[1] === 'learn')
);
};