Skip to content

Commit

Permalink
[wallet] Fixed Native phone picker Use native API instead (#1669)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinvol committed Nov 12, 2019
1 parent 110f856 commit 6bca7c3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
10 changes: 4 additions & 6 deletions packages/react-components/components/PhoneNumberInput.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import PhoneNumberInput from '@celo/react-components/components/PhoneNumberInput'
import { shallow } from 'enzyme'
import * as React from 'react'
import { Platform } from 'react-native'
import { fireEvent, render } from 'react-native-testing-library'

jest.mock('@celo/react-native-sms-retriever', () => {
Expand All @@ -9,12 +10,6 @@ jest.mock('@celo/react-native-sms-retriever', () => {
}
})

jest.mock('react-native-device-info', () => {
return {
getBaseOs: jest.fn(() => 'Android'),
}
})

describe('PhoneNumberInput', () => {
describe('when defaultCountry is falsy', () => {
it('renders an AutoComplete and a country can be selected', () => {
Expand Down Expand Up @@ -54,6 +49,9 @@ describe('when defaultCountry is truthy', () => {

describe('Native phone picker (Android)', () => {
it('can read phone', async () => {
// mock
Platform.OS = 'android'

const wrapper = shallow<PhoneNumberInput>(
<PhoneNumberInput
setE164Number={jest.fn()}
Expand Down
4 changes: 1 addition & 3 deletions packages/react-components/components/PhoneNumberInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { getRegionCodeFromCountryCode, parsePhoneNumber } from '@celo/utils/src/
import * as React from 'react'
import { Platform, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import Autocomplete from 'react-native-autocomplete-input'
import DeviceInfo from 'react-native-device-info'

const TAG = 'PhoneNumberInput'

Expand Down Expand Up @@ -97,8 +96,7 @@ export default class PhoneNumberInput extends React.Component<Props, State> {

async triggerPhoneNumberRequest() {
try {
const baseOS = await DeviceInfo.getBaseOs()
if (baseOS === 'Android') {
if (Platform.OS === 'android') {
await this.triggerPhoneNumberRequestAndroid()
} else {
console.info(`${TAG}/triggerPhoneNumberRequest`, 'Not implemented in this platform')
Expand Down

0 comments on commit 6bca7c3

Please sign in to comment.