From 5118b42da7c49ab1bbe55dd4fad2661138681d49 Mon Sep 17 00:00:00 2001 From: Mathias Schreck Date: Tue, 24 Mar 2015 12:56:14 +0100 Subject: [PATCH] [added] Test for carousel control behaviour with wrap=true --- test/CarouselSpec.jsx | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/test/CarouselSpec.jsx b/test/CarouselSpec.jsx index 6174dd16c0..f2a63568d9 100644 --- a/test/CarouselSpec.jsx +++ b/test/CarouselSpec.jsx @@ -73,4 +73,45 @@ describe('Carousel', function () { )[0] ); }); + + it('Should show all controls on the first/last image if wrap is true', function () { + var instance = ReactTestUtils.renderIntoDocument( + + Item 1 content + Item 2 content + + ); + + var backButton = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'left'); + + assert.ok(backButton); + assert.equal(backButton.props.href, '#prev'); + + instance = ReactTestUtils.renderIntoDocument( + + Item 1 content + Item 2 content + + ); + + var nextButton = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'right'); + + assert.ok(nextButton); + assert.equal(nextButton.props.href, '#next'); + }); + + it('Should not show the prev button on the first image if wrap is false', function () { + var instance = ReactTestUtils.renderIntoDocument( + + Item 1 content + Item 2 content + + ); + + var backButtons = ReactTestUtils.scryRenderedDOMComponentsWithClass(instance, 'left'); + var nextButtons = ReactTestUtils.scryRenderedDOMComponentsWithClass(instance, 'right'); + + assert.equal(backButtons.length, 0); + assert.equal(nextButtons.length, 1); + }); });