diff --git a/jest.mocks.js b/jest.mocks.js index c4f7cd4..e2ef93a 100644 --- a/jest.mocks.js +++ b/jest.mocks.js @@ -25,6 +25,7 @@ jest.mock('@fortawesome/react-native-fontawesome', () => ({ size={faIcon.size} style={faIcon.style} type={getIconType(faIcon.icon.prefix)} + transform={faIcon.transform} /> ), })) diff --git a/package.json b/package.json index 9968de7..78cfe75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@observation.org/react-native-components", - "version": "1.58.0", + "version": "1.59.0", "main": "src/index.ts", "repository": "git@github.com:observation/react-native-components.git", "author": "Observation.org", diff --git a/src/components/Icon.tsx b/src/components/Icon.tsx index fa61fe0..a370a13 100644 --- a/src/components/Icon.tsx +++ b/src/components/Icon.tsx @@ -12,18 +12,19 @@ export type IconAppearanceProps = { color?: string size?: number testID?: string + rotation?: number } export type IconProps = IconAppearanceProps & { name: IconName } -export const Icon = ({ name, color, size, testID, style }: IconProps): React.ReactElement => { - const FontAwesomeIconTypeErased = FontAwesomeIcon as unknown as any +export const Icon = ({ name, color, size, testID, style, rotation }: IconProps): React.ReactElement => { const iconStyle = style ?? 'light' const icon = iconStyle === 'light' ? Icons[name].light : Icons[name].solid const iconColor = color ?? theme.color.primary const iconSize = size ?? theme.icon.size.large + const transform = rotation ? { rotate: rotation } : undefined - return + return } diff --git a/src/components/__tests__/Icon.test.tsx b/src/components/__tests__/Icon.test.tsx new file mode 100644 index 0000000..93557fa --- /dev/null +++ b/src/components/__tests__/Icon.test.tsx @@ -0,0 +1,27 @@ +import React from 'react' + +import { render } from '@testing-library/react-native' + +import { Icon } from '../Icon' + +describe('Icon', () => { + test('Light icon', () => { + const { toJSON } = render() + expect(toJSON()).toMatchSnapshot() + }) + + test('Solid icon', () => { + const { toJSON } = render() + expect(toJSON()).toMatchSnapshot() + }) + + test('With color and size', () => { + const { toJSON } = render() + expect(toJSON()).toMatchSnapshot() + }) + + test('With rotation', () => { + const { toJSON } = render() + expect(toJSON()).toMatchSnapshot() + }) +}) diff --git a/src/components/__tests__/__snapshots__/Icon.test.tsx.snap b/src/components/__tests__/__snapshots__/Icon.test.tsx.snap new file mode 100644 index 0000000..17a0e70 --- /dev/null +++ b/src/components/__tests__/__snapshots__/Icon.test.tsx.snap @@ -0,0 +1,42 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Icon Light icon 1`] = ` + +`; + +exports[`Icon Solid icon 1`] = ` + +`; + +exports[`Icon With color and size 1`] = ` + +`; + +exports[`Icon With rotation 1`] = ` + +`;