Skip to content

Commit 956b275

Browse files
committed
format
1 parent 4dea65a commit 956b275

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/components/carousel/__tests__/index.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {Text, View} from 'react-native';
55
import {Constants} from '../../../helpers';
66
import Carousel from '../index';
77

8-
98
const numberOfPagesShown = 5;
109
const eventData = {
1110
nativeEvent: {
@@ -46,17 +45,19 @@ describe('Carousel tests', () => {
4645
</Page>
4746
))}
4847
</Carousel>);
48+
4949
component.getByText('Page #0'); // Validates that the text is there
5050
});
5151

5252
it('should trigger onScroll from the second scroll', () => {
5353
const component = render(<Carousel {...props}>
5454
{map([...Array(numberOfPagesShown)], (_, index) => (
5555
<Page key={index}>
56-
<Text>Page #{index}</Text>
56+
<Text testID={`page-${index}`}>Page #{index}</Text>
5757
</Page>
5858
))}
5959
</Carousel>);
60+
6061
const scrollView = component.getByTestId('carousel.scrollView');
6162

6263
fireEvent.scroll(scrollView, eventData); //NOTE: first scroll will no fire onScroll
@@ -70,17 +71,18 @@ describe('Carousel tests', () => {
7071
const component = render(<Carousel {...props}>
7172
{map([...Array(numberOfPagesShown)], (_, index) => (
7273
<Page key={index}>
73-
<Text>Page #{index}</Text>
74+
<Text testID={`page-${index}`}>Page #{index}</Text>
7475
</Page>
7576
))}
7677
</Carousel>);
78+
7779
const scrollView = component.getByTestId('carousel.scrollView');
7880

7981
fireEvent.scroll(scrollView, eventData); //NOTE: first scroll will no fire onScroll
8082
fireEvent.scroll(scrollView, eventData);
8183
expect(onChangePageMock).not.toHaveBeenCalled();
82-
83-
await new Promise((r) => setTimeout(r, 2000));
84+
85+
await new Promise(r => setTimeout(r, 2000));
8486
fireEvent(scrollView, 'onMomentumScrollEnd', eventData);
8587
expect(onChangePageMock).toHaveBeenCalled();
8688
expect(onChangePageMock).toHaveBeenCalledWith(1, 0, {isAutoScrolled: false});

0 commit comments

Comments
 (0)