@@ -2,52 +2,52 @@ import * as uut from '../CarouselPresenter';
2
2
3
3
describe ( 'Carousel presenter' , ( ) => {
4
4
it ( 'should getChildrenLength' , ( ) => {
5
- expect ( uut . getChildrenLength ( { children : [ { } , { } , { } ] } ) ) . toBe ( 3 ) ;
6
- expect ( uut . getChildrenLength ( { children : [ { } ] } ) ) . toBe ( 1 ) ;
7
- expect ( uut . getChildrenLength ( { } ) ) . toBe ( 0 ) ;
5
+ expect ( uut . getChildrenLength ( { migrate : true , children : [ { } , { } , { } ] } ) ) . toBe ( 3 ) ;
6
+ expect ( uut . getChildrenLength ( { migrate : true , children : [ { } ] } ) ) . toBe ( 1 ) ;
7
+ expect ( uut . getChildrenLength ( { migrate : true } ) ) . toBe ( 0 ) ;
8
8
} ) ;
9
9
10
10
describe ( 'calcOffset' , ( ) => {
11
11
it ( 'should calcOffset (default mode)' , ( ) => {
12
- expect ( uut . calcOffset ( { pageWidth : 120 , children : [ { } , { } , { } ] } , { currentPage : 0 } ) ) . toBe ( 0 ) ;
13
- expect ( uut . calcOffset ( { pageWidth : 120 , children : [ { } , { } , { } ] } , { currentPage : 1 } ) ) . toBe ( 120 ) ;
14
- expect ( uut . calcOffset ( { pageWidth : 120 , children : [ { } , { } , { } ] } , { currentPage : 2 } ) ) . toBe ( 240 ) ;
12
+ expect ( uut . calcOffset ( { migrate : true , children : [ { } , { } , { } ] } , { pageWidth : 120 , currentPage : 0 } ) ) . toBe ( 0 ) ;
13
+ expect ( uut . calcOffset ( { migrate : true , children : [ { } , { } , { } ] } , { pageWidth : 120 , currentPage : 1 } ) ) . toBe ( 120 ) ;
14
+ expect ( uut . calcOffset ( { migrate : true , children : [ { } , { } , { } ] } , { pageWidth : 120 , currentPage : 2 } ) ) . toBe ( 240 ) ;
15
15
} ) ;
16
16
17
17
it ( 'should calcOffset (loop mode)' , ( ) => {
18
- expect ( uut . calcOffset ( { loop : true , pageWidth : 120 , children : [ { } , { } , { } ] } , { currentPage : 0 } ) ) . toBe ( 120 ) ;
19
- expect ( uut . calcOffset ( { loop : true , pageWidth : 120 , children : [ { } , { } , { } ] } , { currentPage : 1 } ) ) . toBe ( 240 ) ;
20
- expect ( uut . calcOffset ( { loop : true , pageWidth : 120 , children : [ { } , { } , { } ] } , { currentPage : 2 } ) ) . toBe ( 360 ) ;
18
+ expect ( uut . calcOffset ( { migrate : true , loop : true , children : [ { } , { } , { } ] } , { pageWidth : 120 , currentPage : 0 } ) ) . toBe ( 120 ) ;
19
+ expect ( uut . calcOffset ( { migrate : true , loop : true , children : [ { } , { } , { } ] } , { pageWidth : 120 , currentPage : 1 } ) ) . toBe ( 240 ) ;
20
+ expect ( uut . calcOffset ( { migrate : true , loop : true , children : [ { } , { } , { } ] } , { pageWidth : 120 , currentPage : 2 } ) ) . toBe ( 360 ) ;
21
21
} ) ;
22
22
} ) ;
23
23
24
24
describe ( 'calcPageIndex' , ( ) => {
25
25
it ( 'should calcPageIndex' , ( ) => {
26
- expect ( uut . calcPageIndex ( 120 , { pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 1 ) ;
27
- expect ( uut . calcPageIndex ( 245 , { pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 2 ) ;
28
- expect ( uut . calcPageIndex ( 481 , { pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 2 ) ;
29
- expect ( uut . calcPageIndex ( 5 , { pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 0 ) ;
26
+ expect ( uut . calcPageIndex ( 120 , { migrate : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 1 ) ;
27
+ expect ( uut . calcPageIndex ( 245 , { migrate : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 2 ) ;
28
+ expect ( uut . calcPageIndex ( 481 , { migrate : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 2 ) ;
29
+ expect ( uut . calcPageIndex ( 5 , { migrate : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 0 ) ;
30
30
} ) ;
31
31
32
32
it ( 'should calcPageIndex (loop mode)' , ( ) => {
33
- expect ( uut . calcPageIndex ( 120 , { loop : true , pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 0 ) ;
34
- expect ( uut . calcPageIndex ( 245 , { loop : true , pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 1 ) ;
35
- expect ( uut . calcPageIndex ( 481 , { loop : true , pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 0 ) ;
36
- expect ( uut . calcPageIndex ( 5 , { loop : true , pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( 2 ) ;
33
+ expect ( uut . calcPageIndex ( 120 , { migrate : true , loop : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 0 ) ;
34
+ expect ( uut . calcPageIndex ( 245 , { migrate : true , loop : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 1 ) ;
35
+ expect ( uut . calcPageIndex ( 481 , { migrate : true , loop : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 0 ) ;
36
+ expect ( uut . calcPageIndex ( 5 , { migrate : true , loop : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( 2 ) ;
37
37
} ) ;
38
38
} ) ;
39
39
40
40
it ( 'should return isOutsideLimits' , ( ) => {
41
- expect ( uut . isOutOfBounds ( 120 , { pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( false ) ;
42
- expect ( uut . isOutOfBounds ( 1125 , { pageWidth : 375 , children : [ { } , { } , { } , { } ] } ) ) . toBe ( false ) ;
43
- expect ( uut . isOutOfBounds ( 0 , { pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( true ) ;
44
- expect ( uut . isOutOfBounds ( 481 , { pageWidth : 120 , children : [ { } , { } , { } ] } ) ) . toBe ( true ) ;
45
- expect ( uut . isOutOfBounds ( 1875 , { pageWidth : 375 , children : [ { } , { } , { } , { } ] } ) ) . toBe ( true ) ;
41
+ expect ( uut . isOutOfBounds ( 120 , { migrate : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( false ) ;
42
+ expect ( uut . isOutOfBounds ( 1125 , { migrate : true , children : [ { } , { } , { } , { } ] } , 375 ) ) . toBe ( false ) ;
43
+ expect ( uut . isOutOfBounds ( 0 , { migrate : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( true ) ;
44
+ expect ( uut . isOutOfBounds ( 481 , { migrate : true , children : [ { } , { } , { } ] } , 120 ) ) . toBe ( true ) ;
45
+ expect ( uut . isOutOfBounds ( 1875 , { migrate : true , children : [ { } , { } , { } , { } ] } , 375 ) ) . toBe ( true ) ;
46
46
} ) ;
47
47
48
48
it ( 'should calcCarouselWidth' , ( ) => {
49
- expect ( uut . calcCarouselWidth ( { pageWidth : 70 , children : [ { } , { } , { } ] } ) ) . toBe ( 210 ) ;
50
- expect ( uut . calcCarouselWidth ( { pageWidth : 50 , children : [ { } , { } , { } ] } ) ) . toBe ( 150 ) ;
51
- expect ( uut . calcCarouselWidth ( { pageWidth : 150 , loop : true , children : [ { } , { } , { } ] } ) ) . toBe ( 750 ) ;
49
+ expect ( uut . calcCarouselWidth ( { migrate : true , pageWidth : 70 , children : [ { } , { } , { } ] } ) ) . toBe ( 210 ) ;
50
+ expect ( uut . calcCarouselWidth ( { migrate : true , pageWidth : 50 , children : [ { } , { } , { } ] } ) ) . toBe ( 150 ) ;
51
+ expect ( uut . calcCarouselWidth ( { migrate : true , pageWidth : 150 , loop : true , children : [ { } , { } , { } ] } ) ) . toBe ( 750 ) ;
52
52
} ) ;
53
53
} ) ;
0 commit comments