diff --git a/packages/core/src/components/carousel/carousel.spec.ts b/packages/core/src/components/carousel/carousel.spec.ts index 682bf44af..5a8ed6956 100644 --- a/packages/core/src/components/carousel/carousel.spec.ts +++ b/packages/core/src/components/carousel/carousel.spec.ts @@ -171,11 +171,17 @@ describe('AtomCarousel', () => { '.navigation--next' ) as HTMLElement - nextButton?.click() + const prevButton = page.root?.shadowRoot?.querySelector( + '.navigation--prev' + ) as HTMLElement + nextButton?.click() await page.waitForChanges() - expect(page?.rootInstance.currentIdx).toBe(1) + + prevButton?.click() + await page.waitForChanges() + expect(page?.rootInstance.currentIdx).toBe(0) }) it('should working with loop', async () => { diff --git a/packages/core/src/components/carousel/carousel.tsx b/packages/core/src/components/carousel/carousel.tsx index a4a486fb3..42e8ab807 100644 --- a/packages/core/src/components/carousel/carousel.tsx +++ b/packages/core/src/components/carousel/carousel.tsx @@ -24,7 +24,7 @@ export class AtomCarousel { } set currentIndex(value: number) { - if (!this.carouselWrapper || !value) return + if (!this.carouselWrapper) return this.currentIdx = value this.carouselWrapper.style.transform = `translateX(-${this.currentIndex * 100}%)`