@@ -10,7 +10,7 @@ import { omit } from "lodash";
10
10
import { shallow , mount } from "enzyme" ;
11
11
import SvgTestHelper from "../svg-test-helper" ;
12
12
import { VictoryAxis } from "packages/victory-axis/src/index" ;
13
- import { VictoryLabel } from "packages/victory-core/src/index" ;
13
+ import { VictoryLabel , LineSegment } from "packages/victory-core/src/index" ;
14
14
import { TextSize } from "packages/victory-core" ;
15
15
16
16
describe ( "components/victory-axis" , ( ) => {
@@ -32,15 +32,27 @@ describe("components/victory-axis", () => {
32
32
it ( "renders the appropriate number of ticks" , ( ) => {
33
33
const tickValues = [ 1 , 2 , 3 ] ;
34
34
const style = { ticks : { stroke : "black" } } ;
35
- const wrapper = shallow ( < VictoryAxis tickValues = { tickValues } style = { style } /> ) ;
35
+ const wrapper = shallow (
36
+ < VictoryAxis
37
+ tickValues = { tickValues }
38
+ style = { style }
39
+ tickComponent = { < LineSegment type = "tick" /> }
40
+ />
41
+ ) ;
36
42
const ticks = wrapper . find ( '[type="tick"]' ) ;
37
43
expect ( ticks . length ) . to . equal ( tickValues . length ) ;
38
44
} ) ;
39
45
40
46
it ( "does not render invisible ticks" , ( ) => {
41
47
const tickValues = [ 1 , 2 , 3 ] ;
42
48
const style = { ticks : { stroke : "none" } } ;
43
- const wrapper = shallow ( < VictoryAxis tickValues = { tickValues } style = { style } /> ) ;
49
+ const wrapper = shallow (
50
+ < VictoryAxis
51
+ tickValues = { tickValues }
52
+ style = { style }
53
+ tickComponent = { < LineSegment type = "tick" /> }
54
+ />
55
+ ) ;
44
56
const ticks = wrapper . find ( '[type="tick"]' ) ;
45
57
expect ( ticks . length ) . to . equal ( 0 ) ;
46
58
} ) ;
@@ -60,20 +72,21 @@ describe("components/victory-axis", () => {
60
72
] }
61
73
tickValues = { tickValues }
62
74
style = { style }
75
+ tickComponent = { < LineSegment type = "tick" /> }
63
76
/>
64
77
) ;
65
78
const ticks = wrapper . find ( '[type="tick"]' ) ;
66
79
expect ( ticks . length ) . to . equal ( tickValues . length ) ;
67
80
} ) ;
68
81
69
82
it ( "renders ticks as lines" , ( ) => {
70
- const wrapper = mount ( < VictoryAxis /> ) ;
83
+ const wrapper = mount ( < VictoryAxis axisComponent = { < LineSegment type = "axis" /> } /> ) ;
71
84
const ticks = wrapper . find ( '[type="axis"]' ) ;
72
85
ticks . forEach ( SvgTestHelper . expectIsALine ) ;
73
86
} ) ;
74
87
75
88
it ( "renders a line" , ( ) => {
76
- const wrapper = mount ( < VictoryAxis /> ) ;
89
+ const wrapper = mount ( < VictoryAxis axisComponent = { < LineSegment type = "axis" /> } /> ) ;
77
90
const line = wrapper . find ( '[type="axis"]' ) ;
78
91
SvgTestHelper . expectIsALine ( line ) ;
79
92
} ) ;
@@ -112,14 +125,16 @@ describe("components/victory-axis", () => {
112
125
describe ( "dependentAxis prop" , ( ) => {
113
126
it ( "renders a horizontal axis by default" , ( ) => {
114
127
const props = { padding : 50 , width : 300 } ;
115
- const wrapper = mount ( < VictoryAxis { ...props } /> ) ;
128
+ const wrapper = mount ( < VictoryAxis { ...props } axisComponent = { < LineSegment type = "axis" /> } /> ) ;
116
129
const line = wrapper . find ( '[type="axis"]' ) ;
117
130
expect ( SvgTestHelper . isHorizontalAxis ( line , props ) ) . to . equal ( true ) ;
118
131
} ) ;
119
132
120
133
it ( "renders a vertical axis if specified" , ( ) => {
121
134
const props = { padding : 50 , height : 300 } ;
122
- const wrapper = mount ( < VictoryAxis dependentAxis { ...props } /> ) ;
135
+ const wrapper = mount (
136
+ < VictoryAxis dependentAxis { ...props } axisComponent = { < LineSegment type = "axis" /> } />
137
+ ) ;
123
138
const line = wrapper . find ( '[type="axis"]' ) ;
124
139
expect ( SvgTestHelper . isVerticalAxis ( line , props ) ) . to . equal ( true ) ;
125
140
} ) ;
@@ -155,6 +170,7 @@ describe("components/victory-axis", () => {
155
170
eventHandlers : { onClick : clickHandler }
156
171
}
157
172
] }
173
+ axisComponent = { < LineSegment type = "axis" /> }
158
174
/>
159
175
) ;
160
176
const Data = wrapper . find ( '[type="axis"]' ) ;
@@ -189,6 +205,7 @@ describe("components/victory-axis", () => {
189
205
ticks : { stroke : "black" } ,
190
206
tickLabels : { padding : 0 }
191
207
} }
208
+ tickComponent = { < LineSegment type = "tick" /> }
192
209
/>
193
210
) ;
194
211
expect ( wrapper . find ( '[type="tick"]' ) . length ) . to . equal ( 3 ) ;
@@ -206,7 +223,12 @@ describe("components/victory-axis", () => {
206
223
it ( "renders the appropriate number of ticks with default options" , ( ) => {
207
224
const style = { ticks : { stroke : "black" } } ;
208
225
const wrapper = shallow (
209
- < VictoryAxis tickValues = { [ "1" , "2" , "3" ] } style = { style } width = { 10 } />
226
+ < VictoryAxis
227
+ tickValues = { [ "1" , "2" , "3" ] }
228
+ style = { style }
229
+ width = { 10 }
230
+ tickComponent = { < LineSegment type = "tick" /> }
231
+ />
210
232
) ;
211
233
expect ( wrapper . find ( '[type="tick"]' ) . length ) . to . equal ( 3 ) ;
212
234
} ) ;
@@ -220,6 +242,7 @@ describe("components/victory-axis", () => {
220
242
ticks : { stroke : "black" } ,
221
243
tickLabels : { padding : 0 }
222
244
} }
245
+ tickComponent = { < LineSegment type = "tick" /> }
223
246
/>
224
247
) ;
225
248
expect ( wrapper . find ( '[type="tick"]' ) . length ) . to . equal ( 2 ) ;
@@ -272,6 +295,7 @@ describe("components/victory-axis", () => {
272
295
ticks : { stroke : "black" } ,
273
296
tickLabels : { padding : 10 }
274
297
} }
298
+ tickComponent = { < LineSegment type = "tick" /> }
275
299
/>
276
300
) ;
277
301
expect ( wrapper . find ( '[type="tick"]' ) . length ) . to . equal ( 2 ) ;
@@ -287,6 +311,7 @@ describe("components/victory-axis", () => {
287
311
ticks : { stroke : "black" } ,
288
312
tickLabels : { padding : { top : 10 } }
289
313
} }
314
+ tickComponent = { < LineSegment type = "tick" /> }
290
315
/>
291
316
) ;
292
317
expect ( wrapper . find ( '[type="tick"]' ) . length ) . to . equal ( 2 ) ;
0 commit comments