Skip to content

Commit

Permalink
tests: Add test for NavBar
Browse files Browse the repository at this point in the history
  • Loading branch information
Shalinit3 committed Mar 20, 2019
1 parent 48f4efb commit 1db9732
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
Empty file.
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
Empty file.
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('Tests for <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);
});
});

0 comments on commit 1db9732

Please sign in to comment.