-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance Testing and Refactor RedirectWithAnimation for Improved Testa…
…bility (#7) * test: enhance unit tests for Button, FlatList, and add BaseScreen.test * feat: enhance RedirectWithAnimation template for better testability - Extracted BackHandler logic to a custom hook: useBackHandler * test: add unit test for RedirectWithAnimation template * test: improve unit tests for Input molecule - Added edge case coverage for `value` prop
- Loading branch information
1 parent
39b7a18
commit 42d613c
Showing
19 changed files
with
733 additions
and
82 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
33 changes: 33 additions & 0 deletions
33
src/components/atoms/FlatList/__snapshots__/FlatList.test.js.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,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`FlatList Component renders correctly with default props (snapshot) 1`] = ` | ||
<RCTScrollView | ||
data={[]} | ||
getItem={[Function]} | ||
getItemCount={[Function]} | ||
initialNumToRender={10} | ||
keyExtractor={[Function]} | ||
maxToRenderPerBatch={5} | ||
onContentSizeChange={[Function]} | ||
onLayout={[Function]} | ||
onMomentumScrollBegin={[Function]} | ||
onMomentumScrollEnd={[Function]} | ||
onScroll={[Function]} | ||
onScrollBeginDrag={[Function]} | ||
onScrollEndDrag={[Function]} | ||
removeClippedSubviews={true} | ||
renderItem={[Function]} | ||
scrollEventThrottle={0.0001} | ||
stickyHeaderIndices={[]} | ||
style={ | ||
{ | ||
"backgroundColor": "white", | ||
} | ||
} | ||
testID="custom-flatlist" | ||
viewabilityConfigCallbackPairs={[]} | ||
windowSize={10} | ||
> | ||
<View /> | ||
</RCTScrollView> | ||
`; |
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,49 @@ | ||
import React from 'react'; | ||
import { screen } from '@testing-library/react-native'; | ||
import { renderInThemeProvider } from '../../../../__tests__/utils/renderInThemeProvider'; | ||
import Screen from '.'; | ||
import Text from '../../atoms/Text'; | ||
|
||
describe('<Screen />', () => { | ||
it('renders correctly and matches the snapshot', () => { | ||
const { toJSON } = renderInThemeProvider( | ||
<Screen> | ||
<Text>Test Content</Text> | ||
</Screen>, | ||
); | ||
|
||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders children correctly', () => { | ||
renderInThemeProvider( | ||
<Screen> | ||
<Text>Test Content</Text> | ||
</Screen>, | ||
); | ||
|
||
expect(screen.getByText('Test Content')).toBeTruthy(); | ||
}); | ||
|
||
it('applies styles from the theme correctly', () => { | ||
const theme = { | ||
colors: { background: 'blue' }, | ||
}; | ||
|
||
renderInThemeProvider( | ||
<Screen testID="base-screen"> | ||
<Text>Styled Content</Text> | ||
</Screen>, | ||
theme, | ||
); | ||
|
||
const baseScreen = screen.getByTestId('base-screen'); | ||
|
||
expect(baseScreen.props.style).toEqual( | ||
expect.objectContaining({ | ||
flex: 1, | ||
backgroundColor: 'blue', | ||
}), | ||
); | ||
}); | ||
}); |
Oops, something went wrong.