-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Bryce McMath <[email protected]>
- Loading branch information
1 parent
62c13ee
commit 8056c3d
Showing
11 changed files
with
142 additions
and
61 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react' | ||
import { Text, StyleSheet, TextStyle, TextProps } from 'react-native' | ||
|
||
import { useTheme } from '../../contexts/theme' | ||
import { testIdForAccessabilityLabel, testIdWithKey } from '../../utils/testable' | ||
|
||
interface LinkProps { | ||
linkText: string | ||
style?: TextStyle | ||
textProps?: TextProps | ||
onPress: () => void | ||
} | ||
|
||
const Link: React.FC<LinkProps> = ({ linkText, onPress, style = {}, ...textProps }) => { | ||
const { TextTheme, ColorPallet } = useTheme() | ||
const styles = StyleSheet.create({ | ||
link: { | ||
...TextTheme.normal, | ||
color: ColorPallet.brand.link, | ||
textDecorationLine: 'underline', | ||
alignSelf: 'flex-start', | ||
}, | ||
}) | ||
return ( | ||
<Text | ||
style={[styles.link, style]} | ||
accessibilityLabel={linkText} | ||
accessible | ||
accessibilityRole={'link'} | ||
testID={testIdWithKey(testIdForAccessabilityLabel(linkText))} | ||
onPress={onPress} | ||
{...textProps} | ||
> | ||
{linkText} | ||
</Text> | ||
) | ||
} | ||
|
||
export default Link |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { render, fireEvent } from '@testing-library/react-native' | ||
import React from 'react' | ||
|
||
import Link from '../../App/components/texts/Link' | ||
import { testIdWithKey } from '../../App/utils/testable' | ||
|
||
describe('Link Component', () => { | ||
test('Renders correctly, testID exists, and is pressable', async () => { | ||
const onPress = jest.fn() | ||
const tree = render(<Link linkText={'my link'} onPress={onPress} />) | ||
const link = tree.getByTestId(testIdWithKey('MyLink')) | ||
fireEvent(link, 'press') | ||
expect(onPress).toBeCalledTimes(1) | ||
expect(tree).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
37 changes: 37 additions & 0 deletions
37
packages/legacy/core/__tests__/components/__snapshots__/Link.test.tsx.snap
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,37 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Link Component Renders correctly, testID exists, and is pressable 1`] = ` | ||
<Text | ||
accessibilityLabel="my link" | ||
accessibilityRole="link" | ||
accessible={true} | ||
onPress={ | ||
[MockFunction] { | ||
"calls": Array [ | ||
Array [], | ||
], | ||
"results": Array [ | ||
Object { | ||
"type": "return", | ||
"value": undefined, | ||
}, | ||
], | ||
} | ||
} | ||
style={ | ||
Array [ | ||
Object { | ||
"alignSelf": "flex-start", | ||
"color": "#FFFFFF", | ||
"fontSize": 18, | ||
"fontWeight": "normal", | ||
"textDecorationLine": "underline", | ||
}, | ||
Object {}, | ||
] | ||
} | ||
testID="com.ariesbifold:id/MyLink" | ||
> | ||
my link | ||
</Text> | ||
`; |
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