|
|
|
@ -139,4 +139,33 @@ describe('Carousel', () => {
|
|
|
|
|
expect(container.querySelector('.slick-dots')).toHaveClass('customDots');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should not wait for the animation', async () => {
|
|
|
|
|
const ref = React.createRef<CarouselRef>();
|
|
|
|
|
render(
|
|
|
|
|
<Carousel ref={ref}>
|
|
|
|
|
<div>1</div>
|
|
|
|
|
<div>2</div>
|
|
|
|
|
<div>3</div>
|
|
|
|
|
</Carousel>,
|
|
|
|
|
);
|
|
|
|
|
const { prev, next, goTo } = ref.current || {};
|
|
|
|
|
expect(typeof prev).toBe('function');
|
|
|
|
|
expect(typeof next).toBe('function');
|
|
|
|
|
expect(typeof goTo).toBe('function');
|
|
|
|
|
expect(ref.current?.innerSlider.state.currentSlide).toBe(0);
|
|
|
|
|
ref.current?.goTo(1);
|
|
|
|
|
ref.current?.goTo(2);
|
|
|
|
|
ref.current?.goTo(1);
|
|
|
|
|
await waitFakeTimer();
|
|
|
|
|
expect(ref.current?.innerSlider.state.currentSlide).toBe(1);
|
|
|
|
|
ref.current?.prev();
|
|
|
|
|
ref.current?.next();
|
|
|
|
|
ref.current?.next();
|
|
|
|
|
await waitFakeTimer();
|
|
|
|
|
expect(ref.current?.innerSlider.state.currentSlide).toBe(2);
|
|
|
|
|
ref.current?.prev();
|
|
|
|
|
await waitFakeTimer();
|
|
|
|
|
expect(ref.current?.innerSlider.state.currentSlide).toBe(1);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|