Skip to content

Commit

Permalink
Merge pull request #25 from paritytech/standard
Browse files Browse the repository at this point in the history
Standard
  • Loading branch information
debris authored Mar 24, 2017
2 parents 29836a9 + f630906 commit c4aa9b8
Show file tree
Hide file tree
Showing 35 changed files with 303 additions and 274 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
language: node_js
node_js:
- 6

cache:
directories:
- node_modules

install: true

script:
- npm run lint
- npm run test
10 changes: 6 additions & 4 deletions __tests__/index.android.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import React from 'react'
import 'react-native'
import App from '../src/components/App'

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import renderer from 'react-test-renderer'

it('renders correctly', () => {
const tree = renderer.create(
<App/>
<App />
)
});

expect(tree).toBeTruthy()
})
10 changes: 6 additions & 4 deletions __tests__/index.ios.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React from 'react';
import React from 'react'
import 'react-native'
import App from '../src/components/App'

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';
import renderer from 'react-test-renderer'

it('renders correctly', () => {
const tree = renderer.create(
<App/>
<App />
)
});

expect(tree).toBeTruthy()
})
5 changes: 3 additions & 2 deletions jest-setup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//import mockCamera from './__mocks__/Camera'
/* global jest */
// import mockCamera from './__mocks__/Camera'

jest.unmock('Image')
jest.mock('react-native-camera', () => 'camera')
Expand All @@ -8,6 +9,6 @@ jest.mock('Linking', () => {
removeEventListener: jest.fn(),
openURL: jest.fn(),
canOpenURL: jest.fn(),
getInitialURL: jest.fn(),
getInitialURL: jest.fn()
}
})
29 changes: 27 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
"scripts": {
"build-rust": "cd rust/signer && make ios",
"start": "npm run build-rust && node node_modules/react-native/local-cli/cli.js run-ios",
"test": "jest"
"test": "jest",
"lint": "standard",
"commit": "commit-wizard"
},
"dependencies": {
"bignumber.js": "^4.0.0",
Expand All @@ -21,16 +23,39 @@
"redux": "^3.6.0"
},
"devDependencies": {
"babel-eslint": "^7.2.1",
"babel-jest": "18.0.0",
"babel-preset-react-native": "1.9.1",
"jest": "18.1.0",
"jest-react-native": "^18.0.0",
"react-test-renderer": "15.4.2"
"pre-git": "^3.14.0",
"react-test-renderer": "15.4.2",
"standard": "^9.0.2"
},
"jest": {
"preset": "react-native",
"setupFiles": [
"<rootDir>/jest-setup.js"
]
},
"standard": {
"globals": [
"it",
"describe",
"expect"
],
"parser": "babel-eslint"
},
"config": {
"pre-git": {
"pre-commit": [],
"pre-push": [
"npm run lint -- --fix",
"npm run test"
],
"post-commit": [],
"post-checkout": [],
"post-merge": []
}
}
}
22 changes: 11 additions & 11 deletions src/actions/accounts.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
'use strict'

import { ADD_ACCOUNT, SELECT_ACCOUNT, DELETE_ACCOUNT, SET_PIN, CONFIRM_PIN, SET_ACCOUNTS } from '../constants/AccountActions'
import { ADD_ACCOUNT, SELECT_ACCOUNT, DELETE_ACCOUNT, SET_PIN, SET_ACCOUNTS } from '../constants/AccountActions'

