more tests

This commit is contained in:
Overtorment 2018-03-18 15:15:10 +00:00
parent 145e298825
commit 41a1ce812b
8 changed files with 171 additions and 137 deletions

1
App.js
View file

@ -1,4 +1,3 @@
/** @type {AppStorage} */
import './shim.js';
import React from 'react';
import PropTypes from 'prop-types';

View file

@ -1,7 +1,12 @@
/* global describe, it */
/* global describe, it, expect, jest */
import React from 'react';
import { LegacyWallet } from './class';
import renderer from 'react-test-renderer';
import App from './App';
import Settings from './screen/settings';
import { BlueHeader } from './BlueComponents';
let assert = require('assert');
jest.mock('react-native-qrcode', () => 'Video');
describe('unit - LegacyWallet', function() {
it('serialize and unserialize work correctly', () => {
@ -15,3 +20,18 @@ describe('unit - LegacyWallet', function() {
assert.equal(key, JSON.stringify(b));
});
});
it('App does not crash', () => {
const rendered = renderer.create(<App />).toJSON();
expect(rendered).toBeTruthy();
});
it('BlueHeader works', () => {
const rendered = renderer.create(<BlueHeader />).toJSON();
expect(rendered).toBeTruthy();
});
it('Settings work', () => {
const rendered = renderer.create(<Settings />).toJSON();
expect(rendered).toBeTruthy();
});

View file

@ -30,7 +30,7 @@
"ios": "react-native-scripts ios",
"postinstall": "./node_modules/.bin/rn-nodeify --install buffer,events,process,stream,util,inherits,fs,path --hack",
"test": "nodejs ./node_modules/.bin/mocha tests/* && node node_modules/jest/bin/jest.js && npm run lint",
"lint": "./node_modules/.bin/eslint *.js screen/**/*.js --fix"
"lint": "./node_modules/.bin/eslint *.js screen/**/*.js screen/ --fix"
},
"jest": {
"preset": "jest-expo"

View file

@ -1,19 +1,21 @@
import React from 'react'
import { StackNavigator } from 'react-navigation'
import { StackNavigator } from 'react-navigation';
import list from './receive/list'
import details from './receive/details'
import list from './receive/list';
import details from './receive/details';
const ReceiveNavigator = StackNavigator({
SendList: {
screen: list
const ReceiveNavigator = StackNavigator(
{
SendList: {
screen: list,
},
ReceiveDetails: {
screen: details,
},
},
ReceiveDetails: {
screen: details
}
}, {
headerMode: 'none',
mode: 'modal'
})
{
headerMode: 'none',
mode: 'modal',
},
);
export default ReceiveNavigator
export default ReceiveNavigator;

View file

@ -1,27 +1,29 @@
import React from 'react'
import { StackNavigator } from 'react-navigation'
import { StackNavigator } from 'react-navigation';
import list from './send/list'
import details from './send/details'
import scanQrAddress from './send/scanQrAddress'
import create from './send/create'
import list from './send/list';
import details from './send/details';
import scanQrAddress from './send/scanQrAddress';
import create from './send/create';
const SendNavigator = StackNavigator({
SendList: {
screen: list
const SendNavigator = StackNavigator(
{
SendList: {
screen: list,
},
SendDetails: {
screen: details,
},
ScanQrAddress: {
screen: scanQrAddress,
},
CreateTransaction: {
screen: create,
},
},
SendDetails: {
screen: details
{
headerMode: 'none',
mode: 'modal',
},
ScanQrAddress: {
screen: scanQrAddress
},
CreateTransaction: {
screen: create
}
}, {
headerMode: 'none',
mode: 'modal'
})
);
export default SendNavigator
export default SendNavigator;

View file

@ -1,17 +1,20 @@
let BlueApp = require('../BlueApp')
import React, { Component } from 'react';
import { ScrollView, Linking, ActivityIndicator, StyleSheet, ListView, Text, View } from 'react-native';
import { ScrollView, Linking } from 'react-native';
import Ionicons from 'react-native-vector-icons/Ionicons';
import { SafeAreaView, TabNavigator } from 'react-navigation';
import { Icon, Card, Header, List, ListItem, Avatar } from 'react-native-elements'
import { Icon } from 'react-native-elements';
import {
BlueLoading, BlueSpacing20, BlueList, BlueButton, SafeBlueArea, BlueCard, BlueText, BlueListItem, BlueHeader,
BlueFormInput, BlueSpacing
} from '../BlueComponents'
BlueLoading,
BlueSpacing20,
BlueButton,
SafeBlueArea,
BlueCard,
BlueText,
BlueHeader,
} from '../BlueComponents';
import PropTypes from 'prop-types';
let BlueApp = require('../BlueApp');
export default class Settings extends Component {
static navigationOptions = {
tabBarLabel: 'Settings',
tabBarIcon: ({ tintColor, focused }) => (
@ -21,65 +24,67 @@ export default class Settings extends Component {
style={{ color: tintColor }}
/>
),
}
};
constructor(props) {
super(props);
this.state = {
isLoading: true,
}
};
}
async componentDidMount() {
this.setState({
isLoading: false,
})
});
}
render() {
const {navigate} = this.props.navigation;
if (this.state.isLoading) {
return (
<BlueLoading/>
);
return <BlueLoading />;
}
return (
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{flex: 1}}>
<SafeBlueArea forceInset={{ horizontal: 'always' }} style={{ flex: 1 }}>
<BlueHeader
backgroundColor={BlueApp.settings.brandingColor}
leftComponent={<Icon name='menu' color="#fff" onPress={() => this.props.navigation.navigate('DrawerToggle') }/>}
centerComponent={{ text: 'Settings', style: { color: '#fff', fontSize: 25 }}}
leftComponent={
<Icon
name="menu"
color="#fff"
onPress={() => this.props.navigation.navigate('DrawerToggle')}
/>
}
centerComponent={{
text: 'Settings',
style: { color: '#fff', fontSize: 25 },
}}
/>
<BlueCard>
<ScrollView
maxHeight={450}
>
<ScrollView maxHeight={450}>
<BlueText h1>About</BlueText>
<BlueSpacing20/>
<BlueSpacing20 />
<BlueText h4>Blue Wallet is free and opensource Bitcoin wallet</BlueText>
<BlueText>Warning: Alpha version, don't use to store large amouts!</BlueText>
<BlueText h4>
Blue Wallet is free and opensource Bitcoin wallet
</BlueText>
<BlueText>
Warning: Alpha version, don't use to store large amouts!
</BlueText>
<BlueButton
icon={{name: 'octoface', type: 'octicon'}}
onPress={() =>
{
Linking.openURL("https://github.com/Overtorment/BlueWallet")
}
}
icon={{ name: 'octoface', type: 'octicon' }}
onPress={() => {
Linking.openURL('https://github.com/Overtorment/BlueWallet');
}}
title="github.com/Overtorment/BlueWallet"
/>
<BlueSpacing20/>
<BlueSpacing20 />
<BlueText h4>Licensed MIT</BlueText>
<BlueSpacing20/>
<BlueSpacing20 />
<BlueText h3>Built with awesome:</BlueText>
<BlueSpacing20/>
<BlueSpacing20 />
<BlueText h4>* React Native</BlueText>
<BlueText h4>* Bitcoinjs-lib</BlueText>
<BlueText h4>* blockcypher.com API</BlueText>
@ -89,16 +94,18 @@ export default class Settings extends Component {
<BlueText h4>* rn-nodeify</BlueText>
<BlueText h4>* bignumber.js</BlueText>
<BlueText h4>* https://github.com/StefanoBalocco/isaac.js</BlueText>
<BlueText h4>* Design by https://dribbble.com/chrometaphore</BlueText>
<BlueText h4>
* Design by https://dribbble.com/chrometaphore
</BlueText>
</ScrollView>
</BlueCard>
</SafeBlueArea>
);
}
}
Settings.propTypes = {
navigation: PropTypes.shape({
navigate: PropTypes.func,
}),
};

View file

@ -1,27 +1,29 @@
import React from 'react'
import { StackNavigator } from 'react-navigation'
import { StackNavigator } from 'react-navigation';
import list from './transactions/list'
import details from './transactions/details'
import rbf from './transactions/RBF'
import createrbf from './transactions/RBF-create'
import list from './transactions/list';
import details from './transactions/details';
import rbf from './transactions/RBF';
import createrbf from './transactions/RBF-create';
const TransactionsNavigator = StackNavigator({
TransactionsList: {
screen: list
const TransactionsNavigator = StackNavigator(
{
TransactionsList: {
screen: list,
},
TransactionDetails: {
screen: details,
},
RBF: {
screen: rbf,
},
CreateRBF: {
screen: createrbf,
},
},
TransactionDetails: {
screen: details
{
headerMode: 'none',
mode: 'modal',
},
RBF: {
screen: rbf
},
CreateRBF: {
screen: createrbf
}
}, {
headerMode: 'none',
mode: 'modal'
})
);
export default TransactionsNavigator
export default TransactionsNavigator;

View file

@ -1,35 +1,37 @@
import React, { Component } from 'react'
import { StackNavigator } from 'react-navigation'
import { StackNavigator } from 'react-navigation';
import WalletsList from './wallets/list'
import AddWallet from './wallets/add'
import WalletDetails from './wallets/details'
import WalletExport from './wallets/export'
import scanQrWifLegacyAddress from './wallets/scanQrWifLegacyAddress'
import scanQrWifSegwitP2SHAddress from './wallets/scanQrWifSegwitP2SHAddress'
import WalletsList from './wallets/list';
import AddWallet from './wallets/add';
import WalletDetails from './wallets/details';
import WalletExport from './wallets/export';
import scanQrWifLegacyAddress from './wallets/scanQrWifLegacyAddress';
import scanQrWifSegwitP2SHAddress from './wallets/scanQrWifSegwitP2SHAddress';
const WalletsNavigator = StackNavigator({
WalletsList: {
screen: WalletsList
const WalletsNavigator = StackNavigator(
{
WalletsList: {
screen: WalletsList,
},
AddWallet: {
screen: AddWallet,
},
ScanQrWifLegacyAddress: {
screen: scanQrWifLegacyAddress,
},
ScanQrWifSegwitP2SHAddress: {
screen: scanQrWifSegwitP2SHAddress,
},
WalletDetails: {
screen: WalletDetails,
},
WalletExport: {
screen: WalletExport,
},
},
AddWallet: {
screen: AddWallet
{
headerMode: 'none',
mode: 'modal',
},
ScanQrWifLegacyAddress: {
screen: scanQrWifLegacyAddress
},
ScanQrWifSegwitP2SHAddress: {
screen: scanQrWifSegwitP2SHAddress
},
WalletDetails: {
screen: WalletDetails
},
WalletExport: {
screen: WalletExport
}
}, {
headerMode: 'none',
mode: 'modal'
})
);
export default WalletsNavigator
export default WalletsNavigator;