Skip to content

Commit 3d46ab9

Browse files
1 parent e7f41c2 commit 3d46ab9

11 files changed

+41
-206
lines changed

jest.setup.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { configure } from 'enzyme'
22
import Adapter from 'enzyme-adapter-react-16'
3+
import 'babel-polyfill';
34

45
configure({ adapter: new Adapter() })

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@material-ui/icons": "^4.9.1",
99
"@okta/okta-react": "^3.0.1",
1010
"axios": "^0.19.2",
11+
"babel-polyfill": "^6.26.0",
1112
"css-loader": "^3.5.3",
1213
"dotenv": "^8.2.0",
1314
"file-loader": "^6.0.0",

src/App.js

-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Container } from 'semantic-ui-react'
55
import config from './config'
66
import Navbar from './views/Navbar'
77
import Home from './views/Home'
8-
import Profile from './views/Profile'
98

109
const App = () => (
1110
<Router>
@@ -14,7 +13,6 @@ const App = () => (
1413
<Container text style={{ marginTop: '7em' }}>
1514
<Route path="/" exact component={Home} />
1615
<Route path="/implicit/callback" component={LoginCallback} />
17-
<SecureRoute path="/profile" component={Profile} />
1816
</Container>
1917
</Security>
2018
</Router>

src/App.test.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import { shallow } from 'enzyme'
3+
import App from './App'
4+
5+
describe('App component', () => {
6+
const component = shallow(<App />)
7+
8+
it('renders without crashing', () => {
9+
expect(component.length).toBe(1)
10+
})
11+
})

src/__tests__/App.test.js

-107
This file was deleted.

src/__tests__/__snapshots__/App.test.js.snap

-30
This file was deleted.

src/views/Home.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,13 @@ const Dashboard = () => {
3232
{authState.isAuthenticated && userInfo && (
3333
<div>
3434
<p>
35-
Logged in, Welcome back,
35+
Logged in, Welcome back,
3636
{userInfo.name}
3737
</p>
3838
<p>
39-
<a href="/profile">My Profile</a>
39+
Token:
40+
<br />
41+
{authState.accessToken}
4042
</p>
4143
</div>
4244
)}

src/views/Home.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react'
2+
import { shallow } from 'enzyme'
3+
import Home from './Home'
4+
5+
jest.mock('@okta/okta-react', () => ({
6+
useOktaAuth: () => {
7+
return {
8+
authState: {},
9+
authService: {}
10+
}
11+
}
12+
}))
13+
14+
describe('Home component', () => {
15+
const component = shallow(<Home />)
16+
17+
it('renders without crashing', () => {
18+
expect(component.length).toBe(1)
19+
})
20+
})

src/views/Navbar.js

-5
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,6 @@ const Navbar = () => {
1515
<Menu.Item as="a" header href="/">
1616
GitWize
1717
</Menu.Item>
18-
{authState.isAuthenticated && (
19-
<Menu.Item id="profile-button" as="a" href="/profile">
20-
Profile
21-
</Menu.Item>
22-
)}
2318
{authState.isAuthenticated && (
2419
<Menu.Item id="logout-button" as="a" onClick={logout}>
2520
Logout

src/views/Profile.js

-57
This file was deleted.

webpack.config.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ module.exports = {
1616
exclude: /node_modules/,
1717
loader: 'babel-loader'
1818
},
19-
{ test: /\.css$/, loader: "style-loader!css-loader" },
19+
{ test: /\.css$/, loader: 'style-loader!css-loader' },
2020
{
2121
test: /\.(jpg|png|gif|jpeg|woff|woff2|eot|ttf|svg)$/,
2222
loader: 'url-loader?limit=100000'
@@ -29,8 +29,9 @@ module.exports = {
2929
plugins: [
3030
new webpack.HotModuleReplacementPlugin(),
3131
new webpack.DefinePlugin({
32-
'process.env': JSON.stringify(dotenv.config().parsed)
33-
})],
32+
'process.env': JSON.stringify(dotenv.config().parsed)
33+
})
34+
],
3435
devtool: 'cheap-module-eval-source-map',
3536
devServer: {
3637
contentBase: path.join(__dirname, 'public'),

0 commit comments

Comments
 (0)