Skip to content
This repository has been archived by the owner on May 28, 2018. It is now read-only.

Commit

Permalink
Display username in navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
nbrohee committed Nov 18, 2016
1 parent e819fa9 commit 1473cbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 2 additions & 4 deletions client/src/components/header/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ export class Header extends React.Component {
<Navbar.Toggle />
</Navbar.Header>
<Navbar.Collapse>
<Nav>
<LinkContainer to="/application">
<NavItem eventKey={1}>Candidature</NavItem>
</LinkContainer>
<Nav pullRight>
<NavItem id="navbar-user">{this.props.user.username}</NavItem>
</Nav>
</Navbar.Collapse>
</Navbar >
Expand Down
14 changes: 11 additions & 3 deletions client/src/components/header/Header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,17 @@ describe('<Header>', () => {
const navbar = wrapper.find('.navbar')
expect(navbar.length).toBe(0)
})
it('shows when user is logged in', () => {
const wrapper = setup({ isAuthenticated: true })
describe('When user is logged in', () => {
const authenticatedUser = { isAuthenticated: true, username: "authenticated user" }
const wrapper = setup(authenticatedUser)
const navbar = wrapper.find('.navbar')
expect(navbar.length).toBe(1)
it('should display Header', () => {
expect(navbar.length).toBe(1)
})
it('should display username', () => {
const usernameDisplay = navbar.find('#navbar-user')
expect(usernameDisplay.length).toBe(1)
expect(usernameDisplay.text()).toBe(authenticatedUser.username)
})
})
})

0 comments on commit 1473cbc

Please sign in to comment.