export function addAccount(account) {
export function addAccount (account) {
return {
type: ADD_ACCOUNT,
account,
account
}
}

export function selectAccount(account) {
export function selectAccount (account) {
return {
type: SELECT_ACCOUNT,
account,
account
}
}

export function deleteAccount(account) {
export function deleteAccount (account) {
return {
type: DELETE_ACCOUNT,
account,
account
}
}

export function setPin(pin) {
export function setPin (pin) {
return {
type: SET_PIN,
pin,
pin
}
}

export function setAccounts(accounts) {
export function setAccounts (accounts) {
return {
type: SET_ACCOUNTS,
accounts,
accounts
}
}
8 changes: 4 additions & 4 deletions src/actions/transactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

import { NEW_SCANNED_TX, SIGNED_TX } from '../constants/TransactionActions'

export function scannedTx(rlp, transaction) {
export function scannedTx (rlp, transaction) {
return {
type: NEW_SCANNED_TX,
rlp,
transaction,
transaction
}
}

export function signedTx(signature) {
export function signedTx (signature) {
return {
type: SIGNED_TX,
signature: signature,
signature: signature
}
}
8 changes: 4 additions & 4 deletions src/components/AccountDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import AppStyles from '../styles'
export default class AccountDetails extends Component {
static propTypes = {
account: PropTypes.shape({
address: PropTypes.string.isRequired,
address: PropTypes.string.isRequired
}).isRequired,
onDisplayAddressPressed: PropTypes.func.isRequired,
onDeleteAccountPressed: PropTypes.func.isRequired,
onDeleteAccountPressed: PropTypes.func.isRequired
}

render() {
render () {
return (
<ScrollView style={AppStyles.view}>
<Text style={AppStyles.hintText}>Name</Text>
Expand Down Expand Up @@ -45,6 +45,6 @@ export default class AccountDetails extends Component {

const styles = StyleSheet.create({
button: {
flex: 0.5,
flex: 0.5
}
})
16 changes: 8 additions & 8 deletions src/components/AccountList.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
'use strict'

import React, { Component, PropTypes } from 'react'
import { Text, View, ListView, RecyclerViewBackedScrollView, StatusBar } from 'react-native'
import { ListView, RecyclerViewBackedScrollView, StatusBar } from 'react-native'
import AccountListRow from './AccountListRow'
import AppStyles from '../styles'

export default class AccountList extends Component {
static propTypes = {
accounts: PropTypes.arrayOf(PropTypes.shape({
address: PropTypes.string.isRequired,
address: PropTypes.string.isRequired
})).isRequired,
onAccountSelected: PropTypes.func.isRequired,
onAccountSelected: PropTypes.func.isRequired
}

constructor(props) {
constructor (props) {
super(props)
const ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2})
this.state = {
dataSource: ds.cloneWithRows(props.accounts)
}
}

componentWillReceiveProps(nextProps) {
componentWillReceiveProps (nextProps) {
this.setState({
dataSource: this.state.dataSource.cloneWithRows(nextProps.accounts)
})
}

render() {
render () {
return (
<ListView
style={AppStyles.listView}
Expand All @@ -44,10 +44,10 @@ export default class AccountList extends Component {
/>
)
}}
enableEmptySections={true}
enableEmptySections
renderScrollComponent={props => <RecyclerViewBackedScrollView {...props} />}
>
<StatusBar barStyle='light-content'/>
<StatusBar barStyle='light-content' />
</ListView>
)
}
Expand Down
29 changes: 14 additions & 15 deletions src/components/AccountListRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import React, { Component, PropTypes } from 'react'
import { TouchableHighlight, StyleSheet, View, Text, Image } from 'react-native'
import { blockiesIcon } from '../util/native'

async function displayIcon(self, seed) {
async function displayIcon (self, seed) {
try {
let icon = await blockiesIcon(seed)
self.setState({
icon: icon,
icon: icon
})

} catch (e) {
console.log(e)
}
Expand All @@ -20,15 +19,15 @@ export default class AccountListRow extends Component {
static propTypes = {
upperText: PropTypes.string.isRequired,
lowerText: PropTypes.string.isRequired,
onPress: PropTypes.func.isRequired,
onPress: PropTypes.func.isRequired
}

constructor(props) {
constructor (props) {
super(props)
this.state = {}
}

render() {
render () {
displayIcon(this, this.props.lowerText)

return (
Expand All @@ -40,12 +39,12 @@ export default class AccountListRow extends Component {
source={{uri: this.state.icon}}
/>
<View style={{flexDirection: 'column'}}>
<Text style={styles.upperText} ellipsizeMode="middle" numberOfLines={1}>{this.props.upperText}</Text>
<Text style={styles.lowerText} ellipsizeMode="middle" numberOfLines={1}>{this.props.lowerText}</Text>
<Text style={styles.upperText} ellipsizeMode='middle' numberOfLines={1}>{this.props.upperText}</Text>
<Text style={styles.lowerText} ellipsizeMode='middle' numberOfLines={1}>{this.props.lowerText}</Text>
</View>
</View>
<View style={{height: 1, backgroundColor: '#ccc'}}/>
<View style={{height: 1, backgroundColor: '#ddd'}}/>
<View style={{height: 1, backgroundColor: '#ccc'}} />
<View style={{height: 1, backgroundColor: '#ddd'}} />
</View>
</TouchableHighlight>
)
Expand All @@ -54,23 +53,23 @@ export default class AccountListRow extends Component {

const styles = StyleSheet.create({
row: {
backgroundColor: '#F8F8F8',
backgroundColor: '#F8F8F8'
},
square: {
height: 60,
width: 60,
marginRight: 10,
resizeMode: 'contain',
resizeMode: 'contain'
},
upperText: {
marginTop: 20,
width: 200,
fontSize: 16,
color: '#888',
color: '#888'
},
lowerText: {
marginTop: 5,
color: '#aaa',
fontSize: 10,
},
fontSize: 10
}
})
Loading

0 comments on commit c4aa9b8

Please sign in to comment.