-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
677 additions
and
123 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Routes snapshot matches with no accounts 1`] = ` | ||
<div> | ||
<div | ||
className="MuiGrid-container-8 LandingComponent-root-1" | ||
> | ||
<div | ||
className="MuiGrid-item-9 MuiGrid-grid-xs-6-42 LandingComponent-left-2" | ||
> | ||
<div | ||
className="LandingComponent-logo-3" | ||
> | ||
Entaxy | ||
<div | ||
className="LandingComponent-tagline-4" | ||
> | ||
Order from chaos | ||
</div> | ||
</div> | ||
<div | ||
className="LandingComponent-title-5" | ||
> | ||
Your Personal Finance Simple & Private | ||
<div | ||
className="LandingComponent-description-6" | ||
> | ||
Insights into your finances, without sacrificing your data | ||
</div> | ||
</div> | ||
<div | ||
className="MuiGrid-container-8" | ||
> | ||
<h5 | ||
className="MuiTypography-root-111 MuiTypography-h5-127 MuiTypography-colorSecondary-142" | ||
> | ||
Where do you want to store your data? | ||
</h5> | ||
<div | ||
className="MuiGrid-item-9 MuiGrid-grid-xs-6-42" | ||
> | ||
<div | ||
className="MuiPaper-root-147 MuiPaper-elevation1-150 MuiPaper-rounded-148 LandingCardComponent-loggedInContainer-106" | ||
> | ||
<h6 | ||
className="MuiTypography-root-111 MuiTypography-subtitle2-130 LandingCardComponent-blockstackTitle-109" | ||
> | ||
Anywhere with blockstack | ||
</h6> | ||
<span | ||
className="MuiTypography-root-111 MuiTypography-caption-121 LandingCardComponent-signingDescription-107" | ||
> | ||
Keep your data encrypted and decentralized. Learn more about | ||
<a | ||
href="https://blockstack.org/what-is-blockstack" | ||
rel="noopener noreferrer" | ||
target="_blank" | ||
> | ||
Blockstack | ||
</a> | ||
</span> | ||
<button | ||
className="MuiButtonBase-root-200 MuiButton-root-174 MuiButton-contained-185 MuiButton-containedSecondary-187 MuiButton-raised-188 MuiButton-raisedSecondary-190 LandingCardComponent-signinButton-108" | ||
disabled={false} | ||
onBlur={[Function]} | ||
onClick={[Function]} | ||
onContextMenu={[Function]} | ||
onFocus={[Function]} | ||
onKeyDown={[Function]} | ||
onKeyUp={[Function]} | ||
onMouseDown={[Function]} | ||
onMouseLeave={[Function]} | ||
onMouseUp={[Function]} | ||
onTouchEnd={[Function]} | ||
onTouchMove={[Function]} | ||
onTouchStart={[Function]} | ||
tabIndex="0" | ||
type="button" | ||
> | ||
<span | ||
className="MuiButton-label-175" | ||
> | ||
Sign in with Blockstack | ||
</span> | ||
<span | ||
className="MuiTouchRipple-root-214" | ||
/> | ||
</button> | ||
</div> | ||
</div> | ||
<div | ||
className="MuiGrid-item-9 MuiGrid-grid-xs-6-42" | ||
> | ||
<div | ||
className="MuiPaper-root-147 MuiPaper-elevation1-150 MuiPaper-rounded-148 LandingCardComponent-loggedInContainer-106" | ||
> | ||
<h6 | ||
className="MuiTypography-root-111 MuiTypography-subtitle2-130" | ||
> | ||
<svg | ||
aria-hidden="true" | ||
className="MuiSvgIcon-root-203 LandingCardComponent-browserIcon-110" | ||
focusable="false" | ||
role="presentation" | ||
viewBox="0 0 24 24" | ||
> | ||
<defs> | ||
<path | ||
d="M0 0h24v24H0V0z" | ||
id="a" | ||
/> | ||
</defs> | ||
<path | ||
d="M20 18c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2H0v2h24v-2h-4zM4 6h16v10H4V6z" | ||
/> | ||
</svg> | ||
Locally in your browser | ||
</h6> | ||
<span | ||
className="MuiTypography-root-111 MuiTypography-caption-121 LandingCardComponent-signingDescription-107" | ||
> | ||
Your data will be stored temporarily and it be removed once you close your browser | ||
</span> | ||
<button | ||
className="MuiButtonBase-root-200 MuiButton-root-174 MuiButton-contained-185 MuiButton-containedSecondary-187 MuiButton-raised-188 MuiButton-raisedSecondary-190 LandingCardComponent-signinButton-108" | ||
disabled={false} | ||
onBlur={[Function]} | ||
onClick={[Function]} | ||
onContextMenu={[Function]} | ||
onFocus={[Function]} | ||
onKeyDown={[Function]} | ||
onKeyUp={[Function]} | ||
onMouseDown={[Function]} | ||
onMouseLeave={[Function]} | ||
onMouseUp={[Function]} | ||
onTouchEnd={[Function]} | ||
onTouchMove={[Function]} | ||
onTouchStart={[Function]} | ||
tabIndex="0" | ||
type="button" | ||
> | ||
<span | ||
className="MuiButton-label-175" | ||
> | ||
Take it for a test drive | ||
</span> | ||
<span | ||
className="MuiTouchRipple-root-214" | ||
/> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<div> | ||
<p | ||
className="MuiTypography-root-111 MuiTypography-body2-119" | ||
> | ||
Entaxy is free and you get to keep your data. | ||
</p> | ||
<p | ||
className="MuiTypography-root-111 MuiTypography-body2-119" | ||
> | ||
That's right, we don't store your data in a big database so we don't need to convince you to trust us. | ||
</p> | ||
</div> | ||
</div> | ||
<div | ||
className="MuiGrid-item-9 MuiGrid-grid-xs-6-42 LandingComponent-right-7" | ||
/> | ||
</div> | ||
</div> | ||
`; |
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,107 @@ | ||
import React from 'react' | ||
import renderer from 'react-test-renderer' | ||
import { shallow } from 'enzyme' | ||
import { Provider } from 'react-redux' | ||
import { BrowserRouter, Redirect } from 'react-router-dom' | ||
import store from '../store' | ||
import ThemeProvider from '../core/ThemeProvider' | ||
import { initialState as userInitialState } from '../store/user/reducer' | ||
import { initialState as settingsInitialState } from '../store/settings/reducer' | ||
import { initialState as accountsInitialState } from '../store/accounts/reducer' | ||
import { RoutesComponent } from '../routes' | ||
import Header from '../common/Header' | ||
|
||
jest.mock('../common/InstitutionIcon', () => 'InstitutionIcon') | ||
|
||
const FakeComponent = () => (<div />) | ||
|
||
describe('Routes', () => { | ||
describe('snapshot', () => { | ||
it('matches with no accounts', () => { | ||
const component = renderer.create(( | ||
<Provider store={store}> | ||
<ThemeProvider> | ||
<BrowserRouter> | ||
<RoutesComponent | ||
user={userInitialState} | ||
settings={settingsInitialState} | ||
accounts={accountsInitialState} | ||
classes={{ }} | ||
/> | ||
</BrowserRouter> | ||
</ThemeProvider> | ||
</Provider> | ||
)) | ||
expect(component.toJSON()).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('Component methods', () => { | ||
let wrapper | ||
it('Should redirect if user is not authenticated', () => { | ||
wrapper = shallow(( | ||
<RoutesComponent | ||
user={userInitialState} | ||
settings={settingsInitialState} | ||
accounts={accountsInitialState} | ||
classes={{ }} | ||
/> | ||
)) | ||
const instance = wrapper.instance() | ||
|
||
expect(instance.props.user.isAuthenticatedWith).toBeNull() | ||
expect(instance.loginRequired(FakeComponent)()).toEqual(<Redirect to="/" />) | ||
}) | ||
|
||
it('Should render component with no options', () => { | ||
wrapper = shallow(( | ||
<RoutesComponent | ||
user={{ isAuthenticatedWith: true }} | ||
settings={settingsInitialState} | ||
accounts={accountsInitialState} | ||
classes={{ }} | ||
/> | ||
)) | ||
const instance = wrapper.instance() | ||
|
||
expect(instance.props.user.isAuthenticatedWith).toBeTruthy() | ||
expect(instance.loginRequired(FakeComponent)()).toEqual(( | ||
<Header><FakeComponent /></Header> | ||
)) | ||
}) | ||
|
||
it('Should redirect if there are no accounts', () => { | ||
wrapper = shallow(( | ||
<RoutesComponent | ||
user={{ isAuthenticatedWith: true }} | ||
settings={settingsInitialState} | ||
accounts={accountsInitialState} | ||
classes={{ }} | ||
/> | ||
)) | ||
const instance = wrapper.instance() | ||
|
||
expect(instance.props.user.isAuthenticatedWith).toBeTruthy() | ||
expect(instance.loginRequired(FakeComponent, { accountRequired: true })()).toEqual(( | ||
<Redirect to="/" /> | ||
)) | ||
}) | ||
|
||
it('Should render component when accounts required', () => { | ||
wrapper = shallow(( | ||
<RoutesComponent | ||
user={{ isAuthenticatedWith: true }} | ||
settings={settingsInitialState} | ||
accounts={{ byId: [{ id: 1 }] }} | ||
classes={{ }} | ||
/> | ||
)) | ||
const instance = wrapper.instance() | ||
|
||
expect(instance.props.user.isAuthenticatedWith).toBeTruthy() | ||
expect(instance.loginRequired(FakeComponent, { accountRequired: true })()).toEqual(( | ||
<Header><FakeComponent /></Header> | ||
)) | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.