diff --git a/src/App.test.js b/src/App.test.js
deleted file mode 100644
index 4db7ebc..0000000
--- a/src/App.test.js
+++ /dev/null
@@ -1,9 +0,0 @@
-import React from 'react';
-import { render } from '@testing-library/react';
-import App from './App';
-
-test('renders learn react link', () => {
- const { getByText } = render();
- const linkElement = getByText(/learn react/i);
- expect(linkElement).toBeInTheDocument();
-});
diff --git a/src/components/GitHubAuth.js b/src/components/GitHubAuth.js
index 8627799..d4e33bc 100644
--- a/src/components/GitHubAuth.js
+++ b/src/components/GitHubAuth.js
@@ -3,7 +3,6 @@ import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import GitHubLogin from 'react-github-login';
import { postGithubCode } from '../actions/login';
-import { withRouter } from 'react-router';
import { Icon, Message } from 'semantic-ui-react';
class GitHubAuth extends Component {
@@ -20,7 +19,6 @@ class GitHubAuth extends Component {
}
postCode = (response) => {
- console.log(response.code);
this.setState({
code: response.code,
});
@@ -39,7 +37,6 @@ class GitHubAuth extends Component {
posted: true,
errorText: 'Server Error: try again.',
});
- console.log(this.state.error, this.state.posted);
if (!this.state.error) {
this.props.history.push('/');
}
@@ -51,10 +48,12 @@ class GitHubAuth extends Component {
}, 4000);
};
- icon = () => {
+ githubIcon = () => {
return (
- Log in with GitHub
+
+ Log in with GitHub
+
);
};
@@ -74,7 +73,7 @@ class GitHubAuth extends Component {
}, 4000);
};
- UNSAFE_componentWillMount() {
+ componentDidMount() {
this.setState({
code: '',
error: null,
@@ -109,7 +108,7 @@ class GitHubAuth extends Component {
redirectUri={`${REACT_APP_GITHUB_CALLBACK_URL}`}
className="ui fluid button"
>
- {this.icon()}
+ {this.githubIcon()}
)}
>
@@ -126,6 +125,4 @@ const mapStateToProps = (state) => ({
loginerror: state.login.loginerror,
});
-export default connect(mapStateToProps, { postGithubCode })(
- withRouter(GitHubAuth)
-);
+export default connect(mapStateToProps, { postGithubCode })(GitHubAuth);
diff --git a/src/tests/GitHubAuth.test.js b/src/tests/GitHubAuth.test.js
new file mode 100644
index 0000000..ce10ae0
--- /dev/null
+++ b/src/tests/GitHubAuth.test.js
@@ -0,0 +1,25 @@
+import React from 'react';
+import { createStore } from 'redux';
+import { Provider } from 'react-redux';
+import { render, cleanup } from '@testing-library/react';
+import '@testing-library/jest-dom';
+import GitHubAuth from '../components/GitHubAuth';
+import loginReducer from '../reducers/login';
+
+afterEach(cleanup);
+
+function renderWithRedux(
+ component,
+ { initialState, store = createStore(loginReducer, initialState) } = {}
+) {
+ return {
+ ...render({component}),
+ };
+}
+
+it('Renders GitHub Login Button', () => {
+ const { getByTestId } = renderWithRedux();
+ expect(getByTestId('GitHubLoginButton')).toHaveTextContent(
+ 'Log in with GitHub'
+ );
+});