-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
77ca4a5
commit a4b7c4a
Showing
7 changed files
with
134 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { render } from "@testing-library/react-native"; | ||
import * as Localization from 'expo-localization'; | ||
import * as React from "react"; | ||
import { NumberTextInput } from "./NumberTextInput" | ||
|
||
jest.mock('expo-localization') | ||
|
||
describe('NumberTextInput', () => { | ||
it(`should match snapshot with period decimal locale`, () => { | ||
(Localization as any).decimalSeparator = '.' | ||
const component = ( | ||
<NumberTextInput value={123} editable={true} placeholder='Enter an amount' /> | ||
) | ||
const rendered = render(component) | ||
expect(rendered.toJSON()).toMatchSnapshot() | ||
}) | ||
|
||
it(`should match snapshot with period comma locale`, () => { | ||
(Localization as any).decimalSeparator = ',' | ||
const component = ( | ||
<NumberTextInput value={123} editable={true} placeholder='Enter an amount' /> | ||
) | ||
const rendered = render(component) | ||
expect(rendered.toJSON()).toMatchSnapshot() | ||
}) | ||
|
||
it(`should match snapshot with period unknown locale`, () => { | ||
(Localization as any).decimalSeparator = ' ' | ||
const component = ( | ||
<NumberTextInput value={123} editable={true} placeholder='Enter an amount' /> | ||
) | ||
const rendered = render(component) | ||
expect(rendered.toJSON()).toMatchSnapshot() | ||
}) | ||
}) |
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,15 @@ | ||
import * as Localization from 'expo-localization' | ||
import React from 'react' | ||
import { TextInputProps } from 'react-native' | ||
import { TextInput } from './index' | ||
|
||
export function NumberTextInput (props: React.PropsWithChildren<TextInputProps>): JSX.Element { | ||
const keyboardType = Localization.decimalSeparator === '.' ? 'numeric' : 'default' | ||
return ( | ||
<TextInput | ||
placeholderTextColor='rgba(0, 0, 0, 0.4)' | ||
{...props} | ||
keyboardType={keyboardType} | ||
/> | ||
) | ||
} |
73 changes: 73 additions & 0 deletions
73
app/components/__snapshots__/NumberTextInput.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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