forked from alibaba-fusion/next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
a11y-spec.js
87 lines (78 loc) · 2.53 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
85
86
87
import React from 'react';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Card from '../../src/card/index';
import '../../src/card/style';
import { unmount, testReact } from '../util/a11y/validate';
Enzyme.configure({ adapter: new Adapter() });
/* eslint-disable no-undef, react/jsx-filename-extension */
describe('Card A11y', () => {
let wrapper;
afterEach(() => {
if (wrapper) {
wrapper.unmount();
wrapper = null;
}
unmount();
});
it('should not have any violations when default', async () => {
wrapper = await testReact(
<Card title="Simple Card">
<div className="card-placeholder" />
</Card>
);
return wrapper;
});
it('should not have any violations when displaying images', async () => {
wrapper = await testReact(
<Card className="image-card" contentHeight="auto">
<img
src="https://img.alicdn.com/tfs/TB1FNIOSFXXXXaWXXXXXXXXXXXX-260-188.png"
alt="father day"
/>
<div className="custom-card">
<h3>Father's Day</h3>
<p>Thank you, papa</p>
</div>
</Card>
);
return wrapper;
});
it('should not have any violations when setting height', async () => {
const commonProps = {
style: { width: 300 },
title: 'Title',
subTitle: 'Sub-title',
};
wrapper = await testReact(
<div>
<Card {...commonProps} contentHeight="auto">
<div className="custom-content">
<p>Card content</p>
<p>Card content</p>
</div>
</Card>
<Card {...commonProps} contentHeight={200}>
<div className="custom-content">
<p>Card content</p>
<p>Card content</p>
</div>
</Card>
</div>
);
return wrapper;
});
it('should not have any violations when setting title off', async () => {
const commonProps = {
style: { width: 300 },
title: 'Title',
};
wrapper = await testReact(
<Card {...commonProps} showTitleBullet={false}>
Card Content
</Card>
);
return wrapper;
});
});