feat: Add support for inbound "calls" from triggers (#2500)

This commit is contained in:
Dermot Duffy
2026-06-30 17:45:13 -07:00
committed by dermotduffy
parent f4c686c298
commit 15e335a647
39 changed files with 2915 additions and 133 deletions
+35 -1
View File
@@ -195,13 +195,47 @@ describe('CarouselController', () => {
containScroll: 'trimSnaps',
watchSlides: false,
watchResize: true,
watchDrag: false,
watchDrag: expect.any(Function),
direction: 'rtl',
},
[],
);
});
it('should pass a watchDrag predicate reflecting the current drag state', () => {
const children = createTestSlideNodes();
const root = createRoot();
const parent = createParent({ children: children });
const carousel = new CarouselController(root, parent, { dragEnabled: true });
const emblaOptions = vi.mocked(EmblaCarousel).mock.calls[0][1] as {
watchDrag: () => boolean;
};
expect(emblaOptions.watchDrag()).toBe(true);
carousel.setDragEnabled(false);
expect(emblaOptions.watchDrag()).toBe(false);
carousel.setDragEnabled(true);
expect(emblaOptions.watchDrag()).toBe(true);
});
it('should toggle drag without rebuilding the carousel', () => {
const children = createTestSlideNodes();
const parent = createParent({ children: children });
const carousel = new CarouselController(createRoot(), parent, {
dragEnabled: true,
});
const emblaApi = getEmblaApi();
expect(emblaApi).toBeTruthy();
carousel.setDragEnabled(false);
expect(emblaApi?.reInit).not.toBeCalled();
expect(emblaApi?.destroy).not.toBeCalled();
});
it('should include wheel plugin when slides > 1', () => {
const children = createTestSlideNodes();
const root = createRoot();