@@ -73,4 +73,45 @@ describe('Carousel', function () {
73
73
) [ 0 ]
74
74
) ;
75
75
} ) ;
76
+
77
+ it ( 'Should show all controls on the first/last image if wrap is true' , function ( ) {
78
+ var instance = ReactTestUtils . renderIntoDocument (
79
+ < Carousel activeIndex = { 0 } controls = { true } wrap = { true } >
80
+ < CarouselItem ref = "item1" > Item 1 content</ CarouselItem >
81
+ < CarouselItem ref = "item2" > Item 2 content</ CarouselItem >
82
+ </ Carousel >
83
+ ) ;
84
+
85
+ var backButton = ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'left' ) ;
86
+
87
+ assert . ok ( backButton ) ;
88
+ assert . equal ( backButton . props . href , '#prev' ) ;
89
+
90
+ instance = ReactTestUtils . renderIntoDocument (
91
+ < Carousel activeIndex = { 1 } controls = { true } wrap = { true } >
92
+ < CarouselItem ref = "item1" > Item 1 content</ CarouselItem >
93
+ < CarouselItem ref = "item2" > Item 2 content</ CarouselItem >
94
+ </ Carousel >
95
+ ) ;
96
+
97
+ var nextButton = ReactTestUtils . findRenderedDOMComponentWithClass ( instance , 'right' ) ;
98
+
99
+ assert . ok ( nextButton ) ;
100
+ assert . equal ( nextButton . props . href , '#next' ) ;
101
+ } ) ;
102
+
103
+ it ( 'Should not show the prev button on the first image if wrap is false' , function ( ) {
104
+ var instance = ReactTestUtils . renderIntoDocument (
105
+ < Carousel activeIndex = { 0 } controls = { true } wrap = { false } >
106
+ < CarouselItem ref = "item1" > Item 1 content</ CarouselItem >
107
+ < CarouselItem ref = "item2" > Item 2 content</ CarouselItem >
108
+ </ Carousel >
109
+ ) ;
110
+
111
+ var backButtons = ReactTestUtils . scryRenderedDOMComponentsWithClass ( instance , 'left' ) ;
112
+ var nextButtons = ReactTestUtils . scryRenderedDOMComponentsWithClass ( instance , 'right' ) ;
113
+
114
+ assert . equal ( backButtons . length , 0 ) ;
115
+ assert . equal ( nextButtons . length , 1 ) ;
116
+ } ) ;
76
117
} ) ;
0 commit comments