fix: use Login over custom button

This commit is contained in:
Oliver Eyton-Williams
2020-08-10 13:28:17 +02:00
committed by Mrugesh Mohapatra
parent a7d595f349
commit 456173f677
2 changed files with 14 additions and 13 deletions

View File

@ -1,21 +1,28 @@
/* global expect */ /* global expect */
import React from 'react'; import React from 'react';
import renderer from 'react-test-renderer'; import renderer from 'react-test-renderer';
// import ShallowRenderer from 'react-test-renderer/shallow'; import { Provider } from 'react-redux';
import { createStore } from '../../redux/createStore';
import 'jest-dom/extend-expect'; import 'jest-dom/extend-expect';
import Intro from './'; import Intro from './';
function rendererCreateWithRedux(ui) {
return renderer.create(<Provider store={createStore()}>{ui}</Provider>);
}
describe('<Intro />', () => { describe('<Intro />', () => {
it('has no blockquotes when loggedOut', () => { it('has no blockquotes when loggedOut', () => {
const container = renderer.create(<Intro {...loggedOutProps} />).root; const container = rendererCreateWithRedux(<Intro {...loggedOutProps} />)
.root;
expect(container.findAllByType('blockquote').length === 0).toBeTruthy(); expect(container.findAllByType('blockquote').length === 0).toBeTruthy();
expect(container.findAllByType('h1').length === 1).toBeTruthy(); expect(container.findAllByType('h1').length === 1).toBeTruthy();
}); });
it('has a blockquote when loggedIn', () => { it('has a blockquote when loggedIn', () => {
const container = renderer.create(<Intro {...loggedInProps} />).root; const container = rendererCreateWithRedux(<Intro {...loggedInProps} />)
.root;
expect(container.findAllByType('blockquote').length === 1).toBeTruthy(); expect(container.findAllByType('blockquote').length === 1).toBeTruthy();
expect(container.findAllByType('h1').length === 1).toBeTruthy(); expect(container.findAllByType('h1').length === 1).toBeTruthy();
}); });

View File

@ -2,18 +2,18 @@ import React from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import { Link, Spacer, Loader, FullWidthRow } from '../helpers'; import { Link, Spacer, Loader, FullWidthRow } from '../helpers';
import { Row, Col } from '@freecodecamp/react-bootstrap'; import { Row, Col } from '@freecodecamp/react-bootstrap';
import { apiLocation, forumLocation } from '../../../config/env.json'; import { forumLocation } from '../../../config/env.json';
import { randomQuote } from '../../utils/get-words'; import { randomQuote } from '../../utils/get-words';
import CurrentChallengeLink from '../helpers/CurrentChallengeLink'; import CurrentChallengeLink from '../helpers/CurrentChallengeLink';
import './intro.css'; import './intro.css';
import Login from '../Header/components/Login';
const propTypes = { const propTypes = {
complete: PropTypes.bool, complete: PropTypes.bool,
completedChallengeCount: PropTypes.number, completedChallengeCount: PropTypes.number,
isSignedIn: PropTypes.bool, isSignedIn: PropTypes.bool,
name: PropTypes.string, name: PropTypes.string,
navigate: PropTypes.func,
pending: PropTypes.bool, pending: PropTypes.bool,
slug: PropTypes.string, slug: PropTypes.string,
username: PropTypes.string username: PropTypes.string
@ -23,7 +23,6 @@ function Intro({
isSignedIn, isSignedIn,
username, username,
name, name,
navigate,
pending, pending,
complete, complete,
completedChallengeCount, completedChallengeCount,
@ -163,14 +162,9 @@ function Intro({
</Col> </Col>
<Col sm={8} smOffset={2} xs={12}> <Col sm={8} smOffset={2} xs={12}>
<button <Login block={true}>
className={'btn-cta-big signup-btn btn-cta center-block'}
onClick={() => {
navigate(`${apiLocation}/signin`);
}}
>
Sign in to save your progress (it's free) Sign in to save your progress (it's free)
</button> </Login>
</Col> </Col>
</Row> </Row>
<Spacer /> <Spacer />