-
-
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.
- Loading branch information
Showing
4 changed files
with
204 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<MirrorLists /> should renders correctly 1`] = ` | ||
<View | ||
style={ | ||
Array [ | ||
Object { | ||
"flex": 1, | ||
"flexDirection": "column", | ||
}, | ||
] | ||
} | ||
> | ||
<RCTScrollView | ||
decelerationRate="fast" | ||
horizontal={true} | ||
onMomentumScrollEnd={[Function]} | ||
onScroll={[Function]} | ||
onScrollBeginDrag={[Function]} | ||
scrollEventThrottle={1} | ||
showsHorizontalScrollIndicator={false} | ||
snapToInterval={0} | ||
style={ | ||
Object { | ||
"flexGrow": 0, | ||
} | ||
} | ||
> | ||
<View> | ||
<View | ||
style={ | ||
Object { | ||
"width": 375, | ||
} | ||
} | ||
/> | ||
<View | ||
onLayout={[Function]} | ||
> | ||
<Image | ||
source={ | ||
Object { | ||
"uri": "https://avatars.githubusercontent.com/u/42688281?v=4", | ||
} | ||
} | ||
style={ | ||
Object { | ||
"borderRadius": 32, | ||
"height": 64, | ||
"marginHorizontal": 12, | ||
"marginVertical": 8, | ||
"width": 64, | ||
} | ||
} | ||
/> | ||
</View> | ||
<View | ||
style={ | ||
Object { | ||
"width": 375, | ||
} | ||
} | ||
/> | ||
</View> | ||
</RCTScrollView> | ||
<RCTScrollView | ||
decelerationRate="fast" | ||
onLayout={[Function]} | ||
onMomentumScrollEnd={[Function]} | ||
onScroll={[Function]} | ||
onScrollBeginDrag={[Function]} | ||
scrollEventThrottle={1} | ||
snapToInterval={0} | ||
style={ | ||
Object { | ||
"flex": 1, | ||
} | ||
} | ||
> | ||
<View> | ||
<View | ||
style={ | ||
Object { | ||
"height": 0, | ||
} | ||
} | ||
> | ||
<Text> | ||
This guy is really amazing | ||
</Text> | ||
</View> | ||
</View> | ||
</RCTScrollView> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,72 @@ | ||
it.todo('write a test'); | ||
import React from 'react'; | ||
import { Image, Text } from 'react-native'; | ||
import { render } from '@testing-library/react-native'; | ||
|
||
import { MirrorLists } from '../index'; | ||
|
||
describe('<MirrorLists />', () => { | ||
test('should renders correctly', () => { | ||
const mockedData = [ | ||
{ | ||
id: Math.random(), | ||
image: 'https://avatars.githubusercontent.com/u/42688281?v=4', | ||
description: 'This guy is really amazing', | ||
}, | ||
]; | ||
|
||
const container = render( | ||
<MirrorLists | ||
data={mockedData} | ||
keyExtractor={({ item }) => item.id.toString()} | ||
horizontalRenderItem={({ item }) => ( | ||
<Image | ||
source={{ uri: item.image }} | ||
style={{ | ||
width: 64, | ||
height: 64, | ||
marginHorizontal: 12, | ||
marginVertical: 8, | ||
borderRadius: 32, | ||
}} | ||
/> | ||
)} | ||
verticalRenderItem={({ item }) => <Text>{item.description}</Text>} | ||
/> | ||
); | ||
expect(container).toMatchSnapshot(); | ||
}); | ||
|
||
test('should renders correctly with image and description', () => { | ||
const mockedData = [ | ||
{ | ||
id: 1, | ||
image: 'https://avatars.githubusercontent.com/u/42688281?v=4', | ||
description: 'This guy is really amazing', | ||
}, | ||
]; | ||
|
||
const container = render( | ||
<MirrorLists | ||
data={mockedData} | ||
keyExtractor={({ item }) => item.id.toString()} | ||
horizontalRenderItem={({ item }) => ( | ||
<Image | ||
testID="avatar" | ||
source={{ uri: item.image }} | ||
style={{ | ||
width: 64, | ||
height: 64, | ||
marginHorizontal: 12, | ||
marginVertical: 8, | ||
borderRadius: 32, | ||
}} | ||
/> | ||
)} | ||
verticalRenderItem={({ item }) => <Text>{item.description}</Text>} | ||
/> | ||
); | ||
|
||
expect(container.getByTestId('avatar')).toBeTruthy(); | ||
expect(container.getByText('This guy is really amazing')).toBeTruthy(); | ||
}); | ||
}); |
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