@@ -14,21 +14,27 @@ describe('The Carousel class', () => {
1414 expect ( carousel . isVertical ) . toBe ( true ) ;
1515 } ) ;
1616
17- it ( 'should emit go-to and progress events' , async ( ) => {
18- const div = h ( 'div' ) ;
17+ it ( 'should emit index and progress events' , async ( ) => {
18+ const items = [
19+ h ( 'div' , { dataComponent : 'CarouselItem' } ) ,
20+ h ( 'div' , { dataComponent : 'CarouselItem' } ) ,
21+ ] ;
22+ const wrapper = h ( 'div' , { dataComponent : 'CarouselWrapper' } , items ) ;
23+ const div = h ( 'div' , [ wrapper ] ) ;
1924 const carousel = new Carousel ( div ) ;
20- const goToFn = vi . fn ( ) ;
25+ await mount ( carousel ) ;
26+ const indexFn = vi . fn ( ) ;
2127 const progressFn = vi . fn ( ) ;
22- carousel . $on ( 'go-to ' , goToFn ) ;
28+ carousel . $on ( 'index ' , indexFn ) ;
2329 carousel . $on ( 'progress' , progressFn ) ;
2430 carousel . goTo ( 0 ) ;
25- expect ( goToFn ) . toHaveBeenCalledOnce ( ) ;
26- expect ( goToFn . mock . lastCall [ 0 ] . detail ) . toEqual ( [ 0 ] ) ;
31+ expect ( indexFn ) . toHaveBeenCalledOnce ( ) ;
32+ expect ( indexFn . mock . lastCall [ 0 ] . detail ) . toEqual ( [ 0 ] ) ;
2733 await wait ( ) ;
2834 expect ( progressFn ) . toHaveBeenCalledOnce ( ) ;
2935 progressFn . mockClear ( ) ;
3036 carousel . goTo ( 1 ) ;
31- expect ( goToFn . mock . lastCall [ 0 ] . detail ) . toEqual ( [ 1 ] ) ;
37+ expect ( indexFn . mock . lastCall [ 0 ] . detail ) . toEqual ( [ 1 ] ) ;
3238 } ) ;
3339
3440 it ( 'should implement an indexable API' , async ( ) => {
@@ -43,28 +49,28 @@ describe('The Carousel class', () => {
4349 const carousel = new Carousel ( div ) ;
4450 await mount ( carousel ) ;
4551
46- expect ( carousel . index ) . toBe ( 0 ) ;
52+ expect ( carousel . currentIndex ) . toBe ( 0 ) ;
4753 expect ( carousel . prevIndex ) . toBe ( 0 ) ;
4854 expect ( carousel . nextIndex ) . toBe ( 1 ) ;
4955 expect ( carousel . lastIndex ) . toBe ( 3 ) ;
5056
5157 carousel . goTo ( 1 ) ;
5258
53- expect ( carousel . index ) . toBe ( 1 ) ;
59+ expect ( carousel . currentIndex ) . toBe ( 1 ) ;
5460 expect ( carousel . prevIndex ) . toBe ( 0 ) ;
5561 expect ( carousel . nextIndex ) . toBe ( 2 ) ;
5662 expect ( carousel . lastIndex ) . toBe ( 3 ) ;
5763
5864 carousel . goNext ( ) ;
5965
60- expect ( carousel . index ) . toBe ( 2 ) ;
66+ expect ( carousel . currentIndex ) . toBe ( 2 ) ;
6167 expect ( carousel . prevIndex ) . toBe ( 1 ) ;
6268 expect ( carousel . nextIndex ) . toBe ( 3 ) ;
6369 expect ( carousel . lastIndex ) . toBe ( 3 ) ;
6470
6571 carousel . goPrev ( ) ;
6672
67- expect ( carousel . index ) . toBe ( 1 ) ;
73+ expect ( carousel . currentIndex ) . toBe ( 1 ) ;
6874 expect ( carousel . prevIndex ) . toBe ( 0 ) ;
6975 expect ( carousel . nextIndex ) . toBe ( 2 ) ;
7076 expect ( carousel . lastIndex ) . toBe ( 3 ) ;
@@ -75,14 +81,14 @@ describe('The Carousel class', () => {
7581 const carousel = new Carousel ( div ) ;
7682 const spy = vi . spyOn ( carousel , 'goTo' ) ;
7783 await mount ( carousel ) ;
78- expect ( spy ) . toHaveBeenCalledExactlyOnceWith ( carousel . index ) ;
84+ expect ( spy ) . toHaveBeenCalledExactlyOnceWith ( carousel . currentIndex ) ;
7985 } ) ;
8086
8187 it ( 'should go to the current index on resize' , async ( ) => {
8288 const div = h ( 'div' ) ;
8389 const carousel = new Carousel ( div ) ;
8490 const spy = vi . spyOn ( carousel , 'goTo' ) ;
8591 carousel . resized ( ) ;
86- expect ( spy ) . toHaveBeenCalledExactlyOnceWith ( carousel . index ) ;
92+ expect ( spy ) . toHaveBeenCalledExactlyOnceWith ( carousel . currentIndex ) ;
8793 } ) ;
8894} ) ;
0 commit comments