forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
a11y-spec.js
84 lines (74 loc) · 2.31 KB
/
a11y-spec.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import React from 'react';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Slider from '../../src/slider/index';
import '../../src/slider/style';
import './index.scss';
import { unmount, testReact } from '../util/a11y/validate';
Enzyme.configure({ adapter: new Adapter() });
const slides = [1, 2, 3, 4].map((item, index) => (
<div key={index} className="custom-slick-item" style={{ width: '500px' }}>
<h3>{item}</h3>
</div>
));
const multiSlides = [1, 2, 3, 4, 5, 6, 7, 8, 9].map(item => (
<div key={item}>
<h3>{item}</h3>
</div>
));
/* eslint-disable no-undef, react/jsx-filename-extension */
describe('Slider A11y', () => {
let wrapper;
afterEach(() => {
if (wrapper) {
wrapper.unmount();
wrapper = null;
}
unmount();
});
it('should not have any violations', async () => {
wrapper = await testReact(<Slider>{slides}</Slider>);
return wrapper;
});
it('should not have any violations for single slider', async () => {
wrapper = await testReact(
<Slider>
<div>single slider</div>
</Slider>
);
return wrapper;
});
it('should not have any violations with lazyLoad', async () => {
wrapper = await testReact(
<Slider lazyLoad infinite={false}>
{slides}
</Slider>
);
return wrapper;
});
it('should not have any violations in vertical mode', async () => {
wrapper = await testReact(
<Slider dotsDirection="ver">{slides}</Slider>
);
return wrapper;
});
it('should not have any violations when set slideDirection', async () => {
wrapper = await testReact(
<Slider slideDirection="ver">{slides}</Slider>
);
return wrapper;
});
it('should not have any violations in centerMode', async () => {
const settings = {
className: 'custom-slide center',
centerMode: true,
infinite: true,
dots: false,
arrowPosition: 'outer',
centerPadding: '60px',
slidesToShow: 3,
};
wrapper = await testReact(<Slider {...settings}>{multiSlides}</Slider>);
return wrapper;
});
});