Skip to content

Commit

Permalink
[added] Test for carousel control behaviour with wrap=true
Browse files Browse the repository at this point in the history
  • Loading branch information
lo1tuma committed Mar 24, 2015
1 parent ea479db commit 5118b42
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test/CarouselSpec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<Carousel activeIndex={0} controls={true} wrap={true}>
<CarouselItem ref="item1">Item 1 content</CarouselItem>
<CarouselItem ref="item2">Item 2 content</CarouselItem>
</Carousel>
);

var backButton = ReactTestUtils.findRenderedDOMComponentWithClass(instance, 'left');

assert.ok(backButton);
assert.equal(backButton.props.href, '#prev');

instance = ReactTestUtils.renderIntoDocument(
<Carousel activeIndex={1} controls={true} wrap={true}>
<CarouselItem ref="item1">Item 1 content</CarouselItem>
<CarouselItem ref="item2">Item 2 content</CarouselItem>
</Carousel>
);

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(
<Carousel activeIndex={0} controls={true} wrap={false}>
<CarouselItem ref="item1">Item 1 content</CarouselItem>
<CarouselItem ref="item2">Item 2 content</CarouselItem>
</Carousel>
);

var backButtons = ReactTestUtils.scryRenderedDOMComponentsWithClass(instance, 'left');
var nextButtons = ReactTestUtils.scryRenderedDOMComponentsWithClass(instance, 'right');

assert.equal(backButtons.length, 0);
assert.equal(nextButtons.length, 1);
});
});

0 comments on commit 5118b42

Please sign in to comment.