Skip to content

Commit

Permalink
Merge pull request #81 from CaronaBoard/your-ride-offer-fix
Browse files Browse the repository at this point in the history
Your ride offer fix
  • Loading branch information
eduardomoroni authored Oct 3, 2017
2 parents f40d29a + 1b1d60e commit fcbd756
Show file tree
Hide file tree
Showing 38 changed files with 479 additions and 351 deletions.
23 changes: 23 additions & 0 deletions __tests__/resources/mocks/firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { firebaseUserFixture } from '../fixtures/firebase'

export const mockCreateUser = jest.fn(() => Promise.resolve(firebaseUserFixture))
export const mockSignInUser = jest.fn(() => Promise.resolve(firebaseUserFixture))

export const authMock = {
signInWithEmailAndPassword: mockSignInUser,
createUserWithEmailAndPassword: mockCreateUser,
signOut: jest.fn(),
fetchProvidersForEmail: jest.fn(),
currentUser: { uid: '12345' },
setPersistence: jest.fn()
}

export const mockUpdate = jest.fn(() => Promise.resolve())
export const databaseMock = {
ref: jest.fn(() => ({
update: mockUpdate,
child: () => ({
once: () => Promise.resolve({ val: jest.fn() })
})
}))
}
3 changes: 2 additions & 1 deletion __tests__/src/modules/rideOffer/components/RideOffer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import { RideOffer } from '../../../../../src/modules/rideOffer/components/RideO
import { rideOfferFixture } from '../../../../resources/fixtures/ride/offer'

const props = {
ride: rideOfferFixture
ride: rideOfferFixture,
onPress: jest.fn()
}

describe('<RideOffer />', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,148 +1,132 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<RideOffer /> Should have a snapshot 1`] = `
<LoadingSpinnerView
isLoading={false}
<TouchableOpacity
activeOpacity={0.2}
focusedOpacity={0.7}
onPress={[Function]}
>
<TouchableOpacity
activeOpacity={0.2}
focusedOpacity={0.7}
onPress={[Function]}
>
<RkCard>
<RkCard>
<View
rkCardContent={true}
>
<View
rkCardContent={true}
style={
Object {
"alignItems": "center",
"flexDirection": "row",
}
}
>
<View
<Icon
allowFontScaling={false}
name="radio-button-unchecked"
size={12}
style={
Object {
"alignItems": "center",
"flexDirection": "row",
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
<Icon
allowFontScaling={false}
name="radio-button-unchecked"
size={12}
style={
Object {
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
PUC
</Text>
</View>
<View
PUC
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flexDirection": "row",
}
}
>
<Icon
allowFontScaling={false}
name="radio-button-unchecked"
size={12}
style={
Object {
"alignItems": "center",
"flexDirection": "row",
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
<Icon
allowFontScaling={false}
name="radio-button-unchecked"
size={12}
style={
Object {
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
Bomfim
</Text>
</View>
Bomfim
</Text>
</View>
</View>
<View
rkCardContent={true}
>
<View
rkCardContent={true}
style={
Object {
"alignItems": "center",
"flexDirection": "row",
}
}
>
<View
<Icon
allowFontScaling={false}
name="today"
size={12}
style={
Object {
"alignItems": "center",
"flexDirection": "row",
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
<Icon
allowFontScaling={false}
name="today"
size={12}
style={
Object {
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
Seg-Sex
</Text>
</View>
<View
Seg-Sex
</Text>
</View>
<View
style={
Object {
"alignItems": "center",
"flexDirection": "row",
}
}
>
<Icon
allowFontScaling={false}
name="schedule"
size={12}
style={
Object {
"alignItems": "center",
"flexDirection": "row",
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
<Icon
allowFontScaling={false}
name="schedule"
size={12}
style={
Object {
"fontSize": 15,
"marginRight": 5,
}
}
/>
<Text
accessible={true}
allowFontScaling={true}
ellipsizeMode="tail"
rkCardText={true}
>
19h
</Text>
</View>
19h
</Text>
</View>
<Icon
allowFontScaling={false}
color="#900"
name="delete-forever"
size={30}
style={
Object {
"alignSelf": "flex-end",
"margin": 10,
}
}
/>
</RkCard>
</TouchableOpacity>
</LoadingSpinnerView>
</View>
</RkCard>
</TouchableOpacity>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ import { YourRideOffersScreen } from '../../../../../src/modules/rideOffer/conta
import { profileFixture } from '../../../../resources/fixtures/user'

const props = {
uid: profileFixture.uid,
uid: profileFixture.contact.uid,
updateYourOffers: jest.fn(),
yourOffers: [],
navigator: {
setOnNavigatorEvent: jest.fn()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<YourRideOffersScreen /> Should have a snapshot 1`] = `
<View
style={
Object {
"flex": 1,
}
}
<LoadingSpinnerView
isLoading={false}
>
<FlatList
data={Array []}
Expand All @@ -28,5 +24,5 @@ exports[`<YourRideOffersScreen /> Should have a snapshot 1`] = `
icon="md-create"
onPress={[Function]}
/>
</View>
</LoadingSpinnerView>
`;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'react-native'
import React from 'react'
import { shallow } from 'enzyme'
import { RideList } from '../../../../../src/modules/rideRequest/containers/RideRequestsListContainer'
import { RideList } from '../../../../../src/modules/rideOffer/containers/RideOffersListContainer'
import { rideOfferFixture } from '../../../../resources/fixtures/ride/offer'

const props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const props = {
navigator: {
setOnNavigatorEvent: jest.fn()
},
updateYourOffers: jest.fn(),
userId: 'someId'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<RideList /> Should have a snapshot 1`] = `
<ListViewMock
dataSource={
ListViewDataSource {
"items": 1,
<LoadingSpinnerView
isLoading={false}
>
<ListViewMock
dataSource={
ListViewDataSource {
"items": 1,
}
}
}
enableEmptySections={true}
renderRow={[Function]}
renderScrollComponent={[Function]}
style={
Object {
"flex": 1,
"paddingTop": 20,
}
}
/>
enableEmptySections={true}
renderRow={[Function]}
renderScrollComponent={[Function]}
/>
</LoadingSpinnerView>
`;
16 changes: 13 additions & 3 deletions __tests__/src/redux/actions/async/RideOfferActions.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { fetchAllRideOffers } from '../../../../../src/redux/actions/index'
import * as FirebaseService from '../../../../../src/services/firebase/index'
import { updateRideOffers } from '../../../../../src/redux/actions/sync/RideOfferActions'
import { rideOfferFixture } from '../../../../resources/fixtures/ride/offer'
import { fetchAllRideOffers, fetchYourRideOffers } from '../../../../../src/redux/actions'
import { updateRideOffers, updateYourRideOffers } from '../../../../../src/redux/actions/sync/RideOfferActions'
import * as FirebaseService from '../../../../../src/services/firebase'
jest.mock('../../../../../src/services/firebase')

describe('RideOffer async actions', () => {
Expand All @@ -16,4 +16,14 @@ describe('RideOffer async actions', () => {

expect(dispatchMock).toHaveBeenCalledWith(expectedAction)
})

it('Should create a thunk for fetching your ride offers', async () => {
FirebaseService.getUserRideOffers = jest.fn(() => rideOfferFixture)

const expectedAction = updateYourRideOffers(rideOfferFixture)
const thunk = fetchYourRideOffers('uid')
await thunk(dispatchMock)

expect(dispatchMock).toHaveBeenCalledWith(expectedAction)
})
})
Loading

0 comments on commit fcbd756

Please sign in to comment.