Skip to content

Commit

Permalink
Add test for carousel item href
Browse files Browse the repository at this point in the history
  • Loading branch information
tcbegley committed Sep 4, 2023
1 parent 36784ca commit ad06f78
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/components/carousel/__tests__/Carousel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('Carousel', () => {

test('tracks most recently clicked slide with "active_index" prop', () => {
const mockSetProps = jest.fn();
const {container, getByText, rerender} = render(
const {container} = render(
<Carousel items={slides} setProps={mockSetProps} active_index={0} />
);

Expand All @@ -63,4 +63,18 @@ describe('Carousel', () => {
expect(mockSetProps.mock.calls).toHaveLength(1);
expect(mockSetProps.mock.calls[0][0].active_index).toBe(1);
});

test('carousel item accepts href', () => {
const linkedSlides = [
{key: '0', src: '', alt: 'z', href: '/test'},
...slides
];

const carousel = render(<Carousel items={linkedSlides} />);
const {firstChild: carouselItem} = carousel.container.querySelector(
'.carousel-inner'
);
expect(carouselItem).toHaveAttribute('href', '/test');
expect(carouselItem.tagName.toLowerCase()).toEqual('a');
});
});

0 comments on commit ad06f78

Please sign in to comment.