Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup test for client and add tests #69

Merged
merged 3 commits into from
Mar 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"react"
],
"rules": {
"react/jsx-filename-extension": 0
"react/jsx-filename-extension": 0,
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}]
Shalinit3 marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 1 addition & 3 deletions client/src/components/UI/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ const ButtonAppBar = ({ classes, isLoggedIn }) => (
</Typography>
{isLoggedIn
? (
<>
<Button color="inherit">Lead Board</Button>
</>
<Button color="inherit">Leader Board</Button>
)
: <Button color="inherit" href="/auth/signin">login</Button>}
</Toolbar>
Expand Down
26 changes: 26 additions & 0 deletions client/src/components/UI/__tests__/navBar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { shallow } from 'enzyme';
import NavBar from '../NavBar';

describe('<NavBar />', () => {
it('should render', () => {
const wrapper = shallow(<NavBar />);
expect(wrapper.dive().find('div').length).toBe(1);
});
it('should contain LogIn button by default', () => {
const wrapper = shallow(<NavBar />);
expect(wrapper.dive().contains('login')).toBe(true);
});
it('should not contain Leader Board by default', () => {
const wrapper = shallow(<NavBar />);
expect(wrapper.dive().contains('Leader Board')).toBe(false);
});
it('should not contain LogIn button if user has already logged in', () => {
const wrapper = shallow(<NavBar isLoggedIn />);
expect(wrapper.dive().contains('login')).toBe(false);
});
it('should contain Leader Board by default', () => {
const wrapper = shallow(<NavBar isLoggedIn />);
expect(wrapper.dive().contains('Leader Board')).toBe(true);
});
});
Shalinit3 marked this conversation as resolved.
Show resolved Hide resolved
20 changes: 20 additions & 0 deletions client/src/components/UI/__tests__/scoreCard.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import { shallow } from 'enzyme';
import Table from '@material-ui/core/Table';
import TableRow from '@material-ui/core/TableRow';
import ScoreCard from '../ScoreCard';

describe('<ScoreCard />', () => {
it('should render just one Table at a time', () => {
const wrapper = shallow(<ScoreCard />);
expect(wrapper.dive().find(Table).length).toBe(1);
});
it('should render three Rows if its not detailed scorecard', () => {
const wrapper = shallow(<ScoreCard />);
expect(wrapper.dive().find(TableRow).length).toBe(3);
});
it('should render five Rows if its detailed scorecard', () => {
const wrapper = shallow(<ScoreCard isDetailed />);
expect(wrapper.dive().find(TableRow).length).toBe(5);
});
});
4 changes: 4 additions & 0 deletions client/src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

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