Skip to content

Commit

Permalink
add unit test if Carousel renders children correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
jiji14 committed May 29, 2024
1 parent 3f08b6c commit 1bd1f48
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions www/__tests__/Carousel.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';
import { render } from '@testing-library/react-native';
import { View } from 'react-native';
import Carousel from '../js/components/Carousel';

describe('Carousel component', () => {
const child1 = <View testID="child1">Child 1</View>;
const child2 = <View testID="child2">Child 2</View>;
const cardWidth = 100;
const cardMargin = 10;

it('renders children correctly', () => {
const { getByTestId } = render(
<Carousel cardWidth={cardWidth} cardMargin={cardMargin}>
{child1}
{child2}
</Carousel>,
);

const renderedChild1 = getByTestId('child1');
const renderedChild2 = getByTestId('child2');

expect(renderedChild1).toBeTruthy();
expect(renderedChild2).toBeTruthy();
});
});

0 comments on commit 1bd1f48

Please sign in to comment.