Skip to content

Commit 01a0e2d

Browse files
committed
test(carousel): add test checks for igcSlideChanged
1 parent c0789bc commit 01a0e2d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/components/carousel/carousel.spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ describe('Carousel', () => {
520520
describe('Interactions', () => {
521521
describe('Click', () => {
522522
it('should change slide when clicking next button', async () => {
523+
const eventSpy = spy(carousel, 'emitEvent');
523524
expect(carousel.current).to.equal(0);
524525
expect(defaultIndicators[0].active).to.be.true;
525526

@@ -529,9 +530,11 @@ describe('Carousel', () => {
529530
expect(carousel.current).to.equal(1);
530531
expect(defaultIndicators[0].active).to.be.false;
531532
expect(defaultIndicators[1].active).to.be.true;
533+
expect(eventSpy.firstCall).calledWith('igcSlideChanged', { detail: 1 });
532534
});
533535

534536
it('should change slide when clicking previous button', async () => {
537+
const eventSpy = spy(carousel, 'emitEvent');
535538
expect(carousel.current).to.equal(0);
536539
expect(defaultIndicators[0].active).to.be.true;
537540

@@ -541,9 +544,11 @@ describe('Carousel', () => {
541544
expect(carousel.current).to.equal(2);
542545
expect(defaultIndicators[0].active).to.be.false;
543546
expect(defaultIndicators[2].active).to.be.true;
547+
expect(eventSpy.firstCall).calledWith('igcSlideChanged', { detail: 2 });
544548
});
545549

546550
it('should change slide when clicking indicators', async () => {
551+
const eventSpy = spy(carousel, 'emitEvent');
547552
expect(carousel.current).to.equal(0);
548553
expect(defaultIndicators[0].active).to.be.true;
549554

@@ -554,6 +559,7 @@ describe('Carousel', () => {
554559
expect(carousel.current).to.equal(1);
555560
expect(defaultIndicators[0].active).to.be.false;
556561
expect(defaultIndicators[1].active).to.be.true;
562+
expect(eventSpy.firstCall).calledWith('igcSlideChanged', { detail: 1 });
557563

558564
// select first slide
559565
simulateClick(defaultIndicators[0]);
@@ -562,6 +568,7 @@ describe('Carousel', () => {
562568
expect(carousel.current).to.equal(0);
563569
expect(defaultIndicators[0].active).to.be.true;
564570
expect(defaultIndicators[1].active).to.be.false;
571+
expect(eventSpy.firstCall).calledWith('igcSlideChanged', { detail: 0 });
565572
});
566573
});
567574

0 commit comments

Comments
 (0)