This repository has been archived by the owner on Apr 15, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #542 from alepop/506-fix-header-component
Fix header component - Closes #506
- Loading branch information
Showing
7 changed files
with
89 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,3 +16,7 @@ | |
.material-icons{ | ||
font-size: 24px !important; | ||
} | ||
|
||
.menu { | ||
right: -16px !important; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react'; | ||
import { connect } from 'react-redux'; | ||
|
||
export const PrivateWrapperComponent = ({ isAuthenticated, children }) => ( | ||
isAuthenticated && <span>{ children }</ span> | ||
); | ||
|
||
const mapStateToProps = state => ({ | ||
isAuthenticated: !!state.account.publicKey, | ||
}); | ||
|
||
export default connect(mapStateToProps)(PrivateWrapperComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { shallow } from 'enzyme'; | ||
import { PrivateWrapperComponent } from '.'; | ||
|
||
const Private = () => <h1>Private</h1>; | ||
|
||
describe('PrivateWrapperComponent', () => { | ||
const isAuth = isAuthenticated => ( | ||
shallow( | ||
<PrivateWrapperComponent isAuthenticated={isAuthenticated}> | ||
<Private/ > | ||
</PrivateWrapperComponent>, | ||
) | ||
); | ||
it('should render children components if user is authenticated', () => { | ||
const wrapper = isAuth(true); | ||
expect(wrapper.find(Private)).to.have.length(1); | ||
}); | ||
|
||
it('should do not render children components if user is not authenticated', () => { | ||
const wrapper = isAuth(false); | ||
expect(wrapper.find(Private)).to.have.length(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters