diff --git a/client/src/components/Intro/Intro.test.js b/client/src/components/Intro/Intro.test.tsx similarity index 94% rename from client/src/components/Intro/Intro.test.js rename to client/src/components/Intro/Intro.test.tsx index e332aaaa3e..dd9dbc8a96 100644 --- a/client/src/components/Intro/Intro.test.js +++ b/client/src/components/Intro/Intro.test.tsx @@ -3,11 +3,11 @@ import { Provider } from 'react-redux'; import renderer from 'react-test-renderer'; import { createStore } from '../../redux/createStore'; -import Intro from './'; +import Intro from '.'; jest.mock('../../analytics'); -function rendererCreateWithRedux(ui) { +function rendererCreateWithRedux(ui: JSX.Element) { return renderer.create({ui}); } @@ -57,7 +57,7 @@ const loggedInProps = { complete: true, isSignedIn: true, name: 'Development User', - navigate: () => {}, + navigate: () => jest.fn(), pending: false, slug: '/', username: 'DevelopmentUser' @@ -67,7 +67,7 @@ const loggedOutProps = { complete: true, isSignedIn: false, name: '', - navigate: () => {}, + navigate: () => jest.fn(), pending: false, slug: '/', username: '' diff --git a/client/src/components/Intro/index.js b/client/src/components/Intro/index.tsx similarity index 84% rename from client/src/components/Intro/index.js rename to client/src/components/Intro/index.tsx index 65f25076c3..75ff90cddc 100644 --- a/client/src/components/Intro/index.js +++ b/client/src/components/Intro/index.tsx @@ -1,4 +1,3 @@ -import PropTypes from 'prop-types'; import React from 'react'; import { Trans, useTranslation } from 'react-i18next'; import { randomQuote } from '../../utils/get-words'; @@ -9,24 +8,24 @@ import IntroDescription from './components/IntroDescription'; import './intro.css'; -const propTypes = { - complete: PropTypes.bool, - completedChallengeCount: PropTypes.number, - isSignedIn: PropTypes.bool, - name: PropTypes.string, - pending: PropTypes.bool, - slug: PropTypes.string, - username: PropTypes.string -}; +interface IntroProps { + complete?: boolean; + completedChallengeCount?: number; + isSignedIn?: boolean; + name?: string; + pending?: boolean; + slug?: string; + username?: string; +} -function Intro({ +const Intro = ({ isSignedIn, name, pending, complete, completedChallengeCount, slug -}) { +}: IntroProps): JSX.Element => { const { t } = useTranslation(); if (pending && !complete) { return ( @@ -48,7 +47,7 @@ function Intro({ - {completedChallengeCount > 0 ? ( + {completedChallengeCount && completedChallengeCount > 0 ? ( {t('buttons.current-challenge')} @@ -67,7 +66,7 @@ function Intro({ - {completedChallengeCount < 15 ? ( + {completedChallengeCount && slug && completedChallengeCount < 15 ? (

@@ -94,9 +93,8 @@ function Intro({ ); } -} +}; -Intro.propTypes = propTypes; Intro.displayName = 'Intro'; export default Intro;