-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Showing
9 changed files
with
866 additions
and
331 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
app/component-library/components-temp/Price/PercentageChange/PercentageChange.test.tsx
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,42 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react-native'; | ||
import PercentageChange from './PercentageChange'; | ||
import { mockTheme } from '../../../../util/theme'; | ||
|
||
describe('PercentageChange', () => { | ||
it('should render correctly', () => { | ||
const { toJSON } = render(<PercentageChange value={5.5} />); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
it('displays a positive value correctly', () => { | ||
const { getByText } = render(<PercentageChange value={5.5} />); | ||
const positiveText = getByText('+5.50%'); | ||
expect(positiveText).toBeTruthy(); | ||
expect(positiveText.props.style).toMatchObject({ | ||
color: mockTheme.colors.success.default, | ||
textTransform: 'uppercase', | ||
}); | ||
}); | ||
|
||
it('displays a negative value correctly', () => { | ||
const { getByText } = render(<PercentageChange value={-3.25} />); | ||
const negativeText = getByText('-3.25%'); | ||
expect(negativeText).toBeTruthy(); | ||
expect(negativeText.props.style).toMatchObject({ | ||
color: mockTheme.colors.error.default, | ||
textTransform: 'uppercase', | ||
}); | ||
}); | ||
|
||
it('handles null value correctly', () => { | ||
const { queryByText } = render(<PercentageChange value={null} />); | ||
expect(queryByText(/\+/)).toBeNull(); | ||
expect(queryByText(/-/)).toBeNull(); | ||
}); | ||
|
||
it('handles undefined value correctly', () => { | ||
const { queryByText } = render(<PercentageChange value={undefined} />); | ||
expect(queryByText(/\+/)).toBeNull(); | ||
expect(queryByText(/-/)).toBeNull(); | ||
}); | ||
}); |
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
22 changes: 22 additions & 0 deletions
22
...brary/components-temp/Price/PercentageChange/__snapshots__/PercentageChange.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,22 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PercentageChange should render correctly 1`] = ` | ||
<View> | ||
<Text | ||
accessibilityRole="text" | ||
style={ | ||
{ | ||
"color": "#1C8234", | ||
"fontFamily": "EuclidCircularB-Regular", | ||
"fontSize": 14, | ||
"fontWeight": "400", | ||
"letterSpacing": 0, | ||
"lineHeight": 22, | ||
"textTransform": "uppercase", | ||
} | ||
} | ||
> | ||
+5.50% | ||
</Text> | ||
</View> | ||
`; |
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
Oops, something went wrong.