-
Notifications
You must be signed in to change notification settings - Fork 0
/
Carousel.test.js
50 lines (42 loc) · 1.21 KB
/
Carousel.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import React from 'react';
import { shallow } from 'enzyme';
import Carousel from '../Carousel';
import CarouselButton from '../CarouselButton';
describe('Carousel', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<Carousel />);
});
it('renders a <div>', () => {
expect(wrapper.type()).toBe('div');
});
it('has an intial `slideIndex` of 0', () => {
expect(wrapper.state('slideIndex')).toBe(0);
});
it('renders a CarouselButton labeled "Prev"', () => {
expect(
wrapper
.find(CarouselButton)
.at(0)
.prop('children')
).toBe('Prev');
});
it('renders a Carouselbutton labeled "Next"', () => {
expect(
wrapper
.find(CarouselButton)
.at(1)
.prop('children')
).toBe('Next');
});
it('decrements `slideIndex` when Prev is clicked', () => {
wrapper.setState({ slideIndex: 1 });
wrapper.find('[data-action="prev"]').simulate('click');
expect(wrapper.state('slideIndex')).toBe(0);
});
it('increments `slideIndex` when Next is clicked', () => {
wrapper.setState({ slideIndex: 1 });
wrapper.find('[data-action="next"]').simulate('click');
expect(wrapper.state('slideIndex')).toBe(2);
});
});