diff --git a/package.json b/package.json
index cba28f6..50fedb1 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@observation.org/react-native-components",
- "version": "1.93.0",
+ "version": "1.94.0",
"main": "src/index.ts",
"exports": {
".": "./src/index.ts",
diff --git a/src/components/IconText.tsx b/src/components/IconText.tsx
index 552295b..176d403 100644
--- a/src/components/IconText.tsx
+++ b/src/components/IconText.tsx
@@ -1,6 +1,7 @@
import React from 'react'
import { StyleProp, StyleSheet, Text, TextStyle, TouchableOpacity, View, ViewStyle } from 'react-native'
+import CapitalizeText from './CapitalizeText'
import { Theme, useStyles } from '../theme'
type IconTextStyle = {
@@ -15,17 +16,20 @@ type Props = {
style: IconTextStyle
onPress?: () => void
singleLineText?: boolean
+ capitalize?: boolean
}
-const IconText = ({ icon, text, style, onPress, singleLineText = false }: Props) => {
+const IconText = ({ icon, text, style, onPress, singleLineText = false, capitalize = false }: Props) => {
const styles = useStyles(createStyles)
+ const TextComponent = capitalize ? CapitalizeText : Text
+
const content = (
{icon}
-
+
{text}
-
+
)
diff --git a/src/components/__tests__/IconText.test.tsx b/src/components/__tests__/IconText.test.tsx
new file mode 100644
index 0000000..06e6a21
--- /dev/null
+++ b/src/components/__tests__/IconText.test.tsx
@@ -0,0 +1,46 @@
+import React from 'react'
+import { Text } from 'react-native'
+
+import { describe, expect, jest, test } from '@jest/globals'
+import { fireEvent, render } from '@testing-library/react-native'
+
+import IconText from '../IconText'
+
+describe('IconText', () => {
+ const icon = icon
+
+ describe('Rendering', () => {
+ test('With content', () => {
+ const { toJSON } = render()
+
+ expect(toJSON()).toMatchSnapshot()
+ })
+
+ test('Single line text', () => {
+ const { toJSON } = render()
+
+ expect(toJSON()).toMatchSnapshot()
+ })
+
+ test('Capitalize text', () => {
+ const { toJSON, queryByText } = render()
+
+ expect(queryByText('Some text')).toBeTruthy()
+ expect(toJSON()).toMatchSnapshot()
+ })
+ })
+
+ describe('Interaction', () => {
+ test('Click', async () => {
+ // GIVEN
+ const onPress = jest.fn()
+ const { getByText } = render()
+
+ // WHEN
+ await fireEvent.press(getByText('Some text'))
+
+ // THEN
+ expect(onPress).toHaveBeenCalledTimes(1)
+ })
+ })
+})
diff --git a/src/components/__tests__/__snapshots__/IconText.test.tsx.snap b/src/components/__tests__/__snapshots__/IconText.test.tsx.snap
new file mode 100644
index 0000000..1012e5b
--- /dev/null
+++ b/src/components/__tests__/__snapshots__/IconText.test.tsx.snap
@@ -0,0 +1,125 @@
+// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
+
+exports[`IconText Rendering Capitalize text 1`] = `
+
+
+
+ icon
+
+
+
+ Some text
+
+
+`;
+
+exports[`IconText Rendering Single line text 1`] = `
+
+
+
+ icon
+
+
+
+ Some text
+
+
+`;
+
+exports[`IconText Rendering With content 1`] = `
+
+
+
+ icon
+
+
+
+ Some text
+
+
+`;