-
Notifications
You must be signed in to change notification settings - Fork 691
/
AxisTop.test.tsx
77 lines (65 loc) 路 2.48 KB
/
AxisTop.test.tsx
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
import React from 'react';
import { shallow } from 'enzyme';
import { scaleLinear } from '../../vx-scale/src';
import { Axis, AxisTop } from '../src';
import { GenericScale } from '../src/types';
const axisProps = {
scale: scaleLinear({
range: [10, 0],
round: true,
domain: [0, 10],
}) as GenericScale<number>,
};
describe('<AxisTop />', () => {
test('it should be defined', () => {
expect(AxisTop).toBeDefined();
});
test('it should render with class .vx-axis-top', () => {
const wrapper = shallow(<AxisTop {...axisProps} />);
expect(wrapper.prop('axisClassName')).toEqual('vx-axis-top');
});
test('it should set user-specified axisClassName, axisLineClassName, labelClassName, and tickClassName', () => {
const axisClassName = 'axis-test-class';
const axisLineClassName = 'axisline-test-class';
const labelClassName = 'label-test-class';
const tickClassName = 'tick-test-class';
const wrapper = shallow(
<AxisTop
{...axisProps}
axisClassName={axisClassName}
axisLineClassName={axisLineClassName}
labelClassName={labelClassName}
tickClassName={tickClassName}
/>,
);
const axis = wrapper.find(Axis);
expect(axis.prop('axisClassName')).toMatch(axisClassName);
expect(axis.prop('axisLineClassName')).toBe(axisLineClassName);
expect(axis.prop('labelClassName')).toBe(labelClassName);
expect(axis.prop('tickClassName')).toBe(tickClassName);
});
test('it should default labelOffset prop to 8', () => {
const wrapper = shallow(<AxisTop {...axisProps} />);
expect(wrapper.prop('labelOffset')).toEqual(8);
});
test('it should set labelOffset prop', () => {
const labelOffset = 3;
const wrapper = shallow(<AxisTop {...axisProps} labelOffset={labelOffset} />);
expect(wrapper.prop('labelOffset')).toEqual(labelOffset);
});
test('it should default tickLength prop to 8', () => {
const wrapper = shallow(<AxisTop {...axisProps} />);
expect(wrapper.prop('tickLength')).toEqual(8);
});
test('it should set tickLength prop', () => {
const tickLength = 15;
const wrapper = shallow(<AxisTop {...axisProps} tickLength={tickLength} />);
expect(wrapper.prop('tickLength')).toEqual(tickLength);
});
test('it should set label prop', () => {
const label = 'test';
const wrapper = shallow(<AxisTop {...axisProps} label={label} />).dive();
const text = wrapper.find('.vx-axis-label');
expect(text.prop('children')).toEqual(label);
});
});