forked from fga-eps-mds/2017.2-MerendaMais
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fga-eps-mds#175 - Fitting source code to style sheet
- Loading branch information
1 parent
dcf2b4e
commit 22f0cfc
Showing
19 changed files
with
920 additions
and
615 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 |
---|---|---|
@@ -0,0 +1,241 @@ | ||
import React from 'react'; | ||
import Enzyme, { shallow } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import configureStore from 'redux-mock-store'; | ||
import ScheduleMeetingContainer from '../../src/Containers/scheduleMeeting/ScheduleMeetingContainer'; | ||
import ScheduleMeeting from '../../src/screens/scheduleMeeting/ScheduleMeeting'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
const mockStore = configureStore(); | ||
|
||
const initialState = { | ||
application: { | ||
isLoading: false, | ||
}, | ||
counselor: { | ||
profile: { | ||
CAE: 'Distrito Federal', | ||
}, | ||
}, | ||
|
||
schedule: { | ||
codSchool: 0, | ||
meetingLatitude: null, | ||
meetingLongitude: null, | ||
}, | ||
|
||
appToken: 'genericalToken', | ||
nuvemCode: 1, | ||
meeting: { | ||
date: '31-12-2017', | ||
time: '10:00', | ||
lat: 5.00, | ||
long: 13.00, | ||
meetingDescription: '', | ||
}, | ||
|
||
|
||
list: { | ||
listOfCounselorsInAGroup: [ | ||
{ | ||
name: 'Lucas Penido Antunes', | ||
profile: { | ||
cpf: '11111111111', | ||
phone: '11111111111', | ||
}, | ||
}, | ||
], | ||
|
||
meetingListOfInviteesWithCounselorInformations: { | ||
6122: { | ||
nuvemCode: 6122, | ||
name: 'Lucas Penido Antunes', | ||
cpf: '11111111111', | ||
phone: '11111111111', | ||
}, | ||
6201: { | ||
nuvemCode: 6201, | ||
name: 'Kamilla Costa Souzaa', | ||
cpf: '00000000000', | ||
phone: '99999999999', | ||
}, | ||
}, | ||
|
||
meetingListOfInvitees: { | ||
6122: { | ||
nuvemCode: 6122, | ||
confirmed: false, | ||
}, | ||
6201: { | ||
nuvemCode: 6201, | ||
confirmed: false, | ||
}, | ||
}, | ||
}, | ||
asyncGetCounselorFromGroup: jest.fn(), | ||
}; | ||
|
||
const initialStateToScreen = { | ||
counselor: { | ||
token: 'genericalToken', | ||
|
||
profile: { | ||
CAE: 'DF', | ||
}, | ||
}, | ||
|
||
scheduleMeeting: { | ||
codSchool: 0, | ||
meetingLatitude: 0.0, | ||
meetingLongitude: 0.0, | ||
}, | ||
appToken: 'genericalToken', | ||
nuvemCode: 1, | ||
|
||
meeting: { | ||
lat: 5.00, | ||
long: 13.00, | ||
date: '31-10-2017', | ||
time: '19:50', | ||
meetingDescription: '', | ||
}, | ||
|
||
listOfCounselorsInAGroup: [ | ||
{ | ||
name: 'Lucas Penido Antunes', | ||
profile: { | ||
cpf: '11111111111', | ||
phone: '11111111111', | ||
}, | ||
}, | ||
], | ||
|
||
meetingListOfInviteesWithCounselorInformations: { | ||
6122: { | ||
nuvemCode: 6122, | ||
name: 'Lucas Penido Antunes', | ||
cpf: '11111111111', | ||
phone: '11111111111', | ||
}, | ||
6201: { | ||
nuvemCode: 6201, | ||
name: 'Kamilla Costa Souzaa', | ||
cpf: '00000000000', | ||
phone: '99999999999', | ||
}, | ||
}, | ||
|
||
meetingListOfInvitees: { | ||
6122: { | ||
nuvemCode: 6122, | ||
confirmed: false, | ||
}, | ||
6201: { | ||
nuvemCode: 6201, | ||
confirmed: false, | ||
}, | ||
}, | ||
|
||
asyncGetCounselorFromGroup: jest.fn(), | ||
}; | ||
|
||
const store = mockStore(initialState); | ||
|
||
|
||
describe('Testing ScheduleMeeting Screen', () => { | ||
it('renders as expected', () => { | ||
const wrapper = shallow( | ||
<ScheduleMeetingContainer />, | ||
{ context: { store } }, | ||
); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); | ||
|
||
describe('Testing ScheduleMeeting buttons', () => { | ||
it('Test if goToMeetingMaps Button is rendered', () => { | ||
jest.mock('react-native-router-flux'); | ||
const wrapper = shallow(<ScheduleMeeting {...initialStateToScreen} />); | ||
console.log(initialStateToScreen); | ||
const button = wrapper.findWhere(c => c.key() === 'openMeetingMap'); | ||
expect(button.length).toEqual(1); | ||
button.simulate('press'); | ||
}); | ||
|
||
it('Test if openMeetingLocation Button is rendered', () => { | ||
const wrapper = shallow(<ScheduleMeeting {...initialStateToScreen} />); | ||
const button = wrapper.findWhere(c => c.key() === 'openMeetingLocation'); | ||
expect(button.length).toEqual(1); | ||
button.simulate('press'); | ||
}); | ||
|
||
it('Test if inviteCounselors Button is rendered', () => { | ||
const wrapper = shallow(<ScheduleMeeting {...initialStateToScreen} />); | ||
const button = wrapper.findWhere(c => c.key() === 'searchCounselorButton'); | ||
expect(button.length).toEqual(1); | ||
// We are not simulating button press because | ||
// we faced problemns with .show from popUp | ||
// button.simulate('press'); | ||
}); | ||
it('Test if schedule button is rendered', () => { | ||
const asyncSchedulingMeeting = (state) => { | ||
expect(state.nuvemCode).toEqual(1); | ||
expect(state.appToken).toEqual('tokenGenerico'); | ||
expect(state.meeting.date).toEqual('31-12-2017'); | ||
expect(state.meeting.time).toEqual('18:30'); | ||
expect(state.meeting.lat).toEqual(0.00); | ||
expect(state.meeting.long).toEqual(0.00); | ||
}; | ||
|
||
const wrapper = shallow(<ScheduleMeeting | ||
{...initialStateToScreen} | ||
/>); | ||
|
||
wrapper.setState({ | ||
nuvemCode: 1, | ||
token: 'tokenGenerico', | ||
meeting: { | ||
date: '31-12-2017', | ||
time: '18:30', | ||
lat: 0.00, | ||
long: 0.00, | ||
meetingDescription: '', | ||
meetingListOfInvitees: { | ||
6122: { | ||
nuvemCode: 6122, | ||
confirmed: false, | ||
}, | ||
6201: { | ||
nuvemCode: 6201, | ||
confirmed: false, | ||
}, | ||
}, | ||
}, | ||
}); | ||
|
||
const button = wrapper.findWhere(c => c.key() === 'scheduleMeetingButton'); | ||
expect(button.length).toEqual(1); | ||
}); | ||
it('Test if meetingDescription updates', () => { | ||
const wrapper = shallow(<ScheduleMeeting {...initialStateToScreen} />); | ||
const describeInputComponent = wrapper.find('TextInput').at(0); | ||
describeInputComponent.simulate('ChangeText', 'descricao'); | ||
expect(wrapper.state().meeting.meetingDescription).toEqual('descricao'); | ||
}); | ||
}); | ||
|
||
describe('Testing ScheduleMeeting DatePickers', () => { | ||
const wrapper = shallow(<ScheduleMeeting {...initialStateToScreen} />); | ||
|
||
it('Test if date changes when DatePicker changes', () => { | ||
const datePickerComponent = wrapper.find('DatePicker').at(0); | ||
datePickerComponent.simulate('dateChange', '31-10-2017'); | ||
expect(wrapper.state().meeting.date).toEqual('31-10-2017'); | ||
}); | ||
it('Test if time changes when DatePicker changes', () => { | ||
const datePickerComponent = wrapper.find('DatePicker').at(1); | ||
datePickerComponent.simulate('dateChange', '19:50'); | ||
expect(wrapper.state().meeting.time).toEqual('19:50'); | ||
}); | ||
}); |
56 changes: 56 additions & 0 deletions
56
__tests__/screens/__snapshots__/ScheduleMeeting.test.js.snap
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,56 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Testing ScheduleMeeting Screen renders as expected 1`] = ` | ||
<ScheduleMeeting | ||
asyncGetCounselorFromGroup={[Function]} | ||
asyncSchedulingMeeting={[Function]} | ||
counselor={ | ||
Object { | ||
"profile": Object { | ||
"CAE": "Distrito Federal", | ||
}, | ||
} | ||
} | ||
isLoading={false} | ||
listOfCounselorsInAGroup={ | ||
Array [ | ||
Object { | ||
"name": "Lucas Penido Antunes", | ||
"profile": Object { | ||
"cpf": "11111111111", | ||
"phone": "11111111111", | ||
}, | ||
}, | ||
] | ||
} | ||
meetingListOfInvitees={ | ||
Object { | ||
"6122": Object { | ||
"confirmed": false, | ||
"nuvemCode": 6122, | ||
}, | ||
"6201": Object { | ||
"confirmed": false, | ||
"nuvemCode": 6201, | ||
}, | ||
} | ||
} | ||
meetingListOfInviteesWithCounselorInformations={ | ||
Object { | ||
"6122": Object { | ||
"cpf": "11111111111", | ||
"name": "Lucas Penido Antunes", | ||
"nuvemCode": 6122, | ||
"phone": "11111111111", | ||
}, | ||
"6201": Object { | ||
"cpf": "00000000000", | ||
"name": "Kamilla Costa Souzaa", | ||
"nuvemCode": 6201, | ||
"phone": "99999999999", | ||
}, | ||
} | ||
} | ||
setMeetingNewLists={[Function]} | ||
/> | ||
`; |
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,3 @@ | ||
import { AppRegistry } from 'react-native'; | ||
import App from './App'; | ||
AppRegistry.registerComponent('MerendaMais', () => App); |
42 changes: 21 additions & 21 deletions
42
src/Containers/scheduleMeeting/ScheduleMeetingContainer.js
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 |
---|---|---|
@@ -1,27 +1,27 @@ | ||
// import { connect } from 'react-redux'; | ||
// import ScheduleMeeting from '../../screens/scheduleMeeting/ScheduleMeeting'; | ||
// import asyncSchedulingMeeting from '../../actions/schedulingMeetingActions'; | ||
// import { asyncGetCounselorFromGroup, setMeetingNewLists } from '../../actions/listActions'; | ||
import { connect } from 'react-redux'; | ||
import ScheduleMeeting from '../../screens/scheduleMeeting/ScheduleMeeting'; | ||
import asyncSchedulingMeeting from '../../actions/schedulingMeetingActions'; | ||
import { asyncGetCounselorFromGroup, setMeetingNewLists } from '../../actions/listActions'; | ||
|
||
// const mapStateToProps = state => ({ | ||
// isLoading: state.application.isLoading, | ||
// listOfCounselorsInAGroup: state.list.listOfCounselorsInAGroup, | ||
// meetingListOfInviteesWithCounselorInformations: | ||
// state.list.meetingListOfInviteesWithCounselorInformations, | ||
// meetingListOfInvitees: state.list.meetingListOfInvitees, | ||
// counselor: state.counselor, | ||
// scheduleMeeting: state.scheduleMeeting, | ||
// }); | ||
const mapStateToProps = state => ({ | ||
isLoading: state.application.isLoading, | ||
listOfCounselorsInAGroup: state.list.listOfCounselorsInAGroup, | ||
meetingListOfInviteesWithCounselorInformations: | ||
state.list.meetingListOfInviteesWithCounselorInformations, | ||
meetingListOfInvitees: state.list.meetingListOfInvitees, | ||
counselor: state.counselor, | ||
scheduleMeeting: state.scheduleMeeting, | ||
}); | ||
|
||
// const mapDispatchToProps = dispatch => ({ | ||
// asyncGetCounselorFromGroup: (CAE, CPF) => dispatch(asyncGetCounselorFromGroup(CAE, CPF)), | ||
const mapDispatchToProps = dispatch => ({ | ||
asyncGetCounselorFromGroup: (CAE, CPF) => dispatch(asyncGetCounselorFromGroup(CAE, CPF)), | ||
|
||
// asyncSchedulingMeeting: meetingData => dispatch(asyncSchedulingMeeting(meetingData)), | ||
asyncSchedulingMeeting: meetingData => dispatch(asyncSchedulingMeeting(meetingData)), | ||
|
||
// setMeetingNewLists: meetingNewListWithInformations => | ||
// dispatch(setMeetingNewLists(meetingNewListWithInformations)), | ||
// }); | ||
setMeetingNewLists: meetingNewListWithInformations => | ||
dispatch(setMeetingNewLists(meetingNewListWithInformations)), | ||
}); | ||
|
||
// const ScheduleMeetingContainer = connect(mapStateToProps, mapDispatchToProps)(ScheduleMeeting); | ||
const ScheduleMeetingContainer = connect(mapStateToProps, mapDispatchToProps)(ScheduleMeeting); | ||
|
||
// export default ScheduleMeetingContainer; | ||
export default ScheduleMeetingContainer; |
Oops, something went wrong.