Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/fix bugs found #133

Merged
merged 5 commits into from Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -33,6 +33,7 @@ build/
.gradle
local.properties
*.iml
gradle.properties

# node.js
#
Expand All @@ -47,6 +48,7 @@ buck-out/
\.buckd/
*.keystore


# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
Expand Down
76 changes: 76 additions & 0 deletions __tests__/Views/chats/__snapshots__/home-test.js.snap
@@ -0,0 +1,76 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`test home componente render home component 1`] = `
<Styled(Container)>
<Connect(HeaderComponent)
back={[Function]}
chats={Array []}
contacts={Array []}
delete={[Function]}
deleteChat={[Function]}
navigation={
Object {
"closeDrawer": [MockFunction],
"dismiss": [MockFunction],
"goBack": [MockFunction],
"navigate": [MockFunction],
"openDrawer": [MockFunction] {
"calls": Array [
Array [],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
},
"pop": [MockFunction],
"popToTop": [MockFunction],
"push": [MockFunction],
"replace": [MockFunction],
"reset": [MockFunction],
"setParams": [MockFunction],
"state": Object {
"key": "id-1581513550398-0",
"routeName": "initial",
},
"toggleDrawer": [MockFunction],
}
}
screenProps={
Object {
"t": [Function],
}
}
search={[Function]}
selected={Array []}
selectedChat={[Function]}
store={
Object {
"dispatch": [Function],
"getState": [Function],
"replaceReducer": [Function],
"subscribe": [Function],
Symbol(observable): [Function],
}
}
/>
<Styled(Content) />
<FloatButtons
add={[Function]}
icon={
<Styled(Icon)
name="message"
style={
Object {
"color": "#f5f5f5",
"fontSize": 24,
}
}
type="MaterialIcons"
/>
}
/>
</Styled(Container)>
`;
72 changes: 72 additions & 0 deletions __tests__/Views/chats/home-test.js
@@ -0,0 +1,72 @@
import '../../../__Mocks__';
import React from 'react';
import renderer from 'react-test-renderer';
import { shallow } from 'enzyme';
import { navigationPops } from '../../components/heder-test';
import Home from '../../../src/views/home';
import store from '../../../src/store';


const screenProps = {
t: (data) => data
};

const mockMessage = [{
fromUID: '16Uiu2HAm9JHK1iG6g2nLNw2fmAWerGiVoKMnjcvEs6pJVnd6STPC',
id: 'ad7ae2f9dc672c55095e60f2e8367393261088972af35c49c007be0c642fda24',
msg: 'Hola',
msgID: 'ad7ae2f9dc672c55095e60f2e8367393261088972af35c49c007be0c642fda24',
name: undefined,
shippingTime: 1602013395803,
status: 'pending',
time: 1602013395803,
timestamp: 1602013395786,
toUID: '16Uiu2HAm2BXA1TTUE7vvSu3U4YURxb4FwTYjfrwnZN618jrYBpNS',
type: 1
}];

const mockChat = [{
fromUID: '02ce1eeb78647383eac7998e929aa72240cc3d908f682f0375738330ab128bdea7',
messages: { ...mockMessage },
queue: [],
toUID: '16Uiu2HAm2BXA1TTUE7vvSu3U4YURxb4FwTYjfrwnZN618jrYBpNS'
}];


const mockContact = [{
hashUID: '1ed4091506f77825bccb4dadcf89f1b62ff3257d2afc3886bf859c0330120a27',
name: 'Luis',
nodeAddress: '/ip4/85.53.137.144/tcp/4444',
picture: null,
uid: '16Uiu2HAm2BXA1TTUE7vvSu3U4YURxb4FwTYjfrwnZN618jrYBpNS'
}];

describe('test home componente', () => {
const wrapper = shallow(
<Home
store={store}
screenProps={screenProps}
navigation={navigationPops}
/>
).childAt(0).dive();


test('render home component', () => {
expect(wrapper).toMatchSnapshot();
});


test('set props contacts', () => {
wrapper.setProps({
contacts: mockContact
});
expect(wrapper.instance().props.contacts).toBeDefined();
});

test('set props chat', () => {
wrapper.setProps({
chats: mockChat
});
expect(wrapper.instance().props.chats).toBeDefined();
});
});
Expand Up @@ -267,11 +267,12 @@ public void run() {

timer.schedule( new TimerTask() {
public void run() {
String[] ips = Runtime.getInstance().externalAddresses();

for (String ip : ips) {
event.onExternalAddress(ip);
}
if( Runtime.getInstance().isStarted()) {
String[] ips = Runtime.getInstance().externalAddresses();
for (String ip : ips) {
event.onExternalAddress(ip);
}
}
}
}, 0, RECHARGE_TIME);

Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -11,7 +11,8 @@
"docs": "./node_modules/.bin/jsdoc -c jsdoc.json",
"lint": "eslint '**/*.{js,jsx}' --quiet",
"test": "jest --verbose --runInBand --detectOpenHandles && codecov",
"release": "cd android && ./gradlew assembleRelease"
"release": "cd android && ./gradlew assembleRelease",
"keystore": "cd android && ./keystore.sh"
},
"precommit": "lint --staged",
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/views/LoadWallet/CreateAccount.js
Expand Up @@ -50,7 +50,7 @@ export default class CreateAccount extends Component {
continue = (values) => {
const seed = this.props.phrases.slice();
if (!this.props.restore) {
while (seed.reduce((prev, curr) => prev + +(curr === ''), 0) < 0) {
while (seed.reduce((prev, curr) => prev + +(curr === ''), 6) < 0) {
const k = Math.floor(Math.random() * (seed.length - 1));
seed[k] = '';
}
Expand Down
1 change: 1 addition & 0 deletions src/views/LoadWallet/RestoreWithPin.js
Expand Up @@ -36,6 +36,7 @@ class RestoreWithPin extends Component {
callback();
return;
}
callback();
luisan00 marked this conversation as resolved.
Show resolved Hide resolved
toast(this.props.screenProps.t('Initial:error1'));
});
} else {
Expand Down
11 changes: 4 additions & 7 deletions src/views/home/index.js
Expand Up @@ -52,10 +52,6 @@ class index extends Component {
drawerLabel: 'Home'
};

componentDidMount = () => {
database.realmObservable();
// pendingObservable();
};

selectedChat = (info, obj) => {
if (this.state.selected.length === 0) {
Expand Down Expand Up @@ -182,6 +178,8 @@ class index extends Component {
.includes(this.state.search.toLowerCase())
))
: Object.values(this.props.chats);

console.log("dios123", this.props.chats);
return (
<Container>
<Header
Expand All @@ -201,10 +199,9 @@ class index extends Component {
);
const infoData = this.getContactInformation(chat);
const messages = Object.values(chat.messages);
const lastmessage = this.getDataTypeMessage(messages[messages.length - 1]);

const lasTime = Number(messages[messages.length - 1].timestamp);
if (messages.length !== 0) {
const lastmessage = this.getDataTypeMessage(messages[messages.length - 1]);
const lasTime = Number(messages[messages.length - 1].timestamp);
luisan00 marked this conversation as resolved.
Show resolved Hide resolved
return (
<List key={chat.toUID} style={{ backgroundColor }}>
<ListItem
Expand Down